Recent Changes - Search:

TEAMS Academy Wiki

THS

Explore TEAMS!
for visiting sophomores & juniors


Robotics


EnvBioTech

Bat Design

Assistive Tech

Students

Instructors

TEAMS Forum

TEAMS Calendar

TEAMS Web Site

Wiki Info

edit Robots.SideBar

HW 2Pi + 1 - Putting it all together

Your goal for this programming task is to reuse your code from tasks 1, 2, and 3 from the previous homework and merge them into a single program. There are a few minor changes made to the programs ( in red). For class on Nov 13/14, you need to hand in the following pages stapled together BEFORE CLASS BEGINS...

  • a NEAT flowchart (don't cram it onto one page, tape two pages together if needed)
  • main.c printout (in color, if possible)
  • make a copy of your main.c file and rename this copy using the format lastname_combohw_main.txt (e.g. rhine_combohw_main.txt)
 and email that file to Jim Dalphond at james_dalphond@student.uml.edu

What your robot needs to do...

Your new program should do the following for exactly THIRTY SECONDS ...

1. (#1 from last HW) The play LED blinks on and off until the play button is pressed. The Power LED is green.
2. (#3 from last HW) Start the robot driving in a small circle (v = +50 mm/sec, r = 100 mm), make the Play and Advance LEDs blink and the Power LEDs steady green. When play is pressed, the robot accelerates from its current velocity up to 200 mm/sec in reasonable manner about 3 seconds (use a "for" loop). When advance is pressed, the robot decelerates from current velocity down to -200 mm/sec in a reasonable manner about 3 seconds (use a "for" loop). +5 Bonus if you can make the Play and Advance buttons blink on & off without making your response to buttons/bumpers sluggish.
3. ( Optional bonus if you add to your program - +5 points - only do this AFTER you get the rest of the program working!) (#4 from last HW) While the robot is driving in circles (step #2 above), do the following: When the left bumper is pressed, play a short song and turn on left CM led. When the right bumper is pressed, turn on advance LED and right CM LED. When both are pressed, turn on both CM LEDs, but nothing else. Power LED on and green the whole time, and the advance LED should blink on & off.
4. (#2 from last HW) If the robot encounters an unsafe event while execturing 2 & 3 above, beep error and blink the power LED on and off (bright red), Play light off. When the robot RETURNS to a safe state, go back to step 1 to wait for the user to press play again.

At the end of EXACTLY TWO MINUTES, make the robot stop, beep once, and turn the Power LED red (no blinking).

Design Hints...

  • Be careful not to use long delays (> 50 ms) while the robot is driving, because the robot will be "blind" during the delay and may run off a cliff!
  • When you press a button or a bumper, you should see a near-instantaneous response from the robot!
  • Your robot should look for unsafe conditions at all times...one clever way to do this is to include a "safe check" every time you have a conditional test (every if or while or for). For example, rather that check the left bumper as shown below...
    if (cr8->bumper_right == 1) // blah blah blah
you could use this instead...
if (cr8->bumper_right == 1) && ( (cr8->cliff_left == 0) && (cr8->cliff_right == 0) && (cr8->cliff_frontleft == 0)
@@&& (cr8->cliff_frontright == 0) && (cr8->wheeldrop_left == 0) && (cr8->wheeldrop_right == 0)
&& (cr8->wheeldrop_castor == 0))// blah blah blah
and this line of code would do the same thing, taking advantage of the "not" symbol (exclamation point, !) and the fact that these data values are 1 or 0 (true or false), so you can skip the comparison...
if (cr8->bumper_right) && (!cr8->cliff_left && !cr8->cliff_right && !cr8->cliff_frontleft && !cr8->cliff_frontright
&& !cr8->wheeldrop_left && !cr8->wheeldrop_right && !cr8->wheeldrop_castor)// blah blah blah
  • Formatting notes...
    • Look at the sample program I made for driving in circles and carefully follow the indentation that I used
    • Use tabs, not spaces, to indent
    • Put each conditional statement it its own set of parentheses, even if you only have one comparison (see if statements above)
    • Put spaces before and after each arithmetic or local operator (e.g. new=old+10; changes to new = old + 10;)
  • We will compile and test the main.c file that you send to us using the TEMPLATE makefile, create.c, and create.h files. You should never modify those 3 files--if you want to learn how to save your personal code that you expect to reuse over and over again, see Jim (it's easy to create your own header file and use an include statement at the tope of your main.c file).
  • If you are a little bit off with one part or another, you'll receive 70/75 (A), perfect = 75/75 (A+). Plus bonus points, of course!
Edit - History - Print - Recent Changes - Search
Page last modified on November 19, 2008, at 11:34 AM