Closed loop control -- collision detector
In a closed loop control system, the robot will typically use information fed back from the environment through its sensors to moderate its own behaviour.
Touch Sensor/Switch
A simple switch can be used within a bumper to create a straightforward touch sensor that allows a robot to identify when it has collided with an obstacle.
RCX Version: Configure the touch sensor switch, download and run an 'empty' program to the brick. Using the View button, observe the reading produced by the touch sensor when the switch is opened and closed.
To make use of the touch sensor, the robot control program should continually check the sensor reading whilst the robot is moving to see whether the switch has been activated. As soon as it has been activated the robot should stop moving forwards and possibly take evasive action. When you have got your program working, think about how you could use the touch sensor to locate a precipice (such as the edge of a table, if the robot is driving around on the table top) as well as a wall.
Exercise: stop on bump
Program the robot so that it will drive forwards until it bumps into something, at which point it should stop.
|
When the program is started, the motors are switched on and the robot starts to drive forwards.
If the contact sensor is pressed closed, it raises an update event that passes a message to the conditional "if" block.
The conditional block tests all event messages raised by the contact sensor. If the "pressed" message is received, then it turns the motors off and the robot will stop. |
act 11 stop on bump.zip
Exercise: reverse on bump
Program the robot so that it will drive forwards until it bumps into something, at whcih point it should reverse for 1 second before driving forwards again.
| In this program, which extends ther previous "stop on bump" program, the robot will drive backwards for 1 second (1000 milliseconds) if the touch sensor is pressed, before driving forwards again. |
act 11 reverse on bump.zip
Exercise: reverse and turn on bump
Program the robot so that it will drive forwards until it bumps into something, at whcih point it should reverse for 1 second, then turn for one second, then start driving forwards again.
act 11 reverse and turn on bump.zip
For an RCX robot
act 11 reverse and turn on bump (rcx).zip
For an NXT robot
act 11 reverse and turn on bump (nxt).zip
For a robot with distance drive
act 11 reverse and turn on bump (distance drive).zip
Exercise: defining a new activity to drive forward, backward and turn
act 11 reverse and turn on bump (new activity).zip
Back to Home or on to Activity 10
Comments (0)
You don't have permission to comment on this page.