Feature ExamplesGeneral Examples
Path Trajectory Planning Example
Description
- Package:
trace_path(located in the lower-level controller code repository):/home/lab/kuavo-ros-opensource/src/demo/trace_pathAn example of tracking given fixed trajectories using the MPC controller, including: - Straight line: starting from the robot's current position and heading, generates a trajectory of the specified length
- Square: starting from the robot's current position and heading, generates a trajectory of the specified length counterclockwise
- Circle: starting from the robot's current position and heading, generates a trajectory of the specified radius counterclockwise
- "S" curve: starting from the robot's current position and heading, generates a sinusoidal curve trajectory
Directory Structure
# tree -L 2 -d
.
├── CMakeLists.txt
├── docs # Documentation/images
├── include
│ └── trace_path # Header files
├── launch
│ ├── follow_circle_traj.launch # Launch file for circle trajectory tracking
│ ├── follow_s_curve_traj.launch # Launch file for S-curve trajectory tracking
│ └── follow_sqaure_traj.launch # Launch file for square trajectory tracking
├── package.xml
├── README.md
├── rviz
│ └── trace_path_demo.rviz
└── src
├── circle_path_generator.cpp # Circle path generator
├── common # Common methods
├── line_path_generator.cpp # Straight line path generator
├── mpc_path_tracer.cpp # MPC controller
├── path_tracer.cpp # Path tracer base class
├── pid_path_tracer.cpp
├── s_curve_path_generator.cpp # Square path generator
├── square_path_generator.cpp # S-curve path generator
└── tests # *_main.cc entry pointsParameter Settings
Path Parameters
Common parameters:
- speed: speed, in m/s
- dt: time interval, in s
That is, a point is generated on the path every
speed * dtdistance
Straight Line
- length: length, in m
Square
- side_length: side length, in m
Circle
- radius: radius, in m
S-Curve
- length: half of the total length, in m
- amplitude: amplitude
| Square path | Circle path | S-curve path |
|---|---|---|
![]() | ![]() | ![]() |
Controller
MPC
The solution can be constrained by setting the maximum linear velocity and maximum angular velocity via set_max_linear_velocity and set_max_angular_velocity
Build
Modify the path parameters and controller parameters of the corresponding file in src/demo/trace_path/src/tests/*_main.cc, then build and run:
cd ~/kuavo_ros_opensource
sudo su
catkin build trace_path # BuildLaunch
Terminal 1: Start the robot program
source devel/setup.bash # If using zsh, use source devel/setup.zsh
# Run in the simulation environment
roslaunch humanoid_controllers load_kuavo_mujoco_sim.launch # Start the controller, mpc, wbc, and simulator
# For the real robot, run
roslaunch humanoid_controllers load_kuavo_real.launch # Start the real robot nodesTerminal 2: Generate and track the trajectory
Launch arguments:
rvizvisualize the reference path and the real-time path (optional):rviz:=true
source devel/setup.bash
# Square trajectory tracking
roslaunch trace_path follow_sqaure_traj.launch
# Circle trajectory tracking
roslaunch trace_path follow_circle_traj.launch
# S-curve trajectory tracking
roslaunch trace_path follow_s_curve_traj.launch

