trajOpt#

Top-level trajectory optimization interface combining warm-start and iLQR.

namespace saltro
namespace optimizer

Functions

bool trajOpt(const PlannerSettings &settings, const Satellite &satellite, const Satellite::VecX &x0, const Eigen::Vector3d &r0, const Eigen::Vector3d &v0, const Eigen::Ref<const Eigen::VectorXd> &jtime, const Eigen::Ref<const Eigen::MatrixXd> &q_goal, const Eigen::Ref<const Eigen::MatrixXd> &boresight, Eigen::Ref<Eigen::MatrixXd> X, Eigen::Ref<Eigen::MatrixXd> U, Eigen::Ref<Eigen::MatrixXd> K, int state_dim, int input_dim, int &N)#

Solve satellite attitude trajectory optimization problem.

High-level interface that orchestrates the complete trajectory optimization process:

  1. Warm-start: Generate initial trajectory using reference controller or open-loop propagation

  2. iLQR: Iteratively refine trajectory using differential dynamic programming

The optimization minimizes a cost function that typically includes:

  • Attitude tracking error (quaternion distance to q_goal)

  • Angular velocity regulation

  • Control effort (torques, momentum management)

  • Constraint violations (augmented Lagrangian penalties for path constraints)

The problem is formulated as:

\[ \min_{\mathbf{u}_0, \ldots, \mathbf{u}_{N-1}} \, \ell_N(\mathbf{x}_N) + \sum_{k=0}^{N-1} \ell_k(\mathbf{x}_k, \mathbf{u}_k) \]
subject to:
\[ \mathbf{x}_{k+1} = \mathbf{f}(\mathbf{x}_k, \mathbf{u}_k, t_k), \quad k = 0, \ldots, N-1 \]
where \(\mathbf{x} = [\boldsymbol{\omega}, \mathbf{q}, \mathbf{h}_{\text{rw}}]\) is the attitude state and \(\mathbf{u}\) contains actuator commands (MTQ dipoles, RW torques).

Parameters:
  • settings – Planner configuration containing cost weights, constraints, AL parameters, iLQR settings, number of passes, and timestep

  • satelliteSatellite model with inertia, actuators, and dynamics/cost functions

  • x0 – Initial attitude state (7+nRW × 1): [ω(3), q(4), h_rw(nRW)]

  • r0 – Initial position in ECI frame (3 × 1), meters

  • v0 – Initial velocity in ECI frame (3 × 1), m/s

  • jtime – Mission time vector in Julian centuries (N × 1)

  • q_goal – Goal quaternion trajectory (4 × N) defining desired attitude over time

  • boresight – Boresight constraint trajectory (3 × N), unit vectors in body frame

  • X – Output: optimized state trajectory (N × state_dim)

  • U – Output: optimized control trajectory (N-1 × input_dim)

  • K – Output: final feedback gain trajectory (N-1 × input_dim × reduced_state_dim)

  • state_dim – State dimension (7 + nRW)

  • input_dim – Control dimension (3*nMTQ + nRW + 3 for magic torque)

  • N – Output: horizon length (updated if trajectory is extended/truncated)

Returns:

true if optimization succeeded (converged or reached max iterations), false if validation failed or numerical error occurred