File

advertisement
5.2
The bot goes straight in a line until it hits an object and the sensors sense it. The bot immediately
backs up according to the REV_TIME and spins 180 degrees (according to the SPIN_TIME) and
continues in a straight line. This process keeps on repeating. If there is no object on the way of
the bot, it will never stop by itself and keep moving forward.
The effect of changing the values of REV_TIME and SPIN_TIME are that the bot will take
different time to reverse and to spin respectively. Hence the distance it backs up and the degree
turn it takes will change according to the REV_TIME and SPIN_TIME.
Using the define method of declaring a constant enables us to declare a constant in one place and
use it throughout our program, therefore saving some time and making the language simpler to
write.
5.3
Mechanical structure of the second bumpbot is better because it keeps the bumpbot flexible due
to rubber bands and hence prevents it from falling off. Also, the flexibility of the bumpbot does
not let other parts experience a sudden stress due to collision between the bumpbot and any
object.
Logical control strategy in bot 2 is different from bot 1. Here we use UNTIL (SENSOR1 == 0);
Because of the structure, the SENSOR1==1 is always true UNTIL the bot hits an object to get
SENSOR 1==0. Also, the use of RANDOM (SPIN_RANDOM) is better as it brings variability
and different spin times.
LISTING:
BOT 1:
// Group 3 bot 1
// sensors
#define BUMP IN_1
#define LEFT OUT_A
#define RIGHT OUT_C
#define LR OUT_AC
#define REV_TIME 500
#define SPIN_MIN 700
#define SPIN_RANDOM 500
task main()
{
SetSensorTouch(BUMP);
// start going forward
OnFwd(LR, 75);
while(true)
{
until(SENSOR_1==1);
OnRev(LR, 75);
Wait(REV_TIME);
OnFwd(LEFT, 75);
Wait(SPIN_MIN +
Random(SPIN_RANDOM));
OnFwd(LR, 75);
}
}
2: BOT 2
// group 3 superbot
#define BUMP IN_1
#define LFT OUT_A
#define RGT OUT_C
#define LFTRGT OUT_AC
#define REV_TIME 400
#define SPIN_TIME 500
task main()
{
SetSensorTouch(BUMP);
OnFwd(LFTRGT, 75);
while(true)
{
until(SENSOR_1==1);
OnRev(LFTRGT, 50);
Wait(REV_TIME);
OnFwd(LFT, 75);
Wait(REV_TIME);
OnFwd(LFTRGT, 75);
}
}
This is listing for bot 2 with a better bumper.
Steps: The rev time, spin time and outputs were defined. The sensor was set and the main task was
coded.
Output: The robot moves forward with 75% of power until it hits an object. After it hits an object, the
touch sensor senses it and the bot reverses as per the coded Rev_time. It turns left with 50% power
according to the spin time and the again starts moving forward until it hits another object and repeats
the same process.
Answers:
Mechanical and logical control strategies of bot 2 are better and discussed in 5.3.
Download