Bumpbot
By: Thunderous Silence
// [Link] - a simple bumper
// sensors
#define BUMP SENSOR_1
// motors
#define LEFT OUT_A
#define RIGHT OUT_C
// constants
#define REV_TIME 50
#define SPIN_TIME 70
task main()
{
// configure the sensor
SetSensor(BUMP, SENSOR_TOUCH);
// start going forward
On(LEFT+RIGHT);
// do this forever
while(true)
{
// wait for bumper to hit something
until(BUMP==1);
// back up
Rev(LEFT+RIGHT);
Wait(REV_TIME);
// spin around
Fwd(LEFT);
Wait(SPIN_TIME);
// resume
Fwd(RIGHT);
}
The simple bumper program begins going forward. It continues going forward until the sensor is
activated by the bumper. Once this happens the program instructs the robot to reverse for half of a
second. Then the robot is instructed to spin for seven-tenths of a second then proceed to forward
motion. This process is repeated indefinitely.
// [Link] - improved sensor design
// sensors
#define BUMP SENSOR_1
// motors
#define LEFT OUT_A
#define RIGHT OUT_C
// constants
#define REV_TIME 50
#define SPIN_MIN 70
#define SPIN_RANDOM 50
task main()
{
// configure the sensor
SetSensor(BUMP, SENSOR_TOUCH);
// start going forward
On(LEFT+RIGHT);
// do this forever
while(true)
{
// wait for bumper to hit something
until(BUMP==0);
// back up
Rev(LEFT+RIGHT);
Wait(REV_TIME);
// spin around
Fwd(LEFT);
Wait(SPIN_MIN + Random(SPIN_RANDOM));
// resume
Fwd(RIGHT);
}
}
In this program the bumpbot moves forward until it hits an obstacle that initiates the while loop which
makes the bot reverse and spin. The bot will reverse for a set amount of time however unlike the
previous program the spin will occur for a minimum time plus a random time this will make its exit angle
unpredictable the bot then will resume moving forward. This process repeats infinitely.
Bumpbot2 is mechanically superior to bumpbot1 for two reasons: it is structurally stronger and the
sensor activation mechanism works more reliably. Structurally the extra support trusses improve
strength and durability. Also, the bumper design allows for a wider range of detection. The sensor
mechanism implements a rubber band to ensure that the sensor will reset itself.
Bumpbot2s control logic is better because the bots exit angle will not be the same every time allowing
the bot to negotiate a more difficult course. Bumpbot1s control logic limits it to only making right
turns.