CSSE 120 -- Intro. to Software Development
Homework 12
-
There is no new reading or Angel quiz for the next session.
However, Session 13's reading and quiz, due Wednesday, are
fairly long and involved (and worth more points than usual), so
you may want to begin them over the weekend.
- Check out the RobotBehaviors project from your
team repository. You'll need to connect to a new team
repository, named csse120-200920-behaviorsXY,
where X is your section number (3=Boutell,4=Fisher) and Y is
your team number.
- (10 pts) Complete the implementation of moveAndSense.py.
This will ensure you understand how to read sensor data and respond to it while the robot moves. Commit
it.
- (50 pts) LineFollower.
- Using your cliff sensor code from prior homework as a
starting point, complete the implementation of lineFollower.py.
This program will drive
the iRobot Create around the provided black line tracks.
- Your program should continue to perform many of the same
tasks as the cliffSensor.py code. For example it
should light the LEDs based on the black line location and
it should still shutdown the iRobot when a bumper is
detected. Now, however, it should also send commands
to the wheels, as appropriate, to move around the black line
track.
- Requirements:
- To challenge you a bit, we've added a speed
requirement! The speed requirement for this
project is to complete 2 laps in under 1 minute. Start by going slow, but before you get checked off you
need to make sure that within 1 minute you can complete
2 laps!
- Demonstrate your program to the instructor or lab
TA. Make sure they know to fill out your grade on
Angel when they see your robot complete the task.
- We welcome the need for speed! After you
finish the project you are welcome to continue tweaking
your code to see how fast you can go. I got mine
to about 15 seconds per lap so far. :)
- Helpful Recommendations (not requirements):
- In addition to the front left and front right cliff
sensors, we recommend you also use the (extreme) left and right
cliff sensors. For example, when you see the black
line under the far left cliff sensor you may want to
make a rather extreme left turn.
- Debugging LEDs are a good thing. When the
black line was under the extreme left cliff sensor I
made the power LED go green, and when the black line was
under the extreme right cliff sensor I made the power LED go
red. Getting some feedback can be a good thing.
- You may find pycreate's driveDirect(leftVelocity,
rightVelocity) or drive(radius) functions
to be more useful than go(linear velocity,
angular velocity). They are in the pdf, but not your
handout.
- The turns on this track have a radius of curvature
of about 15". You might consider using that fact
to your advantage. Using the drive() command and
knowing the radius of curvature of the track might help
you boost your speed.
- Test early. Test often. As soon as you've
written enough code to test,... test it. For
example, I added the left and right cliff sensors first,
and then tested that before doing anything with the
wheels. When I had those working, I made a few
debugging print statements to show analog values and my
driving plan. Then when I started driving the
wheels, I started with really slow speeds. After
one step works, move on to the next level of complexity.
- Commit your work.
- (40 pts) SmartWander.
- Complete the implementation of smartWander.py.
Your new smartWander() function should
cause the robot to wander around randomly (turn then move,
repeated 5 times), as it did for wander() in an earlier
robot homework, but also move away from any obstacles into which
it bumps. Specifically:
- You will move for random angles between -180 and 180
degrees, and
distances between 10 and 30 cm. Reminder: be
sure that the sign on your velocities and distances are
the same. Also, do NOT use wait_Angle() or wait_Distance()
(or turnTo() or moveTo() which use them), since they
monopolize the serial port, which you need for sensor
data. Therefore, you will have to use go() and stop()
and calculate how long to sleep manually.
- If the robot runs straight into an obstacle (left and
right bumpers sensed), then back up. Choose a sensible
distance to back up: enough to get away from the obstacle,
but not enough to back up into another obstacle. You may
then go on to the next random turn and move (in other words,
you don't have to try to complete the move that was
blocked).
- If the robot runs into an obstacle at an angle such that
only the left bumper senses it, then backup and turn
clockwise (for your sensible choice of an angle). Then
execute the next random turn and move.
- If the robot runs into an obstacle at an angle such that
only the right bumper senses it, then backup and turn
counter-clockwise (for your sensible choice of an angle).
Then execute the next random turn and move.
- Commit your work.