Expand description
3D drone trajectory following with quadrotor dynamics.
Implements a quadrotor dynamics model and a PD trajectory tracking controller that follows quintic polynomial trajectories through 3D waypoints.
Based on PythonRobotics AerialNavigation/drone_3d_trajectory_following.
§Overview
-
Quintic trajectory generation: Given start/end positions (with velocity and acceleration boundary conditions), solve for 6 polynomial coefficients per axis so that position, velocity, and acceleration are continuous at segment boundaries.
-
PD controller: Computes thrust and torques from the tracking error between desired and actual states.
-
Quadrotor dynamics: Euler-integrated rigid body with roll/pitch/yaw, driven by thrust and body torques.
Structs§
- Control
Output - Control outputs: total thrust and body torques.
- Controller
Gains - PD controller gains.
- Desired
State - Desired trajectory values at a single time instant.
- Quadrotor
Params - Physical parameters of the quadrotor.
- Quadrotor
State - Full state of the quadrotor.
- Quintic
Coeffs - Coefficients of a quintic polynomial for one axis:
c0*t^5 + c1*t^4 + ... + c5. - Simulation
Config - Configuration for the trajectory-following simulation.
- Simulation
Record - Record of the quadrotor state at each simulation step.
- Trajectory
Segment - A 3D quintic trajectory segment (one per axis).
Functions§
- compute_
control - Compute the PD control output for the quadrotor.
- generate_
trajectory_ segment - Generate a quintic trajectory segment between two 3D waypoints.
- generate_
trajectory_ segment_ full - Generate a quintic trajectory segment with full boundary conditions.
- generate_
waypoint_ trajectory - Generate trajectory segments for a closed loop through the given waypoints.
- generate_
waypoint_ trajectory_ with_ durations - Generate trajectory segments for a closed loop through the given waypoints with an explicit duration for each segment.
- rotation_
matrix - Compute the ZYX rotation matrix from Euler angles (roll, pitch, yaw).
- sample_
trajectory_ segments - Sample a piecewise quintic trajectory into desired states at a fixed
dt. - simulate_
desired_ states - Simulate a pre-sampled desired trajectory.
- simulate_
trajectory_ following - Run the full trajectory-following simulation.
- step_
dynamics - Advance the quadrotor state by one time step using Euler integration.