Simple minimum-snap trajectory generator
Project description
Minsnap Trajectories
Simple Python/Numpy implementation of the Minimum Snap Trajectory Generation algorithm.
This package addresses the shortage of turnkey minsnap trajectory generator implementations on PyPI. It implements two of the most time-tested algorithms in this area:
-
Mellinger and Kumar's original Minimum Snap Trajectory Generator [1]
-
Roy and Bry's numerically stable, unconstrained quadratic program [2]
and an important utility in generating quadrotor trajectories:
- Aerodynamic-effects-aware flatness map from flat outputs to quadrotor state and inputs
[1]: D. Mellinger and V. Kumar. Minimum snap trajectory generation and control for quadrotors. In Proc. Int. Conf. on Robotics and Automation, 2011
[2]: C. Richter, A. Bry, and N. Roy. Polynomial trajectory planning for aggressive quadrotor flight in dense indoor environments. In Int. Symposium on Robotics Research, 2013
Get Started
Note that this package is imported as follows
import minsnap_trajectories as ms
TLDR
Four key names
ms.Waypoint
: Time, position, velocity, etc. waypoint. A sequence of this defines the trajectoryms.generate_trajectory
: Generates the piecewise-polynomial trajectoryms.compute_trajectory_derivatives
: Samples the polynomial for position/velocity/acceleration, etc.ms.compute_quadrotor_trajectory
: Directly compute quadrotor state/inputs along the trajectory
Full usage example
Define a sequence of position (and optionally velocity, acceleration, higher-order) references
refs = [
ms.Waypoint(
time=0.0,
position=np.array([0.0, 0.0, 10.0]),
),
ms.Waypoint( # Any higher-order derivatives
time=8.0,
position=np.array([10.0, 0.0, 10.0]),
velocity=np.array([0.0, 5.0, 0.0]),
acceleration=np.array([0.1, 0.0, 0.0]),
),
ms.Waypoint( # Potentially leave intermediate-order derivatives unspecified
time=16.0,
position=np.array([20.0, 0.0, 10.0]),
jerk=np.array([0.1, 0.0, 0.2]),
),
]
Generate a piecewise polynomial trajectory using Roy and Bry's closed form solution, minimizing jerk (order-3) AND snap (order-4) while constraining position, velocity, etc... up to jerk (orders 0 to 3) to be continuous
polys = ms.generate_trajectory(
refs,
degree=8, # Polynomial degree
minimized_orders=(3, 4),
continuous_orders=3,
algorithm="closed-form", # Or "constrained"
)
# Inspect the output
t = polys.time_reference
dt = polys.durations
cfs = polys.coefficients
Sample the polynomial trajectory to get position, velocity, acceleration (or higher-order) trajectories
t = np.linspace(0, 16, 100)
# Sample up to the 3rd order (acceleration) -----v
pva = ms.compute_trajectory_derivatives(polys, t, 3)
position = pva[0, ...]
velocity = pva[1, ...]
Or directly generate a quadrotor UAV trajectory
t = np.linspace(0, 15, 100)
states, inputs = ms.compute_quadrotor_trajectory(
polys,
t,
vehicle_mass=1.0, # Quadrotor weight
yaw="velocity", # Align yaw angle to quadrotor velocity
drag_params=ms.RotorDragParameters(0.1, 0.2, 1.0),
)
Limitations
Tests are not nearly enough!
Existing tests show that this piecewise polynomial planner behaves identically to two of the more approachable MATLAB-based trajectory generator implementations by icsl-Jeon and symao.
-
The polynomial planner is not well-guarded against the case when the polynomial planning problem is overconstrained, i.e.
- The polynomial degree is too low
- Too many orders of derivatives are constrained to be continuous
-
The quadrotor trajectory generator is not extensively tested (the rotor-drag effect compensation function is even more so).
Until more extensive tests are available, use the following parameters in polynomial planning (they are the defaults)
degree
: From 5 to 15minimized_orders
: 5 (Minimum snap)continuous_orders
: 3 (Just keep position/velocity/acceleration continuous)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for minsnap_trajectories-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38fbdd0a0caabca6c3b2a4bcc39c597a8aa1837d6243cb2014a00b8965e8973e |
|
MD5 | 871bb11ce0b6a544e217aa6e6ee02d7f |
|
BLAKE2b-256 | 405d62337a519cb4f2424cb5aca9f958c85751b082a3d22334b299d60ea2d0f6 |
Hashes for minsnap_trajectories-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f02cf8fcb7a94d35b1044b1414e5a4a1d10e1f509644383470f3feb828ad79a |
|
MD5 | 117b0d95b717757c01aa64de9f518c32 |
|
BLAKE2b-256 | 12568927bf95748819aff05ceb70d2740345e817edfee9f3d756d61cd153e04f |