Getting Started with Walabot

Pages
Contributors: bboyho
Favorited Favorite 4

Example API

Let's try out the examples in Python! The examples enable the user to utilize the sensor data for embedded projects. There a few methods of running the examples. Since we still have the command line open, we'll open the Python example through the terminal. Navigate to the examples using this command:

cd /usr/share/doc/walabot/examples/python

Typing this command will list the three examples in that path:

ls

Connect the Walabot to the USB port to start testing the Walabot examples.

Walabot Examples via Command LIne

Target Detection w/ SensorApp.py

To run the SensorApp.py example, type this command once you are in the directory.

python SensorApp.py

Again, make sure there are no moving objects in front of the sensor when the program begins. The SensorApp.py is just like the target detection example that was demonstrated in the SDK for Windows. The sensor data will be output in the terminal as shown below.

Walabot SensorApp.py Running

Try moving your hand in front of the sensor to get a feel for the sensor values. Type Ctrl+c in the command line to stop the program.

Breathing w/ BreathingApp.py

To run the BreathingApp.py example, type this command:

python BreathingApp.py

This is just like the breathing example that was demonstrated in the SDK for Windows. With nothing in front of the Walabot, the output should be a very small value.

Walabot BreathingApp.py with No Person

Stand in front of the Walablot and take a deep breath in. As you inhale, the value may look like the output below. The value may be different depending on how far you are from the Walalbot.

Walabot BreathingApp.py Inhaling

As you exhale, the value should decrease. The output may look similar to the output below.

Walabot BreathingApp.py Exhaling

Type Ctrl+c in the command line to stop the program.

Detecting Objects Behind Materials w/ InWallApp.py

To run the InWallApp.py example, type this command:

python InWallApp.py

Again, move the Walabot slowly a circular motion on a flat surface once the program begins. Here's what the output may look like when there are no objects behind a wall or table.

InWallApp.py Nothing in Wall

Here's what the output may look like when there is a metal pipe behind the surface.

InWallApp.py Pipe Parallel

Rotating the Walabot, here's what the output may look like with the metal pipe behind the surface.

InWallApp.py Pipe Perpendicular

Type Ctrl+c in the command line to stop the program.

Displaying Targets w/ SensorTargets.py

Let's try one more example from Walabot's GitHub repository:

For simplicity, we will head to the Walabot-SensorTargets repository. The other examples may require you to adjust the code and hardware to run the the examples. Download the example by clicking on the Clone or download button. Click again on Download ZIP. Head to the directory where the files were downloaded by typing the following command:

cd Downloads

Unzip the .zip with this command:

unzip Walabot-SensorTargets-master.zip

In the command line, type the following:

pip install WalabotAPI --no-index --find-links="/usr/share/walabot/python/"

Change the current directory where the example was unzipped:

cd Walabot-SensorTargets-master

Run the example by typing:

python SensorTargets.py

The program will begin running and open a separate window. Click on the Start button to begin reading and ensure that there is nothing moving in front of the Walabot.

Walabot SensorTargets.py

An object should display in the arena when in front of the Walabot. In this example, I just placed my hand in front of the Walabot.

Walabot SensorTargets.py with Hand

Now that we have tested the SensorTargets.py, try the other examples listed in the GitHub repository! The SeeThroughDemo.py is a neat example that visually notifies you if there is an object behind a wall instead of just the output values in the InWallApp.py . The RawImage.py graphically displays the image of objects in view just like the SDK in Windows.

Troubleshooting

Here are a few troubleshooting tips when using the Walabot on a Raspberry Pi.

• Missing Walabot API

If you are having issues running the Python examples from GitHub, the Python packages for the Walabot API may not be installed. You may receive an error similar to the output below.

language:emacs
Traceback (most recent call last):
  File "sensorTargets.py, line 3, in <module>
    import WalabotAPI
ImportError:NoModule named WalabotAPI

Try using the pip command as explained earlier.

• Suspended Program

If you typed Ctrl+z, the program is suspended. You may get an error similar to the output below.

language:emacs
^Z
[1]+  Stopped                 python SensorApp.py
pi@raspberrypi:/usr/share/doc/walabot/examples/python $ python SensorApp.py
Traceback (most recent call last):
  File "SensorApp.py", line 74, in <module>
    SensorApp()
  File "SensorApp.py", line 38, in SensorApp
    wlbt.ConnectAny()
  File "/usr/share/walabot/python/WalabotAPI.py", line 186, in ConnectAny
    _RaiseIfErr(_wlbt.Walabot_ConnectAny())
  File "/usr/share/walabot/python/WalabotAPI.py", line 122, in _RaiseIfErr
    raise WalabotError(message, res, extended)
WalabotAPI.WalabotError: WALABOT_INSTRUMENT_NOT_FOUND
pi@raspberrypi:/usr/share/doc/walabot/examples/python $ 
Traceback (most recent call last):
  File "SensorApp.py", line 74, in <module>
    SensorApp()
  File "SensorApp.py", line 38, in SensorApp
    wlbt.ConnectAny()
  File "/usr/share/walabot/python/WalabotAPI.py", line 186, in ConnectAny
    _RaiseIfErr(_wlbt.Walabot_ConnectAny())
  File "/usr/share/walabot/python/WalabotAPI.py", line 122, in _RaiseIfErr
    raise WalabotError(message, res, extended)
WalabotAPI.WalabotError: WALABOT_INSTRUMENT_NOT_FOUND

You could try closing the command line and restarting the program.