Project tutorial
Walabot Object Detection

Walabot Object Detection

A PC application that talks to the Walabot PRO, Arduino and NeoPixels!

  • 3,487 views
  • 1 comment
  • 7 respects

Components and supplies

About this project

Welcome to my Walabot project

I will split this project in different parts

  • 1. Get to know the Walabot and a setup. This includes data readout and send it to an Arduino.
  • 2. Gather the data that is needed for the calculations and create an image with this data
  • 3. Convert the data to an object

Getting started with the Walabot

I've made a Windows WPF application to easily configure, setup and read data of the Walabot. Also for testing purpose I connected an Arduino through a serial connection. In this way I can control the Arduino's GPIO with the input from the Walabot. This data is send with the WPF application..

As documented in the Walabot API webpage and the useful comments of the Walabot examples, the following flow is needed to get data of the Walabot:

  • 1 ) Connect
  • 2 ) Configure
  • 3 ) Calibrate
  • 4 ) Start
  • 5 ) Trigger
  • 6 ) Get action
  • 7 ) Stop/Disconnect

In my Arduino example, I determine the found targets:

// Find the targets
SensorTarget[] targets = walabot.GetSensorTargets(); 
// Get the total number of found targets
int numTargets = targets.Length; 

With the targets found, each target has it's own data, to find the distance between each target and the Walabot, the Z-poss variable will be used. This is found by:

// Get the distance for the target
double distanceTarget = targets[targetIdx].zPosCm;  
// targets[]  = the array with the found targets.
// targetIdx  = the selected target
// .zPosCM    = the Z position of the target.

If you place this in a loop for each found target, all the data can be found. Always make sure that you specify the TargetIdx in the right configuration, so no null references will be made.

To make the data more readable, and change it so the data can directly be send to the Arduino:

String distanceTargetString = Math.Round(targets[targetIdx].zPosCm).ToString("00"); 
// distanceTargetString = Z position in a string
// Math.Round = used for rounding the data of the double
// .toString("00") = used for changing the rounded int to a String,
// the "00" in the toString() is used to change the format of the measurement 
// which easily can be used to send the data and use it inside the application.

This data will be send to the Arduino by a serial connection. Simply register the COM port of the Arduino and send serial data to it. Multiple tutorials are available online to setup this connection.

I setup a predefined string to split to send only one data package to the Arduino. The Arduino will split this data and execute the right function.

sting sendData = C0_022_#FF00FF // data string to be send to Arduino, with: 
// C       - the function
// 0       - the selected target (if needed)
// _       - a sepperator 
// 022     - Data from the Walabot 
// _       - a seperator
// #FF00FF - A color preference 

- Walabot setup

Since I found the Walabot Filters and Profiles a little difficult, I made a summary below. This was found from the walabot api pages. Links are found below.

Walabot filters:

FILTER_TYPE filterType = mtiMode ?

FILTER_TYPE.FILTER_TYPE_MTI : //Moving Target Identification: standard dynamic-imaging filter

FILTER_TYPE.FILTER_TYPE_NONE;

walabot.SetDynamicImageFilter(filterType);

Dynamic Filtering
For applications that require tracking movement, Walabot can apply a dynamic-imaging filter that removes static signals, leaving only changing signals. In addition to the Moving Target Identification (MTI) filter, the Derivative filter is available for the specific frequencies typical of breathing. Here’s an example display of Derivative-filtered image energy from sensor-narrow scanning (breathing):

Walabot Profiles

Sensor

walabot.SetProfile(APP_PROFILE.PROF_SENSOR);

  • distance stanning through air,
  • high resolution images
  • slower capture range

Sensor narrow

walabot.SetProfile(APP_PROFILE.PROF_SENSOR_NARROW );

  • lower-resolution images
  • fast capture
  • useful for tracking quick movement

Short-range (imaging)

walabot.SetProfile(APP_PROFILE.PROF_SHORT_RANGE_IMAGING );

  • Short range
  • penetrative scanning inside dielectric materials

Short-range (singe line)

walabot.SetProfile(APP_PROFILE.PROF_SHORT_RANGE_SINGLE_LINE );

  • Short range
  • Small number of antennas pairs

- Arduino Setup

The Arduino will be used to receive the imput of the Walabot and use this data as input for the Neopixels. I use the Arduino (Genuino) MKR1000, but every board can be used in this scenario.

The Arduino has to be setup to read serial data, this is done by:

Serial.begin(9600); 

and read the data with:

if(Serial.available() > 0) // if serial connection is available
{ 
    // read a full string
    String serialString = Serial.readString(); 
    // read the first char of the input string (serialString)
    char serialStringNumberCommand = serialString[0]; 
    // switch between commands using the char. 
    switch(serialStringNumberCommand)
    {
       case 'a' : <execute first command>;   break; 
       case 'b' : <execute second command>;  break;  
       default:   <execute default command>; break;
    }
}

The method above will be used to send the data to the Neopixels. Below the steps to light up the LEDs:

// declare the neopixels
int NUMBER_OF_NEOPIXELS = xxx; // number of connected LEDs
int PIN  x; // pin on the Arduino where the Neopixels are connected
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMBER_OF_NEOPIXELS, PIN, NEO_RGB + NEO_KHZ800); 
// in the setup():
strip.begin();
// in the loop() or other functions:
// set the color [c] of a specific Led [i]
strip.setPixelColor(i, c); 
// show the LEDs with the changes
strip.show(); 

1. Windows application V1 - Arduino setup & first connection

Here is the first Windows application. Don't botter the layout/UI, will change that in later phases.

Functionality that is included in this V1 application:

  • Connect with the Walabot
  • Connect with an Arduino (the arduino must be configured to read serial data)
  • Colored buttons have the function to light up the RGB LEDs in a specific color.
  • Change the configuration (arena, phi and theta configuration of the walabot)
  • Read the Z-position of (up to) three targets measured by the Walabot
  • Will automatically pass through the Z-asses of the first target to the Arduino

The result of the first phase is quiet successful; objects can be detected and for the first object detected the LEDs will show it's distance. But a lot of additional functionality and calibration has to be done.

2. Windows application V2 - Find the right data

As the progress of the application follows, I implemented a few test and debug functions to test the Walabot. Those functions include getting energy data or x-pos, y-pos and z-pos values and calibrating the walabot with the theta-, phi- and area values.

Mainly testing with the theta-angle and phi-angle did take a lot time, but after hours of testing, the optimal values for detecting an object above the senor where:

  • theta: static at min -1, max 1, resolution: 1,
  • phi: moving from -45 to 45, with iterations of 1 degree. resolution: 1
  • Area: depending on object height. add object_height + 10 for the maximum and object_height - 10 for the minimum. Resolution: 0.1.

My plan is to create a sweep of measurements whereby in each measurement the phi angle is increased. This is to determine in different angles if there is an object. In this way I can determine the width of measured target. The theta angle will be 1, so a small strip of data will be measured.

The object has to stand still for about 2 minutes (each measurements needs to be calibrated again so this will take some time).

I created a function whereby there is a sweep of measurements. In each measurement I will increase the phi angle. Like this:

int x = 0
int x_stepsize = 2; // this value is used for the amount of measurements 
                    // and to widen the angle 
for(x; x<=(MAX_PHI_VALUE - x_stepsize); x += x_stepsize)
{
    minPhiInDegrees = x;
    maxPhiInDegrees = x + x_stepsize; 
}

// update the measurement configuration to include the updated values.
// calibrate the Walabot

This is quite a tricky methode to determine objects, since in each measurement the X, Y and Z are slightly different. But for roughly measurements a start and finish of an object can be detected.

If the first (start of detecting object) and end (last measurement where the object was detected) are known. The width can be calculated. With distance (z-position) is also known.

// saving the distance of the detected object_a. 
zPos = Math.Round(targets[object_a].zPosCm);

For the example: if the object starts at -10 and ends at 18 at a distance of 50cm, the angle is 28 degree. tan(28 *(pi/180) ) * 50 = 26,6cm.

double calculation = tan(angle) * height;  
// note that the angle must be in radian degree
// mulitply the degree with (pi/180)

I've made a simple database where a few objects are defined. This is now hardcoded, with for example:

  • Hand: 5-11 cm
  • Book: 12-16 cm
  • Tablet: 16 - 20 cm
  • Newspaper: 20 - 32 cm
  • Plastic lid: 32 - 40 cm
  • Pillow: 40-50 cm

Based on those values a measurement can be connected to a predefined object. In this way the Walabot can detect objects :) Yeah!

3. Windows application V3 - finding the right object

Demo - detecting objects

Above is the demo of my application where the the windows application does the following;

1. Connect to the Walabot and return the software version.

2. Specify the height where the objects will be searched for. I tried two things; automatically with a single measurement before or manual. The automatically measured zPos of the target will can cause an offset since

Since I have to hold the object by hand I implemented a 3 second delay.

targetDistance = double.Parse(distanceToTarget_TextBox.Text); 

3. Start scanning

This will go through all the phi-angles and save on which angle a object is detected within a specific height-range.

I can just hold the objects with my hand above the sensor. This didn't influence the results for now. But I have to say that it would be easier to mount the object to a standard or tripot.

4. Calculate

With having the starting point and ending point angles and with the known height of the object the width of the object can be calculated.

// combine both found object angles
double widthangleTarget = endObject - startObject; 
// convert total angle to radian 
widthangleTarget = widthangleTarget * (Math.PI / 180); 
// height of the target
double heightTarget = targetDistance;
// calculate the width with the height and angles. 
double calculation = Math.Tan(widthangleTarget) * heightTarget; 

The WPF application project is available in the resources below.

Demo - Arduino

In the video below I demonstrated the Arduino integration. In this demo the distance calculated by the Walabot is send through serial to the Arduino. Depending on the height the LEDs will shown a different/brighter color.

I connected the infinity mirror which I made during my NXP FRDM-K82F project [link]. This mirror includes 125 neopixels.

The Arduino .ino projectfile is available in the resources below.

Things on my todo list

There are some things I want to improve or add to this project, but they cost a bit more time and knowledge.

  • Apply asynchronous functionality to the windows application. So data can be shown in the application without it hangs on loading.
  • Apply my initial idea to convert the measurement-data in a bitmap image. I tried it, but couldn't handle the image/bitmap functionality. I have to learn some more advanced C# code for that.
  • Calibrating the Walabot faster. This would significantly decrease the waiting time for each measurement.
  • Add the same measurements in the other axis (theta angle) to create a 2d image of the object.

Conclusion

This project confirms that the Walabot is an ideal tool for detecting targets. A lot of configurations can be made. I see a lot of possibilities in it and I look forward to implement the Walabot in my next project.

I have to say that this project is far from perfect, but I'm happy with the end result! Object can be detected and the Walabot can handle a lot data. Connecting an Arduino to a Windows Applications was new for me and learned a lot by making it.

Bill of Materials

The following items are used in this project:

  • Walabot Pro
  • Arduino MKR1000
  • Neopixels/WS2812b LEDs
  • Breadboard/wires
  • Windows PC

Resources

Credits

The Walabot team - for the support here at Hackster, through DM and through the Slack app.

Hackster.io - for being an amazing community that makes projects as this one happen.

Thanks for reading!

Code

WPF applicationC#
Note; it's a beta version with some bugs and
No preview (download only).
Arduino applicationArduino
.ino file with serial communications that can read input from the WPF application
No preview (download only).

Comments

Similar projects you might like

Traffic Control with Walabot

Project tutorial by Balázs Simon

  • 1,611 views
  • 0 comments
  • 8 respects

Walabot and Mobile App Controlled 3D-Printed Cars

Project tutorial by Jonathan Mendenhall

  • 6,243 views
  • 2 comments
  • 47 respects

Turn Walabot into a "Why-Not?" Bot for the Disabled/Elderly

Project in progress by Eric Olson

  • 1,639 views
  • 1 comment
  • 8 respects

Walabot for Wireless Gas Sensing

Project tutorial by 3 developers

  • 2,340 views
  • 1 comment
  • 7 respects

Object Tracker and Updater

by Rupin Chheda

  • 2,793 views
  • 4 comments
  • 14 respects

Motion Detection Lamp

Project tutorial by Izzati Azryna

  • 3,065 views
  • 0 comments
  • 8 respects
Add projectSign up / Login