Report 2-Bump Bot

advertisement
BUMP BOT REPORT
A Programming Report
Group 3
Krystal, Yannick, Derek
Bump Bot 1___________________________________________________________________________
// bumpbot1.nxc - a simple bumper
// sensors
#define BUMP SENSOR_1 // motors
#define LEFT OUT_A
#define RIGHT OUT_C // constants
#define REV_TIME 500
#define SPIN_TIME 500
task main()
{
SetSensorTouch(IN_1); // configure sensor input 1
OnFwd(LEFT, 75); // forward left wheel
OnFwd(RIGHT,75); // foward right wheel
while(true) // do this forever
{
until(BUMP == 1); // wait for bumper to hit
OnRev(LEFT, 75); // reverse left wheel
OnRev(RIGHT, 75); // reverse right wheel
Wait(REV_TIME); // reverse for constant time
OnFwd(LEFT, 75); // left wheel forward to spin
Wait(SPIN_TIME); // spin constant time
OnFwd(RIGHT, 75); // right wheel forward to go straight
}
}
Can you explain its motion based upon the program? What is the effect of changing the values
of REV_TIME and SPIN_TIME. Why is it advantageous to use #define to declare these constants?_______
Based upon the program the bot starts by moving forward at 75 percent of its maximum speed
until it hits something. Once the bot hits an object, it reverses for 0.5 seconds, then spins for 0.5 seconds,
and finally moves forward again.
Changing the value of REV_TIME and SPIN_TIME affects the motion of the bot. When we increase
these values, the reverse distance is longer and the bot makes more spins. When the values decrease, the
reverse distance is shorter and it makes less spins.
It is advantageous to use #define because it enables us to declare a constant in one place and
then use it throughout the program. It makes the program more maintainable.
Describe in words how the control strategy is designed to work.________________________________
The control strategy for bump bot one is to reverse and spin, with a constant, when the bot hits
an object. When the bump bot hits into an object, the robot will reverse for a half a second, then it will
turn right for half a second out of the path of the object that it just ran into. After reversing and turning,
the right wheel will duplicate the left wheel in going forward. The robot will go forward once again until
it runs into about object. Once it runs into another object, it will repeat the previous steps to get out of
the way of the new object. In the control strategy, the spin time and turn time are constant throughout
the code. This means that there is a set time that it will reverse and spin. This is good if you want to know
where the bump bot is going. However, give the bump bot enough time, it will eventually hit the same
object more than once. It is not trying to navigate away from the obstacles.
Bump Bot 2___________________________________________________________________________
// bumpbot2.nxc - different sensor design
// sensors
#define BUMP SENSOR_1 // sensor
#define LEFT OUT_A // left motor
#define RIGHT OUT_C // right motor
#define REV_TIME 500 // constant reverse time
#define SPIN_MIN 200 // constant spin time minimum
#define SPIN_RANDOM 700 // constant spin time between 0 and 700
task main() // main task of the bump bot
{
repeat(4) // repeat following code four times
{
SetSensorTouch(IN_1); // sensor in input 1
OnFwd(LEFT, 75); // left wheel goes forward
OnFwd(RIGHT, 75); // right wheel goes forward
{
until(BUMP==1); // wait for sensor to bump something
OnRev(LEFT, 75); // left wheel reverse
OnRev(RIGHT, 75); // right wheel reverse
Wait(REV_TIME); // amount of reverse time
OnFwd(LEFT, 75); // Left wheel rotate forward to spin
Wait(SPIN_MIN + Random(SPIN_RANDOM));// randomly spin between 200 and 700
}
Off(OUT_AC); // Off
}
}
Describe in words how the control strategy is designed to work._________________________________
The control strategy for bump bot 2 is slightly different from the control strategy in bump bot one
in that there is a random spin time after it bumps into an object. In this code, the touch sensor is in input
1. The left and right wheel power on and carry the bump bot forward until it runs into an object. When
the bot hits an object, the left and right wheel reverse for half a second. Then, the bot spins right for a
random time between 200 and 700 milliseconds. In this code, we added a repeat function so that the
bump bot would shut off after it ran into 4 objects. After the bump bot would run into four objects, the
motors to the left and right wheel would shut off, preventing any further movement. In hindsight, it would
be more beneficial for this code to use a greater repeat count seeing how the random spin time helps the
bot navigate.
Why is the logical control strategy for bot 2 better?___________________________________________
The control strategy for bot 2 is better because the random spin time helps the bot navigate the
terrain better than the control strategy in bot 1. In bot 1, both reverse time and spin time are constant,
giving the bump bot no navigational skills. The bump bot 1 will bump into the same objects constantly,
and in the same order. In bot 2, the opposite is true. The bump bot 2 does not have a set path, giving it a
certain amount of navigational skill. It will not have a set order of objects it bumps into. If it were hunting,
the control strategy in bot 2 would be best because then it has a better chance of searching for objects.
Yannick and Derek were responsible for building and coding the bumpbot on Derek’s laptop.
(Krystal was absent for this assignment and missed building and coding bot 1.) Bot 2 was designed on
Derek’s laptop, with the help of both Yannick and Krystal. Yannick wrote a summary rough draft
answering the questions, Derek added in the code, and Krystal edited the draft.
Download