• Stars
    star
    547
  • Rank 78,343 (Top 2 %)
  • Language
    MATLAB
  • License
    MIT License
  • Created over 8 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A trajectory optimization library for Matlab

OptimTraj - Trajectory Optimization for Matlab

DOI

OptimTraj is a matlab library designed for solving continuous-time single-phase trajectory optimization problems. I developed it while working on my PhD at Cornell, studying non-linear controller design for walking robots.

What sort of problems does OptimTraj solve?

Examples:

  • Cart-pole swing-up: Find the force profile to apply to the cart to swing-up the pendulum that freely hanges from it.
  • Compute the gait (joint angles, rates, and torques) for a walking robot that minimizes the energy used while walking.
  • Find a minimum-thrust orbit transfer trajectory for a satellite.

Details:

OptimTraj finds the optimal trajectory for a dynamical system. This trajectory is a sequence of controls (expressed as a function) that moves the dynamical system between two points in state space. The trajectory will minimize some cost function, which is typically an integral along the trajectory. The trajectory will also satisfy a set user-defined constraints.

OptimTraj solves problems with

  • continuous dynamics
  • boundary constraints
  • path constraints
  • integral cost function
  • boundary cost function

All functions in the problem description can be non-linear, but they must be smooth (C2 continuous).

Features:

  • Easy to install - no dependencies outside of Matlab (for base functionality)
  • Lots of examples - look at the demo/ directory to see for yourself!
  • Readable source code - easy to debug your code and figure out how the software works
  • Analytic gradients - most methods support analytic gradients
  • Rapidly switch methods - choose from a variety of methods:
    • direct collocation
      • trapezoid
      • Hermite-Simpson (seperated)
    • direct multiple shooting
      • 4th-order Runge-Kutta
    • global (pseudospectral) collocation
      • Chebyshev (Lobatto) -- (requires chebfun)

Installation:

  1. Clone or download the repository
  2. Add the top level folder to your Matlab path
  3. (Optional) Clone or download chebfun (needed for global collocation)
  4. Done!

Usage:

  • Call the function optimTraj from inside matlab.
  • optimTraj takes a single argument: a struct that describes your trajectory optimization problem.
  • optimTraj returns a struct that describes the solution. It contains a full description of the problem, the transcription method that was used, and the solution (both as a vector of points and a function handle for interpolation).
  • For more details, type help optimTraj at the command line, or check out some of the examples in the demo/ directory.

Documentation:

The best way to learn OptimTraj is by working through a few of the examples in the demo/ directory. There is also a .pdf user guide that can be found in the /docs directory.

For more background on trajectory optimization in general, I wrote a tutorial paper that includes derivations and references for most methods implemented here, along with a variety of practical suggestions and debugging tips. Finally, I have a tutorial webpage for trajectory optimization.

Citing OptimTraj

The best way to cite OptimTraj is using the DOI assigned the the library source code:

DOI

@software{Kelly_OptimTraj_Trajectory_Optimization_2022,
  author = {Kelly, Matthew Peter},
  doi = {10.5281/zenodo.7430524},
  month = {12},
  title = {{OptimTraj: Trajectory Optimization for Matlab}},
  url = {https://github.com/MatthewPeterKelly/OptimTraj},
  version = {1.7},
  year = {2022}
}

Alternatively, you can cite the tutorial paper that accompanies OptimTraj:

@article{kelly2017introduction,
  title={An Introduction to Trajectory Optimization: How to do your own Direct Collocation},
  author={Kelly, Matthew},
  journal={SIAM Review},
  volume={59},
  number={4},
  pages={849--904},
  year={2017},
  publisher={SIAM}
}

Contribute:

Contributions are welcome! Feel free to reach out if you're planning a bigger submission, or just go ahead and make a pull request for smaller contributions.

If you are interested in contributing, here are a few possible things to do:

  • Create additional demo problems
  • Identify holes in the documentation
  • Report bugs
  • Implement new methods or features
  • Look through the open issues

Contributions:

  • Will Wehner implemented analytic gradients in the 4th-order Runge-Kutta method.

  • Conrad McGreal contributed the minimum-time 3D quadrotor example.

More Repositories

1

dscTutorials

A few simple tutorials for dynamical systems and control. Most require Matlab.
MATLAB
97
star
2

ParticleSwarmOptimization

Matlab implementation of particle swarm optimization. Well documented with examples.
MATLAB
72
star
3

ME149_Spring2018

Optimal Control for Robotics -- Tufts University -- ME 149 -- Spring 2018
MATLAB
48
star
4

RungeKuttaCpp

A collection of explicit runge-kutta integrators, written in C++
C++
31
star
5

IntroMatlabDynamics

A basic introduction to Matlab, guided towards simulation and analysis of dynamical systems
MATLAB
28
star
6

Continuous_Finite_LQR

Derivation and implementation of continuous-time finite-horizon Linear Quadratic Regulator
MATLAB
19
star
7

Kinematic_Constrained_Trajectory

MATLAB
17
star
8

Tractor_Trailer_Control

Simulation of a tractor-trailer truck driving backwards along a curving road. Control via time-varying linear quadratic regulator, estimation via extended Kalman filter
MATLAB
16
star
9

Bouncing_Ball_Matlab

Tutorial for event detection in Matlab - simulation of ball bouncing over hilly terrain.
MATLAB
9
star
10

DirCol5i

Trajectory Optimization in Matlab, specialized for problems with higher-derivatives (eg. jerk or snap) and / or implicit dynamics.
MATLAB
7
star
11

Lagrange_Mechanics_Derivations

Tutorial: derive equations of motion for mechanical systems using Lagrange equations
MATLAB
7
star
12

icra2015_kellyRuina

Non-linear robust control for inverted-pendulum 2D walking
MATLAB
7
star
13

Bezier_Curves

A few Matlab functions for creating and evaluating bezier curves.
MATLAB
6
star
14

website

A repository for development of my personal website.
CSS
6
star
15

matthewpeterkelly.github.io

A new place to host my personal website.
CSS
5
star
16

Matlab_Animation_Tutorial

An tutorial the goes over real-time animation in Matlab, as well as saving video files. Some advanced topics are covered as well.
MATLAB
5
star
17

numerical-methods-in-python

This project contains a set of standard numerical methods that I have implemented in python. The source-code for this project is intended to be read as a tutorial.
Python
4
star
18

RangerSimulation

Source code for my two most well-documented simulators for the Cornell Ranger walking robot.
MATLAB
4
star
19

TwoPhaseOptimalGait

Trajectory optimization, using GPOPS-II, for two-phase walking and running gaits, for a simple walking model
MATLAB
4
star
20

Dynamics_Function_Gradient

Computes gradient of f(x) = A(x) \ b(x) in Matlab.
MATLAB
3
star
21

Polynomial_Smoothing_Matlab

Implementation of polynomial smoothing for several basic functions
MATLAB
3
star
22

Acrobot_Derivation_Matlab

Derivation of the equations of motion and simulation for the acrobot, an under-actuated double pendulum robot.
MATLAB
3
star
23

Toppling_Stick

Finite-State-Machine simulation of a toppling stick. Careful Analysis. Matlab.
MATLAB
3
star
24

FluenceMapping

Trajectory optimization to match fluence profiles.
MATLAB
3
star
25

Chebyshev_Polynomials

Tutorial for Chebyshev orthogonal polynomials, written in Matlab. Strongly inspired by the chebfun project.
MATLAB
3
star
26

MDP_Pendulum

Creates a Markov Decision Process model of a pendulum, then finds optimal swing-up policy.
MATLAB
3
star
27

Exponential_Smoothing_Matlab

Exponential smoothing for simple functions: max(), clamp(), abs(), ramp()...
MATLAB
2
star
28

Bulirsch-Stoer

Matlab implementation of the Bulirsch-Stoer method for solving initial value problems.
MATLAB
2
star
29

myJavaPkgs

Java utility packages that I wrote, generally related to simulation.
Java
1
star
30

poker-stats

Small library for computing poker statistics using Monte-Carlo simulation. The primary focus for the project is learning Rust.
Rust
1
star
31

RombergQuadrature

MATLAB
1
star