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

2008TestBonus

8. What command(s) would you SEND using RealTerm to accomplish the task described below? You must use a script as part of your solution. Assume that you have just turned on the Create, set up RealTerm, and connected your robot to the computer with the Create cable.

Task: Turn power LED on and green. Turn play LED on and green. When play is pressed, drive in a circle clockwise at a speed of 325 mm/sec and radius of 400 mm. After exactly one rotation, stop the Create, turn off play LED, turn on power LED to red, and beep. Briefly explain what each part of your code does (use an arrow and a couple of words for each command).

One Possible Solution:
128 131 SEND (start OI, safe mode)
140 1 1 72 16 SEND (program song #1 for one note, 1/4 sec long)
152 24 (all 24 bytes listed below will be sent on same command line, 25 bytes if you use wait angle)
139 2 0 255 (LEDs set)
158 17 (wait for play button)
137 1 69 254 112 (drive v = 325, r = -400)
155 77 (wait time = 77 tenths of secs to complete turn) (or use wait angle = -360 deg, 157 254 152)
137 0 0 0 0 (stop)
139 0 255 255 (LEDs set)
141 1 (beep - play song 1)
SEND
153 SEND (play script)

Bonus #1: Write a program in C to accomplish the task above. Do this at home tonight individually, test it, debug it, and turn in a hard copy of your main.c tomorrow before class. You may not use any numbers in the program itself, but must use constants and variables. Additional bonus is you can use the advance key and beeps to select how many revolutions the Create will perform!!

Bonus #2: Refer to problems 1 - 5 below (answers are in green ). Can you correct the code from problem number 3 to eliminate the errors caused by the problem you discussed in number 4? Write one or more clever lines of C code to generate an accurate number that can be used to drive in a circle for the correct amount of time.

Questions 1 – 4 (and you might want to use this info for the last questions as well). Suppose the Create is driving in a circle clockwise at a speed of v = 325 mm/sec and radius of r = 400 mm.

assume driving forward, so velocity is positive. Since Create is driving clockwise, the radius that needs to be used should be NEGATIVE 400 mm.

1. How long will it take for the Create to drive around the circle exactly one time?

speed = distance/time, therefore time = distance/speed
= (2*pi*r)/v
= (2 * pi *400 mm)/(325 mm/sec)
= 7.733 sec (round to nearest thousandth)
= 7,733 msec (used by cr8_delay(7733); function
= ~ 77 tenths of a sec (used by cr8_stopwatchtime() function and by OI wait time opcode)

2. What are the right and left wheel velocities for the problem above?

A detailed answer for this problem will be posted on Friday along with one possible solution to drive vs. drive direct formula. The short answer is... VL = +431 mm/sec and VR = + 219 mm/sec (assumes 260 mm wheelbase and rounding decimal).

3. Suppose you use C to calculate the time it takes to go around the circle exactly one time (one revolution). You defined and initialize variables as shown above as well as a variable called “timeonerev” (but don’t initialize the variable) and a constant , pi = 3.14. What is the value of timeonerev after each of the lines of code below is executed sequentially?

Use fact that any decimals will be truncated as each decimal occurs using PEMDAS to evaluate the line of code. Assume pi is truncated to 3.
timeonerev = timeonerev; // timeonerev = unknown because it was not initialized properly above.
timeonerev = 2 * pi * r / v; // timeonerev = (2 * 3 * 400) / 325 = 7.384 sec = 7 sec
timeonerev = 2 * pi / v * r; // timeonerev = ((2 * 3) / 325 = 0.019) * 400 = 0 sec
timeonerev = timeonerev + 5; // timeonerev = 0 + 5 = 5

4. Are there any calculation errors in the second and third lines of code above? If so, explain the source(s) of those errors.

yes, truncation due to integer-only math that we are restricted to with the limited version of C we are able to use with the Create.

5. What are the units of time used for the…

a. OI wait time command? tenths of a sec
b. cr8_delay(7733); millisec (thousandths)
c. if stopwatch_time() < 77 (tenths of a sec)
Edit - History - Print - Recent Changes - Search
Page last modified on November 10, 2008, at 10:59 AM