Trajectory Optimization (TrajOpt)
Published:
Article Goal
Explain TrajOpt (Trajectory Optimization using Sequential Convex Programming)
What is TrajOpt?
TrajOpt is a trajectory optimization algorithm that formulates motion planning as a sequence of convex optimization problems. TrajOpt converts the inherently non-convex trajectory optimization problem into a series of convex subproblems that can be solved efficiently using standard optimization solvers.
The key insight is to linearize non-convex constraints (like collision avoidance) around the current trajectory estimate, solve the resulting convex problem, then iterate. This approach combines the theoretical guarantees of convex optimization with practical handling of complex geometric constraints.
TrajOpt starts with an initial trajectory guess and iteratively refines it by solving convex approximations of the original problem, using trust regions to ensure convergence.
Core Concepts
- Sequential Convex Programming (SCP) - Converting non-convex problems into a sequence of convex subproblems
- Signed Distance Functions - Using distance fields to represent collision constraints in a differentiable way
- Trust Regions - Limiting step sizes to ensure the linear approximations remain valid
- Penalty Methods - Converting hard constraints into soft penalties in the objective function
The Math
Problem Formulation
The trajectory optimization problem is formulated as:
\[\min_{\mathbf{x}} f(\mathbf{x}) + \sum_{i} \lambda_i g_i(\mathbf{x})^2\]Where:
- \(\mathbf{x} = [x_0, x_1, ..., x_T]\) represents the trajectory (sequence of robot configurations)
- \(f(\mathbf{x})\) is the primary objective (e.g., minimize path length, smoothness)
- \(g_i(\mathbf{x})\) are constraint functions (collision avoidance, joint limits, etc.)
- \(\lambda_i\) are penalty weights
Linearization of Constraints
For each constraint \(g_i(\mathbf{x})\), TrajOpt computes the linear approximation around current estimate \(\mathbf{x}^{(k)}\):
\[g_i(\mathbf{x}) \approx g_i(\mathbf{x}^{(k)}) + \nabla g_i(\mathbf{x}^{(k)})^T (\mathbf{x} - \mathbf{x}^{(k)})\]Trust Region Constraint
To ensure the linearization remains valid:
\[||\mathbf{x} - \mathbf{x}^{(k)}||_{\infty} \leq \Delta^{(k)}\]Where \(\Delta^{(k)}\) is the trust region radius at iteration \(k\).
Signed Distance Functions
For collision avoidance, TrajOpt uses signed distance functions:
\[d(\mathbf{x}_t) = \min_{p \in \text{obstacles}} ||\text{robot}(\mathbf{x}_t) - p||\]The collision constraint becomes: \(g_{\text{collision}}(\mathbf{x}_t) = \max(0, \epsilon - d(\mathbf{x}_t))\)
Where \(\epsilon\) is the minimum safe distance.
Sequential Updates
At each iteration \(k\): \(\mathbf{x}^{(k+1)} = \arg\min_{\mathbf{x}} f(\mathbf{x}) + \sum_i \lambda_i [g_i(\mathbf{x}^{(k)}) + \nabla g_i(\mathbf{x}^{(k)})^T (\mathbf{x} - \mathbf{x}^{(k)})]^2\)
| Subject to: $$ | \mathbf{x} - \mathbf{x}^{(k)} | _{\infty} \leq \Delta^{(k)}$$ |
Algorithm Steps
- Initialize - Start with initial trajectory guess (e.g., straight line interpolation)
- Linearize Constraints - Compute linear approximations of all non-convex constraints around current trajectory
- Formulate Convex Subproblem - Create convex optimization problem with linearized constraints and trust region
- Solve Subproblem - Use convex optimization solver (e.g., OSQP, Gurobi) to find optimal step
- Update Trust Region - Adjust trust region radius based on solution quality
- Check Convergence - Test for convergence criteria or maximum iterations
- Repeat - Continue until convergence achieved
Advantages of TrajOpt
- Fast convergence due to second-order optimization methods
- Handles complex constraints through differentiable approximations
- Deterministic behavior unlike sampling-based methods
- Leverages mature convex solvers with strong theoretical guarantees
- Scales well to high-dimensional robot systems
Limitations
- Requires good initialization - poor initial guess can lead to local minima
- Constraint linearization accuracy - approximations may not capture true constraint geometry
- Trust region tuning - requires careful parameter selection for reliable convergence
- Memory intensive for long horizons due to dense constraint matrices
- Sensitive to penalty weights - requires balancing constraint satisfaction vs objective optimization
