Skip to content

Caltech-AMBER/traj_opt

Repository files navigation

TrajOpt

A Python-based trajectory optimization framework for hybrid dynamics using CasADi.

Features

  • Trajectory optimization for hybrid systems
  • Support for multiple shooting methods
  • Integration with CasADi for efficient optimization
  • Visualization tools for trajectories

Setup

Set the environment variable:

export AMBER_TRAJ_OPT=/path/to/repo/root

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/TrajOpt.git
cd TrajOpt
  1. Create and activate the conda environment:
conda env create -f environment.yml
conda activate traj_opt

Usage

This library consists of 3 main parts:

  1. Optimizer
  2. Robot
  3. Hybrid System

The optimizer class is responsible for taking the hybrid system and the robot and transcribing them (using multiple shooting) into an NLP. At the core, Casadi and IPOPT are used for this formulation.

The robot class is a thin wrapper around Pinocchio that supplies a few convince functions as well as a nice way to hold all the model and data structs.

The hybrid_system class is where the bulk of the optimization problem is defined. The hybrid system is made up of domains and edges. The domains define operating regions and conditions for the robot and the edges define guard conditions and transitions to the next domain. Within each domain, a number of multiple shooting nodes and can be defined as well as all the costs and constraints. The costs and constraints are specified per-node to allow maximum flexibility.

Costs and Constraints

The constraints are made up of four main types: (a) dynamics, (b) state, (c) input, and (d) auxiliary. For now, we assume that every constraint is is defined on a per-node basis and has no interaction with decision variables for other nodes except for the dynamics. The auxiliary constraints are only on "auxiliary" decision variables, i.e. decision variables that are not states or inputs. For example, this could be the total time within a given domain.

Similarly, the costs are also assumed to be node-wise with no cross-node dependence for now.

Examples

There are examples in the examples/ folder.

Generate a motion

Walking:

python g1_config_example.py --config=configs/single_support_config.yaml

Running:

python g1_config_example.py --config=configs/running_config.yaml

Please verify first that there are no warm starts being used in the config before trying to run the code. If there are warm starts but you haven't run the code yet, it will fail as there is nothing to warmstart with.

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages