Motion Planning and Control For FRC
Motion Planning and Control For FRC
Control in FRC
Jared Russell
Tom Bottiglieri
Austin Schuh
Why are we here?
254 Goal
10 Feet
Distance = 10 feet
Full Speed = 5 ft/sec
Dead reckoning
Bang-bang 254 Goal
10 Feet
while (true) {
error = goal_distance - current_distance
if (error > 0) {
Drive(1.0);
} else if (error < 0) {
Drive(-1.0);
} else {
Drive(0.0);
}
}
Dead reckoning
Bang-bang 254 Goal
PID 10 Feet
PID 10 Feet
Motion profiles
Smoothly Cruise at Smoothly
accelerate full speed decelerate
A well-planned
profile makes
precise control
easier!
Some quick definitions...
t = 0.1 s, t = 0 s,
index 0 v = 0.5 m/s v = 0 m/s
index 1
index 2 t = 0.15 s,
v = 0.25 m/s
index 3 t = 0.22 s
Path Trajectory v = 0.28 m/s
t=
254 .1 s
Goal
Feedback
at time t = .1 s, I should be
there, but I am actually here, so
I should go (faster/slower)
Some quick definitions...
“My left wheel went forward 2 inches, “I want to turn clockwise 90 degrees”
my right wheel went forward 4 → Left wheel must go forward for X
inches” → I went forward while inches, Right wheel must go backward
turning counter-clockwise for X inches
The Motion Control Process
Inputs:
Start (x, y) at s = 0 4 unknowns, 4 equations
End (x, y) at s = 1
Solve!
Equations:
x(s) = Ax s3 + Bx s2 + Cx s + Dx
y(s) = Ay s3 + By s2 + Cy s + Dy
acceleration =
0
slope = slope =
acceleration = acceleration =
max_accel -max_accel
acceleration =
0
slope = slope =
acceleration = acceleration =
max_accel -max_accel
acceleration =
0
slope = slope =
acceleration = acceleration =
max_accel -max_accel
● Next:
○ figure out how much distance you will cover to
accelerate from v_start to v_cruise (hint: xf = xi + v t
+ ½ a t 2)
○ ...and the same to decelerate from v_cruise to v_end
v = v_cruise
slope =
Velocity
acceleration =
0
slope = slope =
acceleration = acceleration =
max_accel -max_accel
● Finally:
○ How long are you at cruise velocity?
○ Total distance = distance during accel + distance
during decel + distance during cruise
○ Notice that cruise distance is zero in the case of a
The Result
angular
velocity
translational
velocity
Path
Curvature
Maximum
Velocity
Velocity
Distance along
path
Distance along
path
Distance along
path
t=
254 .1 s
Goal
setpoint = LookUpSetpoint(t)
error = setpoint.pos - actual_position
2D navigation case
t=
.1 s
254
Along-track, cross-track, and heading
components to error
Feedforward
● Basic Idea
○ If you have information about your system, tell
your controller!
○ Trajectories encode all the information necessary
to tell a “perfect” robot to follow them exactly
○ The feedback part will take care of deviations from
perfection
Trajectory Following
2. Feedforward control
t=
254 .1 s
Goal
setpoint = LookUpSetpoint(t)
SetMotorSpeed(Kv * setpoint.vel)
setpoint = LookUpSetpoint(t)
SetMotorSpeed(Kv * setpoint.vel +
Ka * setpoint.acc)
3. Feedback control
NOTE: The slides as
presented contained
t= an error here; there
254 .1 s
Goal is no need to
subtract setpoint
velocity in this
setpoint = LookUpSetpoint(t) formulation, since
error = setpoint.pos - actual_position error_last is relative
to the old position
error_deriv = (error - error_last) / dt setpoint.
SetMotorSpeed(Kv * setpoint.vel +
Ka * setpoint.acc + These slides are now
correct.
Kp * error +
Kd * error_deriv)
error_last = error
Look up
Compute Compute Compute
desired state Drive
Left/Right Left/Right Gyro
of motion at Motors
Feedforward Feedback Adjustment
time t
Coordinated Motion