Python · 1 Hz
Reference Publisher
The demo uses a straight path; utilities also generate circle and slalom points
GAZEBO SIMULATION · SAFE MOTION CONTROL · 2026
基于 CBF-NMPC 的底盘安全运动控制系统
A ROS 2 and Gazebo local-control simulation for a differential-drive robot. The controller jointly optimizes trajectory tracking and softened safety constraints over a receding horizon, then applies the first optimal command online.

These figures are reported in the project presentation. The supplied source does not include reproducible full-system benchmark logs; video and rosbag evidence will be added next.
20 Hz
Configured control-loop rate
< 25 ms
Per-solve figure reported in slides
0
Test collisions reported in slides
100%
Solve success reported in slides
The controller consumes odometry, a reference path, and obstacle states on a nominal 20 Hz loop. It publishes velocity commands together with the predicted path, CBF values, and obstacle forecasts for RViz2 diagnostics.
Python · 1 Hz
The demo uses a straight path; utilities also generate circle and slalom points
Python · 20 Hz
Synchronizes obstacle odometry and broadcasts velocity states
C++ · 20 Hz
Builds the receding-horizon problem and outputs v / ω
Simulation
Executes the simulation and visualizes predicted trajectories

Read robot pose, reference path, and obstacle states
Propagate obstacle positions across the N-step horizon
Formulate with CasADi and solve the NLP using IPOPT
Apply the first control, publish diagnostics, and repeat
A differential-drive unicycle model describes planar motion. Continuous-time dynamics are discretized with RK4 to balance prediction accuracy and numerical stability.
The objective combines state tracking, control effort, control-rate smoothing, terminal error, and CBF slack. Heading error uses 1 − cos(θ − θ_ref) to avoid discontinuities at the angle wraparound.
For each obstacle the safety function above is enforced with a discrete forward-invariance constraint. A heavily weighted nonnegative slack and the tolerance h_k ≥ −0.01 soften instantaneous infeasibility, so this is a softened discrete safety constraint rather than an absolute safety proof.
The previous solution initializes IPOPT while obstacle constraints remain unchanged. The current implementation rebuilds the problem and clears this initial guess when obstacle positions change—a target for further real-time optimization.
Live position and velocity are propagated with a constant-velocity model, and CBF constraints are applied throughout the horizon.
N+1 points are selected from the nearest path index, with lateral error blended out progressively. Reference heading is currently fixed to +X, so circle and slalom tracking still require controller work.
Solver exceptions immediately produce zero linear and angular velocity. Diagnostics retain solve time, status, and CBF values.
Tests cover tiered oncoming obstacles, a narrow corridor, and dense multi-obstacle conflicts. Each scenario below includes a Gazebo demo video of the closed-loop avoidance run.
TEST 01
Dynamic obstacles move head-on in formation, testing prediction-aware avoidance.
TEST 02
Tests moving-obstacle avoidance with limited clearance; corridor walls exist in Gazebo but are not yet represented as CBF constraints.
TEST 03
Obstacles of different radii create simultaneous conflicts and stress continuous solver stability.

Prediction currently assumes constant velocity and observed state. The next step is short-horizon probabilistic prediction using an EKF or learned model.
A fully blocked corridor can make the local NMPC infeasible or trap it in a local minimum. Integration with PRM or Hybrid A* is planned.
Obstacle states currently come from Gazebo ground truth rather than a perception pipeline. Hardware tests must add detection/tracking and calibrate latency, wheel slip, and state-estimation error.
ROS 2 Humble · C++ · CasADi · IPOPT · Gazebo 11 · RViz2 · Python