Lab 3: Ded Reckoning

 

Lead TAs: Samantha Tan (samanthatan@cmu), Rui Cai (rcai@andrew)

Due Date: Tuesday, February 7th, 2012

Part 1: Line Following

Challenge Statement:

Create a mobile robot that when placed at the begining of a dark line on a light plane, follows the line to the end.

Demo:

  1. Place the robot in any desired orientation on the start position marked in the map shown below with the light sensor pointing towards the center of the line.
  2. Start the robot, which should follow the line passing over the first checkpoint, the half-way checkpoint, the second checkpoint and the goal.
  3. Your robot must pass the checkpoints in sequence. If your robot drives off the line and skips a checkpoint, you will not receive points for passing any other checkpoint from there on, even if your robot manages to find the line again.
  4. It is OK to have undefined behavior after passing over the goal. Your robot is not required to stop gracefully at the end, etc.
  5. Three tries will be given in order to improve your score if neeDed. All tries are independent of each other.
  6. You will have 45 seconds to reach the final checkpoint the. After which you be penalized for speed. You will lose 2 points per second over 45 seconds.

Map:


map
Example map with various checkpoints marked.
Your robot should be able to complete all elements in this course.

Line Following Hints

Keywords: Motor Teaming, PID, Light Sensor

Part 2: Ded Reckoning

Challenge Statement:

Given a sequence of three input wheel velocities to be used in five second intervals, determine the final position of a fixed point on the robot and its orientation relative to a fixed axis.

Demo:

  1. Using the robot from the previous demonstration, make sure that when the motor power level for both left and right motors is set to 100 (maximum power), the robot moves forward at at least 0.15 meters per second. For different kinematic designs make sure that the maximum driving speed of the robot is still at least 0.15 meters per second. If neeDed a TA may ask you to demonstrate this requirement.
  2. The TA will specify three input the three sets of input velocities for both left and right wheels of a differential dirve robot. The values will correspond to a motor power level and will be between -75 and 75.
  3. Then, place the robot on the ground and press a button that makes the robot execute the desired sets of motor speeds in five second intervals. For example, if the input set is {{50, 40}, {-30, 40}, {30, 0}}, for the first five seconds, the left and right motor power levels should be 50 and 40 respectively, for the next 5 seconds -30 and 40 and for the last five seconds 30 and 0.
  4. Assume that the robot starts in the initial configuration x = 0, y = 0 and theta = 0.
  5. After 15 seconds, the robot must stop and report its current position and orientation in meters and degrees respectively in [x,y,theta] coortinates.
  6. The Error will be measured from the robots current location to the reported location and the angle will be measured from the global [x,y,theta] that the TA will have marked at the origin.
  7. Three tries will be given in order to improve your score if neeDed. Each try is independent of the other. Progressively easier velocities can be requested, each for a 10 point penalty and only once per try. A request cannot be made on the first try.

How to:

The following description applies only to a standard differential drive robot.

  1. Write a loop that continuously polls the wheel encoders to calculate left and right wheel velocities in terms of ticks per second = degrees per second.
  2. Consider the left and right wheel angular velocities in radians per second (v_l,v_r).
    v_l = D1
    v_l = D2

    We can convert them to linear velocities (in m/s) by multiplying by the radius of the wheels (R).

    V_l
    V_r

    From that we can obtain the linear (in m/s) and angular velocity (in rad/sec) for the entire robot.

    nu
    omega

    L (wheel base) : Distance between the point of contact of the two wheels to the ground (in meters)

  3. vec_vel
    To obtain p_vec, we need to solve this non - linear system of differential equations. A numerical integrator like the fourth order Runge - Kutta can be used to approximate the position vector we are looking for. Let t be the time elapsed since we last ran the integration loop (the time step) and n represent the current iteration of the loop.

    runga_kutta diff_drive

    mat_eqn

  4. Now that we have position and orientation information with respect to some fixed global coordinate frame, display it and wait for a specified time interval before starting the entire loop again. This is done to ensure that the wheel rotates at least a few degrees so that the encoder readings that are obtained will be accurate.

Other tips:

  1. The PID update interval should be low (5 - 20 ms).
  2. The integration loop must also be small (1 - 20 ms).
  3. Save this lab. It will be used in the next three labs.
  4. Do not use the in-built radiansToDegrees and degreesToRadians functions. They do not handle floating point inputs correctlly.
  5. The number inputed as power to the motor does not exactlly correspond to wheel velocity. The relation specified in the RobotC manual however is 1 motor power unit = 10 encoder ticks per second = 10 degrees per second.
  6. Do not poll the encoders at extremely small intervals as in such a time step inaccuracies in the encoder ticks (± 1 degree) will cause the velocity estimate to be very inaccurate.
  7. There is only one loop in the method described above where wheel velocities are calculate just before running the integration step. It may be beneficial to have them in seperate threads with different update intervals.
  8. Play with loop update intervals until error over the fifteen seconds is minimized. Factors like encoder and motor error will add up as we are integrating over time and will cause a drift in position.
  9. Having a good position estimate will be crucial in the next few labs so work hard to get this lab working well.
  10. Input can be done through a third SERVO motor where encoder clicks correspond to analog input.
  11. Remember that keeping your robot balanced is key.

Sample starter code: Code fragment written in RobotC.

Hand-in:

  • A copy of the grading sheet completed with your team number and names

Evaluation:

Line Following (100 points) :

  1. Checkpoints
    • Robot reaches checkpoint 1:   25 points
    • Robot reaches checkpoint 2:   25 points
    • Robot reaches checkpoint 3:   25 points
    • Robot reaches checkpoint 4:   25 points
  2. Course Difficulty
    • Easy Course = -20
    • Normal Course = +0
    • Hard Course = +10
  3. Time Penalty: -2 points/second over 45 seconds

Ded Reckoning (100 points):
    Position will be determined by L1 metric:
    Error = |(Actual X) - (Measured X)| + |(Actual Y) - (Measured Y)|

  1. Positioning
    • Robot is within 5 cm of the described position: 70 points
    • Robot is more than 5 cm of the described position: -10 points/cm after the first 5cm
  2. Orientation
    • Robot is within 5 degrees of the described position: 30 points
    • Robot is between 5 and 10 degrees of the described position: -1 points/degree after the first 5 degrees
    • Robot is more than 10 degrees of the described position: -5 points/degree after the first 10 degrees

Lab Demo Sign-Up:


Keywords: Ded Reckoning, Numerical Integration, Fourth Order Runge-Kutta, Equations of motion, C-Space


Last Updated : 1/31/12 by Samantha Tan
(c) 1999-2012: Howie Choset, Carnegie Mellon University