here

advertisement
Junkbot
11-13-14
Team 2
Ahmed Baadani, Brett Newell, and Michael Leone
Final/Junkbot
Final Report
1. A statement of the design intent, and any constraints.
2. Your final concept should be described in words, sketches and pictures.
3. A high-level system design document of your software architecture should be included.
4. A fully documented detailed description of your programs should be included.
5. A video of your run in the contest should be linked to your website.
6. Include final thoughts and suggestions for change.
7. Include your journal of design changes.
1. The design intent is to randomly search for 10 pop cans in a
designated area and once cans are detected by the junkbot, to remove
them out of the arena by pushing them out. Must be completed in
under 3 minutes.
2. The design includes 2 actuators for movement on the left and right
wheel. We also used 3 sensors; 2 light sensors to stay within the
black boundary and 1 ultrasonic sensor to detect the cans. The light
sensors are positioned towards the ground to detect any threshold
changes most effectively. The ultrasonic sensor is located in the front
and positioned to be in the middle of the cans.
3.
#define …
int coin=1;
int dir =0;
Task feedback ()
{
…
}
Inline void rebound ()
{
…
}
Inline void clean ()
{
…
}
Inline void detect ()
{
Defining values for
efficiency
Defining variables for
random movement and light
detection
Task for detecting threshold
values
Function for returning back
to white area inside
boundaries randomly
Function to remove the can
once detected and starts
rebound() to return to white
area
Function that stops the robot,
says “I have detected a can”,
…
}
Task drive ()
{
…
}
Task test ()
{
…
}
Task can ()
{
…
}
Task main ()
4.
//final.nxc
#define MOVE OUT_AC
#define PWR 75
#define REYE SENSOR_1
#define LEYE SENSOR_4
#define THRESH 40
int coin=1;
int dir =0;
task feedback()
{
while(true)
{
while(REYE>THRESH && LEYE>THRESH)
{
dir=0;
}
while(REYE<THRESH || LEYE<THRESH)
{
dir=1;
}
}
}
inline void rebound()
{
//PlayTone(440, 250);
OnRev(MOVE, PWR);
Wait(500);
coin=(Random(2));
if(coin==1)
and starts clean () to
remove the detected can
Task that drives the robot in
a random search
Task that starts rebound () to
return bot to white area if
light sensors detect the black
boundary
Task that starts detect () to
remove the can when the
ultrasonic sensor finds one
closer than 15 cm
Task that sets all the sensors
and starts all the tasks
inline void rebound()
{
OnRev(MOVE, PWR);
Wait(500);
coin=(Random(2));
if(coin==1)
{
OnFwd(OUT_A, PWR);
Wait(375+Random(100));
}
else
{
OnFwd(OUT_C, PWR);
Wait(375+Random(100));
}
}
inline void clean()
{
OnFwd(MOVE, PWR);
until(dir==1);
{
rebound();
}
}
inline void detect()
{
Off(MOVE);
PlayFileEx("Voice.rso", 4, FALSE);
Wait(1500);
clean();
}
task drive()
{
while(true)
{
coin=(Random(2));
OnFwd(MOVE, PWR);
Wait(900+Random(1000));
if(coin==1)
OnRev(OUT_A, PWR);
Wait(200+Random(500));
}
else
{
OnRev(OUT_C, PWR);
{
OnRev(OUT_A, PWR);
Wait(200+Random(500));
}
else
{
OnRev(OUT_C, PWR);
Wait(200+Random(500));
}
}
}
task test()
{
while(true)
{
if(dir==1)
{
StopTask(drive);
rebound();
StartTask(drive);
}
}
}
task can()
{
while(true)
{
while(SensorUS(IN_2)>15);
{
StopTask(drive);
detect();
StartTask(drive);
}
}
}
task main()
{
SetSensorUltrasonic(IN_2);
//SetSensorLowspeed(IN_2);
SetSensorLight(IN_1);
SetSensorLight(IN_4);
StartTask(feedback);
StartTask(drive);
StartTask(test);
StartTask(can);
task main()
{
SetSensorUltrasonic(IN_2);
//SetSensorLowspeed(IN_2);
SetSensorLight(IN_1);
SetSensorLight(IN_4);
StartTask(feedback);
StartTask(drive);
StartTask(test);
StartTask(can);
Wait(180000);
StopAllTasks();
}
5. Video link
http://webpages.eng.wayne.edu/~fp2468/
6. A suggestion for junkbot might be to add weight to the inside of the cans so they do not fall
over and roll as easily as they currently do.
7. The following changes were documented after testing the robot with a program and rewriting
the code to run better.
Change 1: Changing the task drive to randomly search instead of specific search.
Change 2: Changing the task drive to just search and creating a new task called test to
decide what to do (i.e. when bot passes boundary, when can is near, etc.)
Change 3: Removed the while(true) from the inline voids detect and clean because it
would loop the function. Created a new task called can to separate the detection of the
can and the detection of the boundaries.
Change 4: Added StopTask(drive) to task can.
Change 5: Added global variable coin to add randomness to inline void rebound. Coin is
randomly flipped and decides whether to turn left or right. Also added coin variable to
task drive to turn randomly left or right in its search.
Download