Desktop RoboTurret - PC Control - Vision Tracking Via RoboRealm

Download the Sketch

RoboTurret Sketches

A .zip file with all of the RoboTurret Sketches can be found here.

Unzip the file and you will have a folder called desktopRoboTurretV3-master We recommend that you create a folder RobotGeek Sketches in your Arduino user folder and put the desktopRoboTurretV3-master in there. The rest of this guide will assume you've placed your sketches in the following folder.

  Arduino -> RobotGeek Sketches -> desktopRoboTurretV3-master

This will be the same 'Arduino' folder you put your libraries and robotgeek tools in, and NOT the folder where the Arduino application is.

PC Control - Vision Tracking Via RoboRealm

The Geekduino's microprocessor does not have enough power to perform vision tracking on its own - it needs some additional help. By loading a 'pass through' sketch onto the board, the Geekduino can be directly controlled by a computer. The computer can run the processor intensive vision tracking algorithms, then control the turret in response to movement.

For this example you will need the following in addition to your RoboTurret:

  • A Computer running Windows XP, Vista, 7, or 8
  • A copy of RoboRealm
  • A Webcam (this example will use a RobotGeek Webcam, but any camera supported by RoboRealm will work)

Roborealm, the RobotGeek Webcam, and the mounting hardware are included in the Vision Tracking Kit.

First you will need to load the pass-through sketch onto your Geekduino. You can find the sketch here:

    File -> Sketchbook -> RobotGeek Sketches -> RoboTurret v3 -> roboTurret3_roboRealm  

Wiring to the Sensor Shield for Vision Tracking is identical to the Test setup. You will also need to attach the webcam directly to your computer.

Device Pin Type Pin #
Pan Servo Digital 10
Tilt Servo Digital 11
Laser Digital 2
b_500_500_16777215_00__images_tutorials_desktopRoboTurret_roboTurret_vision_bb.png

You will now need to install RoboRealm. Insert the CD and follow the installer instructions.

Once you have installed RoboRealm, launch the program. Click the Camera button to try out your camera.

  • If you do not see a camera or it is slow, click the Options button. From the Video tab, select your camera from the drop-down menu. You should now be able to click the Video Format button to adjust the picture size and frame rate.
  • If you do not see your camera listed, use the Windows device manager to make sure your webcam is properly installed
  • If you are having poor performance, try lowering the resolution or frame rate of your camera.
  • For best performance, plug your camera directly into your computer, and not through any extenders or hubs.

Now that your camera is working, you can open up the RoboRealm demo file. The file is in the same folder as the Arduino RoboRealm pass-through sketch.

Arduino -> RobotGeek Sketches ->desktopRoboTurretV3-master -> roboTurret3_roboRealm ->Desktop_RoboTurret_v3_color.robo  

With your camera activated, you can now press the Run button to run the vision tracking program. A blue box should appear around the largest red object in the camera's view. Your RoboTurret should move along, keeping the red object centered in the camera's view.

If the program is working (you will see a blue box imposed over the red object on your screen) but the turret does not move along, check to make sure you are using the correct serial port. Double click the Sparkfun_Arduino field and select the correct serial port from the COM Port drop-down. This will be the same port you used to program your Geekduino.
The Roborealm example can be changed to fit your needs. The following is a quick overview of the modules that make up the color tracking example.
  • Set PAN_SERVO = 1500, TILT_SERVO = 1500, LASER = 0 This module will set the default values for the pan/tilt servo and the laser. You can adjust these if you want to change the default behavior of the turret.
  • RGB_Filter Red This module will allow you to pick different colors to track. We recommend that you only try to track one color at a time. You can also fine-tune the intensity, hue, and hysteresis to get better results for your lighting environment.
  • Blob Size 50 - 0 This module lets you adjust the size of the object being tracked.
  • Center of Gravity This module calculates the center of the object being tracked. You can use this module to change the overlay color and behavior.
  • VBScript Program This module runs the logic that will make the RoboTurret move. The code will take in the center of gravity information and move the turrets to keep that object in the center of the camera's view.
  • Sparkfun_Arduino This module is the bridge between RoboRealm and the Geekduino. By sending serial data to the Geekduino, this module can control each port. If you would like to directly test any of the ports, delete the Variable text from the field - you can then use the sliders and checkboxes to activate connected devices - just be sure to set the variables back when your done!

Feedback Form