Lab 4: Trajectory Following
Grading
Sheet
Lead TAs: Soohyun Jang (soohyunj@andrew), Melvin Rayappa (mrayappa@andrew), James Wahawisan(jwahawis@andrew)
Due Date: February 14th, 2012
Part 1:
Challenge Statement:
Using
feedback control, make a marker that is attached to your robot follow a
trajectory of the form
cm, drawing a pretty shape. See Sample
Trajectories for examples of shapes. Note that during the demo, the TA will
specify one of the shapes from the sample trajectories file for your robot to
draw. Be prepared to draw any one of them!
How to:
The following description
applies only to a standard differential drive robot.
- Start
by reusing the code from last lab and attaching a marker to the robot some
distance away and to the front or back of the center. Note that the math
below will not work if the marker is exactly in the center of your robot.
You will see why.
- From
here, two things can be done :
|
i) The
position of the center of the robot can be computed just like in the previous
lab and from that, the position of the marker can be found using geometry.
Important equations for this method are :

is the position
of the marker wrt. the center of the robot in Cartesian coordinates
ii) Equations
for the motion of the marker tip can be directly integrated. Important
equations for this method are :

|
- Armed
with the knowledge of where the marker is (from the numerical
integration), where the marker should be (from the given trajectory) and
the relationship between linear velocity of the pen and the linear and
angular velocities of the center of the robot, a control law can be made
that outputs wheel velocities that brings the robot closer to its desired
location.
Let
be the current position of the
marker and
the desired position obtained
from the trajectory. Our desired planar velocity is now proportional
to
-
.
So,
where κ is some
positive real number. From the equations of motion for the marker tip
given above, we can solve for
:

Now wheel velocities (in degrees / second) can be obtained from
using the equations defined in Lab 3 :


- Now
that the desired velocities for the left and right motors are known, we
need a way to ensure that the motors spin at that speed. The only variable
we can control is motor power which is only weakly related to motor
rotational velocity. However, due to the proportional nature of our
controller, if we set the motors to a slightly slower speed than desired,
the disparity between current and desired position will grow larger and a
higher velocity is demanded. So, set the motor velocities to the desired
motor velocities (in degrees / second) * 0.1 and wait for a small time
interval before proceeding to the beginning of the loop again so that the
motors have some time to catch up to the velocity desired of them.
Other tips:
- It
is essential to have a low PID update interval (2 - 10 ms).
- The
integration loop must be small (5 - 20 ms) but no smaller than the PID update
interval so as to let the motor catch up to the desired velocity.
- Save
this lab. It will be used in the next lab.
- Play
around with the proportional constant in order to fine tune the
controller. Increasing the constant causes the marker to catch up to the
trajectory faster. In the worst case this will cause the marker to overshoot
its desired position or request the robot wheels to spin faster than
physically possible. Decreasing the constant causes the marker to catch up
to the trajectory slower. Lagging behind too far may cause the controller
to again, request more power than is physically possible from the motors.
- The
controller described above is going to lag behind the desired trajectory
by some amount. This can be reduced by either fine tuning the constants or
looking ahead in the trajectory.
Demo:
- Place
the robot in a position (for the center of the robot) and orientation on a
plane specified by a TA (in cm and degrees respectively). This is the start of your trajectory.
- Run
one of the trajectories from the sample trajectories file. These can be
preprogrammed as separate programs or as a minor change to your program,
however you will not have a lot of time to select a new trajectory.
- Press
a button on the robot so that it follows the trajectory specified in the
challenge statement where t is the time in seconds after
the button press.
- After
the trajectory is completed, the robot must come to a complete halt. Your
time must also be within 5 seconds of the time listed for each trajectory
in the sample trajectory file.
- Three
tries will be given in order to improve your score if needed. All tries
are independent of each other. Progressively easier trajectories and
initial configurations can be requested, each for a 10 point penalty and
only once per try. A request cannot be made on the first try.
Evaluation:
1.
Error score (out of 50 points) Mean error = distance from start
point to end point of trajectory (aim to get this to zero) :
a.
Mean error <= 5 cm = 50 Points
b.
Mean error > 5 cm = 40 Points
c.
Mean error > 10 cm = 30 Points
d.
Mean error > 15 cm = 20 Points
e.
Mean error > 20 cm ? 10 Points
f.
Mean error > 25 cm ? 0 Points
2.
Time score (out of 10):
a.
Robot stops within +- 5 seconds of listed trajectory time = 10
points
3.
Trajectory quality (subjective and determined by the TA) - out of 35
points
a.
Trajectory is generally free of extra squiggles (overshoot) = 15
points
b.
Trajectory is generally uniform and true to the picture = 20
points
Total: 95 points
Part 2:
For part 2, make your robot
draw your team number and a creative picture on a piece of 8.5x11 inch paper.
You do not have to lift up the pen between the number and the picture; however we
still need to be able to recognize your team number. Team 1 must draw the base
and angled top on the 1. Team 10 and above do not need to add this on their 1s.
Below is an example team 1 picture
that I drew in Paint without lifting up the pen.

Your team does not have to
draw the picture on demo day. You can bring in your picture, and we will trust
that your robot drew it.
Evaluation:
1.
Number is recognizable: 3 points
2.
Picture is creative: 2 points
Bonus:
The class will get pizza if all of the team’s pictures can link
together to form an awesome robot mural.
Lab Demo Sign up:
Last Updated : 2/13/12 by SooHyun Jang
(c) 1999-2012: Howie Choset, Carnegie Mellon University