Problem
Definition
TrajectoryOptimization.Problem — Typestruct Problem{Q<:RobotDynamics.QuadratureRule, T<:AbstractFloat}Trajectory Optimization Problem. Contains the full definition of a trajectory optimization problem, including:
- dynamics model (
Model) - objective (
Objective) - constraints (
ConstraintSet) - initial and final states
- Primal variables (state and control trajectories)
- Discretization information: knot points (
N), time step (dt), and total time (tf)
Constructors:
Problem(model, obj, constraints, x0, xf, Z, N, tf) # defaults to RK3 integration
Problem{Q}(model, obj, constraints, x0, xf, Z, N, tf) where Q<:QuadratureRule
Problem(model, obj, xf, tf; x0, constraints, N, X0, U0, dt, integration)
Problem{Q}(prob::Problem) # change integrationwhere Z is a trajectory (Vector of KnotPoints)
Arguments
model: Dynamics model. Can be eitherDiscreteorContinuousobj: ObjectiveX0: Initial state trajectory. If omitted it will be initialized with NaNs, to be later overwritten by the solver.U0: Initial control trajectory. If omitted it will be initialized with zeros.x0: Initial state. Defaults to zeros.xf: Final state. Defaults to zeros.dt: Time steptf: Final time. Set to zero to specify a time penalized problem.N: Number of knot points. Defaults to 51, unless specified bydtandtf.integration: One of the defined integration types to discretize the continuous dynamics model.
Both X0 and U0 can be either a Matrix or a Vector{Vector}, but must be the same. At least 2 of dt, tf, and N need to be specified (or just 1 of dt and tf).
Methods
Getters
TrajectoryOptimization.cost — Methodcost(::Problem)Compute the cost for the current trajectory
RobotDynamics.states — Methodstates(::Problem)Get the state trajectory.
RobotDynamics.controls — Methodcontrols(::Problem)Get the control trajectory
Base.size — Methodsize(prob::Problem) -> Tuple{Any,Any,Int64}
Get number of states, controls, and knot points
TrajectoryOptimization.num_constraints — MethodGet the number of constraint values at each time step
TrajectoryOptimization.get_constraints — FunctionGet problem constraints. Returns AbstractConstraintSet.
TrajectoryOptimization.get_model — FunctionGet the dynamics model. Returns RobotDynamics.AbstractModel.
TrajectoryOptimization.get_trajectory — FunctionGet the trajectory. Returns an RobotDynamics.AbstractTrajectory
TrajectoryOptimization.get_initial_state — FunctionGet the in initial state. Returns an AbstractVector.
RobotDynamics.get_times — Methodget_times(::Problem)Get the times for all the knot points in the problem.
TrajectoryOptimization.integration — Methodintegration(::Problem)
integration(::DynamicsConstraint)Get the integration rule
TrajectoryOptimization.is_constrained — FunctionDetermines if the problem is constrained.
Setters
TrajectoryOptimization.initial_controls! — Methodinitial_controls!(::Problem, U0::Vector{<:AbstractVector})
initial_controls!(::Problem, U0::AbstractMatrx)Copy the control trajectory
TrajectoryOptimization.initial_states! — Methodinitial_states!(::Problem, X0::Vector{<:AbstractVector})
initial_states!(::Problem, X0::AbstractMatrix)Copy the state trajectory
TrajectoryOptimization.initial_trajectory! — Functioninitial_trajectory!(prob::Problem, Z)Copy the trajectory
TrajectoryOptimization.set_initial_state! — Methodset_initial_state!(prob::Problem, x0::AbstractVector)Set the initial state in prob to x0
TrajectoryOptimization.set_initial_time! — Methodset_initial_time!(prob, t0)Set the initial time of the optimization problem, shifting the time of all points in the trajectory. Returns the updated final time.
TrajectoryOptimization.set_goal_state! — Functionset_goal_state!(prob::Problem, xf::AbstractVector; objective=true, constraint=true)Change the goal state. If the appropriate flags are true, it will also modify a GoalConstraint and the objective, assuming it's an LQRObjective.
TrajectoryOptimization.change_integration — Functionchange_integration(prob::Problem, Q<:QuadratureRule)Change dynamics integration for the problem. Returns a new problem.
Other
RobotDynamics.rollout! — Functionrollout!(::Problem)Simulate the dynamics forward from the initial condition x0 using the controls in the trajectory Z. If a problem is passed in, Z = prob.Z, model = prob.model, and x0 = prob.x0.
Base.copy — MethodCopy the problem