Chasing a Red Ball
Download the Chase Red Ball robofile.
- First double click on the Surveyor_SRV1b module in the processing pipeline. It may take a while to appear since it
will immediately try to connect to the default SRV setting at 192.168.1.15. When it does appear change the IP address
to the one you are using. If you do not know the IP address of the robot you will have to check your router information
or see the Surveyor forum
for more information.
- Once you get the right IP address you should see the image from the SRV in the main RoboRealm GUI. From here you can
now use the cursor keys to move the robot. Using cursor left and cursor right to rotate left and right. Use
the cursor up and down keys to move the robot forward and backward.
- Using a red ball see if the SRV will recognize
it and steer towards the ball.
- We track the ball using the RGB_Filter module to find
any red pixels. This may need to be tweaked depending on your camera properties and overhead lighting. If too much of the
image is detected as red choose a higher threshold.
- Then we erode the remaining pixels to remove any spurious pixels
and ensure that the resulting blob is as round as possible. We do this using the Erode module set to remove
a single layer of pixels from any active blobs.
- To ensure that we have a round red ball we use the
Blob Filter module set to remove anything that is not very circular,
smaller than 100 pixels and anything else but the largest resulting blob from the previous criteria. The blob filter works
by removing blobs that fail feature attributes that are specified in a list format where each blob is tested
against the specified features. This criteria works to reduce
any non-ball shaped red objects from being recognized and followed. We also use this module to create a resulting
BLOBS variable array that contains the center of gravity (middle point) of any resulting blobs. In our case this
will either be 1 blob or none at all.
Finally we now need to tell the SRV how to move in order to target the red ball. We do this by
understanding on what side of the image the ball is. In our case it is on the right side thus we need
to move the robot to the right direction. The VBscript
module allows us to write some VBScript to scale the motor values of the SRV based on the X coordinate of the ball. The
more the X location is to the right the faster the LEFT wheel should turn and the slower the RIGHT one
should turn and vice versa for the other side. The VBScript module produces a left_motor and right_motor
variable that contains the suggested values that the SRV should perform. The SRV module then grabs those values
and passes them onto the SRV to complete the cycle.
- Note that a speed of 128 is neutral (no movement) whilst 0 is all back and 255 is all forward. For example, try
adding a keystroke that will cause the SRV to move forward at top speed!
- Note how the initial choice of color in the RGB_Filter module specifies which color ball to follow. Can you change that module to instead detect a green ball? Or perhaps a green square (requires modification of the Blob Filter)?