loading

Line Following

 Download the Line Following robofile.

  1. This demo allows you to navigate the Roomba using a black line. This works really well to steer the Roomba along a pre-defined coarse by following a line. A good line can be created by using black electrical tape which will also adhere reasonably well to carpet and still be removed without leaving any residue. This demo works best when the camera is pointed down at the floor to avoid any non-line objects from causing confusion.

  2. First double click on the Roomba module in the processing pipeline and change the serial COM port to the one you are using. Note that if you happen to have a serial port on your Netbook then the COM port will most likely be from COM1 to COM4. If you are using a USB to serial converter then it can be a much higher number. RoboRealm will only display those COM ports that are active within the system so the COM port selection should be limited to only a few selections. If you are not sure on which COM port is being used start with the highest one and test while moving to lower ones.

    If you have already configured the Roomba in a previous robofile then the COM port should already be configured for your robot assuming the "Remember as default" checkbox in the Roomba GUI interface is set.

  3. If the camera view is not already present press the Camera button in the main RoboRealm interface to show you the USB webcam image. If you have multiple cameras installed or other imaging devices you may need to press the Options button->Video Tab and select the camera from the dropdown list that shows all the imaging devices installed in the system.

  4. Once you get the COM port and camera set you should see the image from the Roomba in the main RoboRealm GUI. From here you can place the Roomba on a black line and it will start to follow that line. Be sure to check the camera image to ensure that the black line is showing up correctly in the webcam image.

  5. We perform this task by first converting the image to gray using the maxium of the red, green or blue color component using the Grayscale module. This trick helps to convert colored images to a much lighter color than they would be by just converting into gray. Since we want to ignore colored objects (we only want a black line) this helps to remove unwanted objects.

  6. Then we threshold the image into black and white parts using the Auto Threshold module. Note that while the red ball is gone the green one is still present, but our black line is aswell so that's what we want.

  7. Then to disconnect any objects and remove any line that is just very thin we erode the image by removing a couple layers of each objects outter shell using the Erode module. This shrinks everything but also disconnects objects.

  8. Using the Blob Filter module we then remove anything that is too small to be our line and focus on the largest object in the center of the image ... which is presumed to be the line.
  9. Now we want to know the center of gravity of the line which is a good indication of where we should move the robot in order to follow the line. We do this using the Center of Gravity module which identies the center of the line and a good target to move towards to keep on the line.

  10. Finally we now need to tell the Roomba how to move in order to stay on the line by targeting the COG. We do this by understanding on what side of the image the identified target is. If the desired target point is right of the center of the image we need to move the robot right, whilst if it is on the left we need to move left. If we create this behavior the robot will move in the direction of the line. The VBscript module allows us to write some VBScript to set the motor values of the Roomba based on the X coordinate of the target point. The more the X location is to the right the harder we should turn LEFT and vice versa for the other side. The VBScript module produces the left and right motor variables that contains the suggested direction that the Roomba should move. The Roomba module then grabs this value and passes it to the Roomba robot to complete the cycle.