Skip to content

Commit

Permalink
Renamed TrajOpt to OptimTraj to avoid confusion with the software fro…
Browse files Browse the repository at this point in the history
…m Pieter Abeel
  • Loading branch information
MatthewPeterKelly committed May 23, 2016
1 parent ac9dd7b commit e1039da
Show file tree
Hide file tree
Showing 48 changed files with 119 additions and 98 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TrajOpt - Trajectory Optimization for Matlab
TrajOpt 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.
# OptimTraj - Trajectory Optimization for Matlab
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 TrajOpt solve?
## What sort of problems does OptimTraj solve?

#### Examples:
- [Cart-pole swing-up](https://youtu.be/kAlhKJlu7O8): Find the force profile to apply to the cart to swing-up the pendulum that freely hanges from it.
Expand All @@ -10,9 +10,9 @@ TrajOpt is a matlab library designed for solving continuous-time single-phase tr

#### Details:

TrajOpt 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 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.

TrajOpt solves problems with
OptimTraj solves problems with
- continuous dynamics
- boundary constraints
- path constraints
Expand Down Expand Up @@ -45,10 +45,10 @@ All functions in the problem description can be non-linear, but they must be smo


## Usage:
- Call the function `trajOpt` from inside matlab.
- `trajOpt` takes a single argument: a struct that describes your trajectory optimization problem.
- `trajOpt` 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 trajOpt` at the command line, or check out some of the examples in the `demo/` directory.
- 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.

## Contribute:
This code is still under development, and will be from now until at least May 2016. Please contact me if you have any comments or suggestions, or create a pull request if you would like to add content.
Expand Down
2 changes: 1 addition & 1 deletion chebyshev.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
% Website: http://www.chebfun.org/
% by Lloyd N. Trefethen et al.
%
% For details on the input and output, see the help file for trajOpt.m
% For details on the input and output, see the help file for optimTraj.m
%
% Method specific parameters:
%
Expand Down
2 changes: 1 addition & 1 deletion collectConstraints.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function [c, ceq] = collectConstraints(t,x,u,defects, pathCst, bndCst)
% [c, ceq] = collectConstraints(t,x,u,defects, pathCst, bndCst)
%
% TrajOpt utility function.
% OptimTraj utility function.
%
% Collects the defects, calls user-defined constraints, and then packs
% everything up into a form that is good for fmincon.
Expand Down
2 changes: 1 addition & 1 deletion demo/acrobot/MAIN.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
% Solve! %
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%

soln = trajOpt(problem);
soln = optimTraj(problem);

% Interpolate the solution on a uniform grid for plotting and animation:
tGrid = soln(end).grid.time;
Expand Down
2 changes: 1 addition & 1 deletion demo/cartPole/MAIN.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
% Solve! %
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%

soln = trajOpt(problem);
soln = optimTraj(problem);


%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
Expand Down
2 changes: 1 addition & 1 deletion demo/cartPole/RESULTS_makePlots.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
% Solve! %
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%

soln = trajOpt(problem);
soln = optimTraj(problem);


%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
Expand Down
4 changes: 2 additions & 2 deletions demo/fiveLinkBiped/DEV_rungeKutta_grad.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% DEV_rungeKutta_grad.m
%
% Script for testing and development of the runge-kutta option for TrajOpt
% Script for testing and development of the runge-kutta option for OptimTraj
% with analytic gradients.
%
% WARNING: This script uses adaptive numerical gradients to check the
Expand Down Expand Up @@ -150,7 +150,7 @@
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%

%%%%% THE KEY LINE:
soln = trajOpt(problem);
soln = optimTraj(problem);

% Transcription Grid points:
t = soln(end).grid.time;
Expand Down
2 changes: 1 addition & 1 deletion demo/fiveLinkBiped/MAIN.m
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%

%%%%% THE KEY LINE:
soln = trajOpt(problem);
soln = optimTraj(problem);

% Transcription Grid points:
t = soln(end).grid.time;
Expand Down
2 changes: 1 addition & 1 deletion demo/fiveLinkBiped/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Five-Link Biped - Example problem for TrajOpt
# Five-Link Biped - Example problem for OptimTraj

The model for this problem is for the robot RABBIT, taken from the 2003 paper by Westervelt, Grizzle, and Koditschek: "Hybrid Zero Dynamics of Planar Biped Walkers"

Expand Down
2 changes: 1 addition & 1 deletion demo/fiveLinkBiped/RESULTS.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%

%%%%% THE KEY LINE:
soln = trajOpt(problem);
soln = optimTraj(problem);

% Transcription Grid points:
tGrid = soln(end).grid.time;
Expand Down
2 changes: 1 addition & 1 deletion demo/fiveLinkBiped/costOfTransport/MAIN.m
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%

%%%%% THE KEY LINE:
soln = trajOpt(problem);
soln = optimTraj(problem);

% Transcription Grid points:
t = soln(end).grid.time;
Expand Down
2 changes: 1 addition & 1 deletion demo/fiveLinkBiped/costOfTransport/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Five-Link Biped - Example problem for TrajOpt
# Five-Link Biped - Example problem for OptimTraj

The model for this problem is for the robot RABBIT, taken from the 2003 paper by Westervelt, Grizzle, and Koditschek: "Hybrid Zero Dynamics of Planar Biped Walkers"

Expand Down
8 changes: 4 additions & 4 deletions demo/fiveLinkBiped/costOfTransport/dirColGrad.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function soln = dirColGrad(P, problem)
% soln = dirColGrad(P, problem)
%
% TrajOpt utility function - Direct Collocation with Gradients
% OptimTraj utility function - Direct Collocation with Gradients
%
% This function is core function that is called to run the transcription
% for both the "trapezoid" and the "hermiteSimpson" methods when they are
Expand Down Expand Up @@ -186,7 +186,7 @@

function [dt, dtGrad] = grad_timeStep(t,gradInfo)
%
% TrajOpt utility function
% OptimTraj utility function
%
% Computes the time step and its gradient
%
Expand All @@ -210,7 +210,7 @@
function [c, ceq, cGrad, ceqGrad] = grad_collectConstraints(t,x,u,defects, defectsGrad, pathCst, bndCst, gradInfo)
% [c, ceq, cGrad, ceqGrad] = grad_collectConstraints(t,x,u,defects, defectsGrad, pathCst, bndCst, gradInfo)
%
% TrajOpt utility function.
% OptimTraj utility function.
%
% Collects the defects, calls user-defined constraints, and then packs
% everything up into a form that is good for fmincon. Additionally, it
Expand Down Expand Up @@ -316,7 +316,7 @@
function grad = grad_reshapeContinuous(gradRaw,gradInfo)
% grad = grad_reshapeContinuous(gradRaw,gradInfo)
%
% TrajOpt utility function.
% OptimTraj utility function.
%
% This function converts the raw gradients from the user function into
% gradients with respect to the decision variables.
Expand Down
2 changes: 1 addition & 1 deletion demo/goddardRocket/MAIN.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
% Solve! %
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
soln = trajOpt(P);
soln = optimTraj(P);

t = linspace(soln(end).grid.time(1),soln(end).grid.time(end),250);
x = soln(end).interp.state(t);
Expand Down
4 changes: 2 additions & 2 deletions demo/gradientsTutorial/DEV_rk4_grad.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%
% Demonstrates simple swing-up for a single pendulum with a torque motor.
% This is an easy problem, used for demonstrating how to use analytic
% gradients with trajOpt.
% gradients with optimTraj.
%

clc; clear;
Expand Down Expand Up @@ -58,7 +58,7 @@

% Solve the problem
tic;
soln = trajOpt(problem);
soln = optimTraj(problem);
toc

t = soln(end).grid.time;
Expand Down
4 changes: 2 additions & 2 deletions demo/gradientsTutorial/MAIN.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%
% Demonstrates simple swing-up for a single pendulum with a torque motor.
% This is an easy problem, used for demonstrating how to use analytic
% gradients with trajOpt.
% gradients with optimTraj.
%

clc; clear;
Expand Down Expand Up @@ -48,7 +48,7 @@
problem.options.defaultAccuracy = 'medium';

% Solve the problem
soln = trajOpt(problem);
soln = optimTraj(problem);
t = soln.grid.time;
q = soln.grid.state(1,:);
dq = soln.grid.state(2,:);
Expand Down
2 changes: 1 addition & 1 deletion demo/minimumSnap/chainIntegrator/MAIN.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@


%%%% Solve!
soln = trajOpt(problem);
soln = optimTraj(problem);


%%%% Unpack the solution
Expand Down
2 changes: 1 addition & 1 deletion demo/minimumSnap/minAccel/MAIN.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
end

%%%% Solve
soln = trajOpt(problem);
soln = optimTraj(problem);


%%%% Unpack the solution
Expand Down
2 changes: 1 addition & 1 deletion demo/minimumSnap/minJerk/MAIN.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@


%%%% Solve
soln = trajOpt(problem);
soln = optimTraj(problem);


%%%% Unpack the solution
Expand Down
2 changes: 1 addition & 1 deletion demo/minimumSnap/minSnap/MAIN.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
end

%%%% Solve
soln = trajOpt(problem);
soln = optimTraj(problem);


%%%% Unpack the solution
Expand Down
2 changes: 1 addition & 1 deletion demo/minimumWork/MAIN_cstWork.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
problem.options.defaultAccuracy = 'medium';

% Solve the problem
soln = trajOpt(problem);
soln = optimTraj(problem);
t = soln.grid.time;
q = soln.grid.state(1,:);
dq = soln.grid.state(2,:);
Expand Down
2 changes: 1 addition & 1 deletion demo/minimumWork/MAIN_forceSquared.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
% problem.options.method = 'rungeKutta';

% Solve the problem
soln = trajOpt(problem);
soln = optimTraj(problem);
t = soln.grid.time;
q = soln.grid.state(1,:);
dq = soln.grid.state(2,:);
Expand Down
2 changes: 1 addition & 1 deletion demo/minimumWork/MAIN_smoothWork.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
problem.options.defaultAccuracy = 'medium';

% Solve the problem
soln = trajOpt(problem);
soln = optimTraj(problem);
t = soln.grid.time;
q = soln.grid.state(1,:);
dq = soln.grid.state(2,:);
Expand Down
2 changes: 1 addition & 1 deletion demo/quadRotor2d/MAIN_minAccelTraj.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
% Solve! %
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%

soln = trajOpt(problem);
soln = optimTraj(problem);



Expand Down
2 changes: 1 addition & 1 deletion demo/quadRotor2d/MAIN_minForceTraj.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
% Solve! %
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%

soln = trajOpt(problem);
soln = optimTraj(problem);



Expand Down
2 changes: 1 addition & 1 deletion demo/quadRotor2d/MAIN_minJerkTraj.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
% Solve! %
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%

soln = trajOpt(problem);
soln = optimTraj(problem);



Expand Down
4 changes: 2 additions & 2 deletions demo/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# README.txt -- TrajOpt/demo
# README.txt -- OptimTraj/demo

This directory contains a collection of example problems for trajectory optimization, all solved using TrajOpt. Each example contains a MAIN.m file, which is the entry-point file for the example.
This directory contains a collection of example problems for trajectory optimization, all solved using OptimTraj. Each example contains a MAIN.m file, which is the entry-point file for the example.

If the dynamics or constraints are complicated, then a script Derive_*.m is provided to use the symbolic toolbox to derive these equations. Any files with the autoGen_fileName.m are created by the Matlab symbolic toolbox, and should not be edited. In each case, they will be called by a regular function named fileName.m.

Expand Down
2 changes: 1 addition & 1 deletion demo/simplePendulum/MAIN.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
problem.options.defaultAccuracy = 'medium';

% Solve the problem
soln = trajOpt(problem);
soln = optimTraj(problem);
t = soln.grid.time;
q = soln.grid.state(1,:);
dq = soln.grid.state(2,:);
Expand Down
4 changes: 2 additions & 2 deletions demo/simpleWalker/MAIN.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%MAIN.m -- simple walker trajectory optimization
%
% This script sets up a trajectory optimization problem for a simple model
% of walking, and solves it using TrajOpt. The walking model is a double
% of walking, and solves it using OptimTraj. The walking model is a double
% pendulum, with point feet, no ankle torques, impulsive heel-strike (but
% not push-off), and continuous hip torque. Both legs have inertia. Cost
% function is minimize integral of torque-squared.
Expand Down Expand Up @@ -165,7 +165,7 @@
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%

%%%%% THE KEY LINE:
soln = trajOpt(problem);
soln = optimTraj(problem);

% Transcription Grid points:
t = soln(end).grid.time;
Expand Down
2 changes: 1 addition & 1 deletion demo/toyCar/MAIN.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
% Solve! %
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%

soln = trajOpt(problem);
soln = optimTraj(problem);


%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
Expand Down
6 changes: 3 additions & 3 deletions directCollocation.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function soln = directCollocation(problem)
% soln = directCollocation(problem)
%
% TrajOpt utility function
% OptimTraj utility function
%
% This function is designed to be called by either "trapezoid" or
% "hermiteSimpson". It actually calls FMINCON to solve the trajectory
Expand Down Expand Up @@ -325,7 +325,7 @@
function [c, ceq, cGrad, ceqGrad] = grad_collectConstraints(t,x,u,defects, defectsGrad, pathCst, bndCst, gradInfo)
% [c, ceq, cGrad, ceqGrad] = grad_collectConstraints(t,x,u,defects, defectsGrad, pathCst, bndCst, gradInfo)
%
% TrajOpt utility function.
% OptimTraj utility function.
%
% Collects the defects, calls user-defined constraints, and then packs
% everything up into a form that is good for fmincon. Additionally, it
Expand Down Expand Up @@ -433,7 +433,7 @@
function grad = grad_reshapeContinuous(gradRaw,gradInfo)
% grad = grad_reshapeContinuous(gradRaw,gradInfo)
%
% TrajOpt utility function.
% OptimTraj utility function.
%
% This function converts the raw gradients from the user function into
% gradients with respect to the decision variables.
Expand Down
4 changes: 2 additions & 2 deletions docs/AnalyticGradients/AnalyticGradients.tex
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
\begin{document}
\maketitle

This document describes the method for calculating the analytic gradients for the multiple shooting approach, ``rungeKutta'' of the TrajOpt package. The procedure is exactly the same as that described in Russ Tedrake's Course notes~\cite{tedrakeNotes},(Sec 12.3.3). It may look complicated, but it is essentially just a careful and repeated carrying out of the chain rule. The gradient calculation depends on the specific numerical integration approach of the dynamics and cost function. We consider a couple integration cases below: explicit Euler, and 4$^{\text{th}}$ order Runge-Kutta. The explicit Euler case is only considered as a simple example. The 4$^{\text{th}}$ order Runge-Kutta is the integration scheme used in multiple shooting approach, ``rungeKutta'', of the TrajOpt package.
This document describes the method for calculating the analytic gradients for the multiple shooting approach, ``rungeKutta'' of the OptimTraj package. The procedure is exactly the same as that described in Russ Tedrake's Course notes~\cite{tedrakeNotes},(Sec 12.3.3). It may look complicated, but it is essentially just a careful and repeated carrying out of the chain rule. The gradient calculation depends on the specific numerical integration approach of the dynamics and cost function. We consider a couple integration cases below: explicit Euler, and 4$^{\text{th}}$ order Runge-Kutta. The explicit Euler case is only considered as a simple example. The 4$^{\text{th}}$ order Runge-Kutta is the integration scheme used in multiple shooting approach, ``rungeKutta'', of the OptimTraj package.

\section{Cost function gradients}
Consider the scalar valued cost function,
Expand Down Expand Up @@ -178,7 +178,7 @@ \section{Multiple-Shooting Formulation}
\section{Other Integration Schemes}

\subsection{4$^{\text{th}}$ Order Runge-Kutta Integration}
See the function \texttt{simSysGrad} inside \texttt{rungeKutta.m} of the TrajOpt package for the matlab implementation of the following equations. Consider the path cost
See the function \texttt{simSysGrad} inside \texttt{rungeKutta.m} of the OptimTraj package for the matlab implementation of the following equations. Consider the path cost
\begin{equation}
J^{\bs \alpha} = \int_{t_0}^{t_F} g(t, \bs x(t), \bs u(t)) dt,
\label{eq:PathCost}
Expand Down
Loading

0 comments on commit e1039da

Please sign in to comment.