Repository contains a differential-drive robot model for Gazebo (ROS 2 Humble) and four simple path-following controllers:
- P waypoint controller
- Pure Pursuit
- Stanley
- MPC (minimal brute-force grid)
Each controller can be launched together with an odometry plotter that saves a 2×2 figure:
- XY trajectory (actual vs expected waypoint polyline + tolerance circles)
- x(t)
- y(t)
- heading ϕ(t)
Plots are saved into ./plots/.
my_robot_description/— URDF/Xacro + meshes + RViz configmy_robot_bringup/— Gazebo launch (my_robot_gazebo.launch.xml), keyboard control, odom listenermy_robot_controllers/— controllers + plotter + launch files- controllers:
p_controller.py,pure_pursuit_controller.py,stanley_controller.py,mpc_controller.py - plotter:
odom_plotter.py - launches:
*_with_plots.launch.py
- controllers:
plots/— saved plot images (example runs)
Moves to the current waypoint using:
- linear speed proportional to distance error (
k_rho * rho) - angular speed proportional to heading error (
k_alpha * alpha) Optionally slows down when heading error is large (to avoid “driving sideways”).
Chooses a lookahead point on the path at distance Ld and computes curvature:
kappa = 2*sin(alpha) / Ldw = v * kappaWorks well for smooth paths; can cut corners if lookahead is too large.
Uses:
- heading error to the path direction
- cross-track error (signed distance to closest point on the path) Steering:
delta = e_psi + atan2(k * e_cte, v + v0)Then mapped to diff-drive angular velocity viaw = (v/L)*tan(delta)(with a clamp ondelta).
Very simple MPC-like selection:
- pick a target waypoint (nearest + a few points ahead)
- brute-force a small grid of constant
(v,w)commands for horizonN - simulate kinematic rollout and choose the lowest cost
git clone [email protected]:Artyom35689/AutMobRob-Assignment1.git
cd AutMobRob-Assignment1docker compose build
docker compose up -ddocker compose exec terminal bashcd ~/ros2_ws
colcon build
. install/setup.bashros2 launch my_robot_controllers p_with_plots.launch.py
ros2 launch my_robot_controllers pure_pursuit_with_plots.launch.py
ros2 launch my_robot_controllers stanley_with_plots.launch.py
ros2 launch my_robot_controllers mpc_with_plots.launch.pyAfter completion the plot will appear in ./plots/ on the host.
git clone [email protected]:Artyom35689/AutMobRob-Assignment1.git
cd AutMobRob-Assignment1
colcon build
. install/setup.bashSame commands as above.
All controllers share:
odom_topic(default/odom)cmd_vel_topic(default/cmd_vel)waypoints_flat(default polyline in code)v_max,w_maxcontrol_rate
Plotter:
plot_name— name used in the figure title and filename prefixoutput_dir— where to save plots (default points to repoplots/)goal_tolerance- stop detection:
stop_lin_eps,stop_ang_eps,settle_time - safety:
max_duration
See ./plots/:
run_p_controller_done_*.pngrun_pure_pursuit_done_*.pngrun_stanley_controller_done_*.pngrun_mpc_controller_done_*.png


