Open Source Robotics

A curated collection of high-quality open source robotics projects, tools, and software to propel the robotics community forward.

Direct Collocation

  • Also called: collocation, direct transcription
  • Category: Planning & manipulation › Trajectory optimisation
  • Tags: trajectory-optimization, optimal-control, nonlinear-programming, motion-planning, dynamics

A trajectory optimization method that treats states and controls at sampled times as variables and enforces the dynamics as constraints between neighbouring samples.

Definition

Direct collocation is a way of turning an optimal control problem, finding the control inputs over time that move a system from start to goal at least cost, into a finite nonlinear program that a standard solver can handle. The trajectory is cut into a number of time points, called knot points. Both the state and the control input at every knot point become decision variables, and the system's dynamics are enforced as equality constraints, called defect constraints, that require neighbouring states to be consistent with an integration rule such as the trapezoidal or Hermite–Simpson rule. Pseudospectral methods are a related family that use higher-order polynomials over the whole trajectory.

This differs from shooting methods, in which only the controls are decision variables and the states are obtained by simulating the dynamics forward. Collocation produces a larger but very sparse problem, solved with sparse nonlinear programming solvers such as IPOPT or SNOPT. Its advantages are that limits on states, such as joint ranges, obstacle clearance or contact conditions, are easy to impose directly; that the solver can start from a guess that is not physically consistent, such as a straight line through the obstacles; and that it tends to behave better than single shooting on long horizons and unstable systems.

A consequence of this structure is that intermediate iterates need not obey the dynamics: the solver is free to violate the defect constraints early on and only satisfies them at convergence. Formulations that move the dynamics or collision constraints into penalty terms make this explicit, letting the solution pass through infeasible regions before the penalty pushes it back. That idea has been borrowed in robot learning, for example by first letting a simulated robot pass through obstacles with a penalty and later enforcing hard collisions. Like most trajectory optimization, direct collocation finds local optima, so the result depends on the initial guess.

Why it matters

Direct collocation is one of the main workhorses of trajectory optimization for legged robots, drones and manipulators, because it handles constraints well and starts easily from rough guesses. Understanding it also explains a useful design idea in robot learning: relax the physics first and enforce it gradually.

Key applications

  • Trajectory optimization for jumps, flips and gaits of legged robots
  • Time-optimal and energy-optimal manipulator and drone trajectories
  • Planning search and coverage trajectories for mobile robots
  • Generating reference motions for learned policies and tracking controllers
  • Spacecraft and aircraft trajectory design

In practice

An engineer planning a jump for a legged robot in Drake or CasADi sets up a problem with, say, a fixed number of knot points over the jump, each holding the robot's state and joint torques. The defect constraints tie consecutive knots through the robot's dynamics, extra constraints keep torques within motor limits and the feet on the ground during stance, and the cost penalizes effort and final error. They initialize with a simple interpolation between the start and landing poses, which violates the dynamics, and let IPOPT find a consistent trajectory. If the solver fails, they add knot points, scale the variables or improve the initial guess. The resulting trajectory is then tracked by a feedback controller or used as a reference for a learned policy.

Common misconceptions

  • Every iterate of the solver is a physically valid trajectory — the dynamics are only satisfied at convergence; intermediate solutions can violate them
  • Direct collocation finds the globally best trajectory — it solves a nonconvex problem locally, so different initial guesses can give different answers
  • Collocation and shooting solve different problems — they are two transcriptions of the same optimal control problem, with different numerical behaviour

Who should know this

  • Trajectory optimization and motion planning engineers
  • Legged robot and drone control developers
  • Robot learning researchers who use optimized reference motions
  • Robotics students studying optimal control

Related technologies

  • Drake
  • CasADi
  • IPOPT
  • SNOPT
  • Multiple Shooting
  • Pseudospectral Methods

Related terms

  • Trajectory Planning
  • Model Predictive Control
  • Differential Flatness
  • Motion Planning
  • Curriculum Learning
  • Ergodic Coverage

Related projects

  • Drake: MIT robotics toolbox for model-based dynamics, optimization, and control system design
  • OMPL: Sampling-based motion planning library powering MoveIt and countless robotics applications
  • MoveIt 2: Motion planning framework for ROS 2 robot arms, with kinematics and collision checking
  • PyRoki: Modular Python toolkit for kinematic optimization across CPU, GPU, and TPU via JAX
  • mink: Python inverse kinematics library built on MuJoCo supporting 20+ robot platforms
  • Ruckig: Real-time jerk-constrained time-optimal trajectory generation for robots and machines

This website requires JavaScript to function properly. Please enable JavaScript to explore our collection of open source robotics projects.