Repository navigation
Description
Proposal
Add longitudinal speed control with PID and a feedforward term, and a simulation where it matters: the commanded acceleration reaches the vehicle through a first-order lag and against a driving resistance (a road slope), so the current proportional control can't hold the target speed.
a_cmd = a_ff + K_p e_v + K_i ∫ e_v dt + K_d de_v/dt, e_v = v_ref - v
a_ff = dv_ref/dt + g sin(slope) (feedforward)
plant: da_act/dt = (a_cmd - a_act) / tau, dv/dt = a_act - g sin(slope)
Why
Every controller of Chapter 4 controls the speed with a = K_v (v_ref - v) (for example PurePursuitController._calculate_target_acceleration_mps2(), SPEED_PROPORTIONAL_GAIN = 1.0). In the kinematic model the commanded acceleration is applied exactly (State.update(accel_mps2, yaw_rate_rps, time_s)), so a P control has no steady-state error and PID would show nothing. With a lag and a slope, P leaves an error on the slope, I removes it, and the feedforward removes most of it before any error builds up. This is the longitudinal control taught with Pure Pursuit and Stanley in introductory courses. #376 is PID for the steering; this issue is the speed.
Expected change
src/components/control/speed_pid/speed_pid_controller.py: aSpeedPidController(kp, ki, kd, use_feedforward)withupdate(target_speed_mps, target_accel_mps2, speed_mps, slope_rad, time_s) -> float(the commanded acceleration). The derivative is the difference of the error between two calls divided bytime_s; the integral is the sum ofe_v * time_s- The plant stays in the simulation, not in
State: the first-order lag (tau_s, for example 0.5 s) and the slope resistance are a small class in the simulation script that turnsa_cmdinto the acceleration passed to the vehicle. The vehicle model and the command interface will change in Phase 1: Command(accel, steer) and a swappable vehicle model #108; putting the plant intoStatenow would collide with it. Write this in the docstrings src/simulations/path_tracking/speed_pid_control/speed_pid_control.py: a straight course with a target speed that steps up and down, and a slope on part of it (only as a resistance; the drawing stays flat). Four vehicles or four runs: P (the current gain), PI, PID, PID with feedforward. Plot speed and the speed error against time in a separate figure after the run (GlobalXYVisualizerhas one plot area; don't change it)test/test_speed_pid_control.py(show_plot = False, thenmain()), andtest/test_speed_pid_controller.pywith a unit test that on a constant slope the PI controller's error goes to zero while P keeps an error of aboutg sin(slope) / K_p- The simulation in the Sections list of
doc/path_tracking/index.md, next to the speed profile of Speed profile from the course's curvature, compared with a constant target speed #380 (the maintainer confirms the number) - Run
python generate_pyrightconfig.pyfor the new folders
Comparing P, PI, PID and feedforward
In the PR description, a table of the steady-state error on the slope and the overshoot after the speed step for the four controllers, and one or two sentences on what changes when tau_s is doubled.
Out of scope
- Engine, gear and brake models; anti-windup, unless the integral clearly winds up at the speed limits of
State(then say why in the PR) - Changing
State,FourWheelsVehicleor the existing controllers
References
- K. J. Åström, R. M. Murray, Feedback Systems: An Introduction for Scientists and Engineers, Princeton University Press, 2008, Chapter 10 (PID control). https://fbswiki.org
- R. Rajamani, Vehicle Dynamics and Control, 2nd ed., Springer, 2012 (chapters on longitudinal vehicle dynamics and longitudinal control). https://doi.org/10.1007/978-1-4614-1433-9
- Self-Driving Cars Specialization, University of Toronto, Coursera, course 1 (vehicle longitudinal control). https://www.coursera.org/specializations/self-driving-cars
How to contribute
Comment /claim on this issue to be assigned. Follow Steps 2–4 of HOWTOCONTRIBUTE.md, attach the GIF or plot and the table to the PR, and write Closes #<this issue> in the description.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
leninworld commentedon Dec 5, 2026
/claim
github-actions commentedon Dec 5, 2026
@leninworld This issue is now assigned to you. Thank you!
Closes #429in the description.See Claim an issue before you start.