The Surveyor SRV-1 is a great platform for experimenting in machine vision. With the wireless communication and built in camera the SRV-1 is a natural choice for machine vision processing using a PC.
In this tutorial we experiment with the wall avoidance capabilities that can be performed using RoboRealm and the SRV-1. In particular we have a look at how the SRV-1 operates within a confined location surrounded by walls. The environment has been re-purposed from a Trinity FireFighting Maze to show how the SRV-1 can operate within that environment.
First left us have a look at our simple environment ...
Example Room
The purpose is to have the SRV-1 roam around within this room while avoiding the walls. We first experimented with the built in "wander mode" of the SRV-1. This mode works fine in a spacious environment but simply keeps rotating on spot within this small room.
Part of the problem is that the camera on the SRV-1 is angled slightly up and therefore not much of the floor becomes visible. Due to the lack of visible floor we then decided to use the IR capabilities of the SRV-1 instead of vision.
The IR works nicely within its designed space requirements in a living room but are set too bright for our maze room. Turning on the IR and setting the robot within the room would completely saturate the entire room (all walls are bright white) with IR light and cause all readings to be at their maximum. Therefore IR was just not going to work either!
Back to vision ...
Camera View
If the robot is placed in one end of the room facing the other we get an image likeAnother possibility is to bend the aluminum bracket that holds the camera downwards a bit. There is enough room under the bracket to change the angle between 10-15 degrees which should be plenty. From the Surveyor folks themselves: "The only caveat is to make certain that there's no contact between the bracket and the front of the battery."
Onto the Wall Detector ...
Wall Detection
The intensity difference between the floor and the wall is easily determined by theWall Finder module. This module will place a red stripe where it seems a maximum change from the bottom of the image towards the top. This is not unlike the built in capabilities of the SRV-1 used in the wander mode.Running this module on the image revealsUsing these variables it is now possible to create a script to navigate the robot around our room.
Onto some VBScript scripting ...
VBScripting the SRV-1
Using the variables provide by the Wall Finder module we can create the following VBScript that will map the wall variables to motor values that are then send to the SRV-1.We would like to turn the robot away from the wall using the most efficient angle. Always turning in one direction would cause the robot to turn into the wall in many of the wall collision cases. In other words, if the robot approaches a wall like thisHowever, there is an interesting problem using this technique when approaching a sharp angle corner (like the one at the tip of the room). The problem is that when the robot approaches the corner from one side it will use the WALL_SLOPE to turn the other direction. Once this is done the robot re-samples what it seems and determines that the WALL_SLOPE has now switched signs and therefore will move in the opposite direction to what it just did. Thus the robot is stuck in an oscillation between left and right movements.
To prevent this oscillation from happening we need to bias the rotational movement until we determine that it is safe to resample the WALL_SLOPE for a potentially new rotational direction. We do this by setting a "turn_bias" variable that once set will ensure the robot only rotates in that direction. This variable is then reset when the robot proceeds forward for a least three or more steps. This reset will only occur when the robot has decided that it is safe to move forward and can then resample the slope once again when approaching another wall.
The following VBScript is used within the VBScript module
' check if we are near a wallif GetVariable("LOWEST_WALL_Y") < 10 then
' if we need to turn check the
' turn bias to make sure that
' if we have already turned that
' we continue to turn in the same
' direction
turnBias = GetStrVariable("turn_bias")
if turnBias = "right" then
SetVariable "left_motor", 95
SetVariable "right_motor", 165
elseif turnBias = "left" then
SetVariable "left_motor", 165
SetVariable "right_motor", 95
' otherwise check the wall slope to determine
' the best direction to turn
elseif GetVariable("WALL_SLOPE") < 0.0 then
SetVariable "left_motor", 95
SetVariable "right_motor", 165
' don't forget to bias successive
' turns in the same direction
SetVariable "turn_bias", "right"
else
SetVariable "left_motor", 165
SetVariable "right_motor", 95
SetVariable "turn_bias", "left"
end if
else
' increment the forward counter
forwardCount = GetVariable("forward_count")
SetVariable "forward_count", forwardCount+1
' if we have moved forward for 3+ steps reset
' the turning bias
if forwardCount > 2 then
SetVariable "turn_bias", ""
end if
' move the robot forward
SetVariable "left_motor", 150
SetVariable "right_motor", 150
end if
No comments:
Post a Comment