CSSE 120 -- Intro. to Software Development

Homework 15

  1. Complete the assigned reading for the next session: Zelle Chapter 11.1 – 11.3, 11.6
  2. (28 pts) Complete the Angel quiz over the reading assignment. You'll find the quiz on the course Angel page, under Lessons → Homework → Homework 15 → Data Collections
  3. Complete the 3-minute project team preference survey if you haven't done so on ANGEL under Lessons.
  4. Check out the Session15Robotics project from your team repository.
  5. (10 pts) Complete the implementations of moveAndSenseViaDistance.py. This will ensure you understand how to read sensor data and respond to it while the robot moves.
  6. (50 pts) LineFollower.
    1. 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.
    2. 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.
    3. Requirements:
      1. 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!
      2. 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.
      3. 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. Dr Fisher got his to about 15 seconds per lap.
    4. Helpful Recommendations (not requirements):
      1. 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.
      2. 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.
      3. You may use pycreate's driveDirect(leftVelocity, rightVelocity) or drive(radius) functions as alternatives to go(linear velocity, angular velocity).  
      4. 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.
      5. 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.
    5. Commit your work.
  7. (40 pts) SmartWander.
    1. 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:
      1. 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 waitAngle() or waitDistance(), 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 or come up with a good solution by regularly reading the distance information.

      2. 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).

      3. 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.

      4. 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.
    2. Commit your work.