Problem
Definition
TrajectoryOptimization.Problem — TypeProblem{T}Trajectory Optimization Problem. Contains the full definition of a trajectory optimization problem, including:
- dynamics model (
RD.DiscreteDynamics) - objective (
Objective) - constraints (
ConstraintList) - 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)
Problem(model, obj, x0, tf; [xf, constraints, N, X0, U0, dt, integration])where Z is a [RobotDynamics.SampledTrajectory].
Arguments
model: ADiscreteDynamicsmodel. If aContinuousDynamicsmodel is provided, it will be converted to aDiscretizedDynamicsmodel via the integrator specified by theintegrationkeyword argument.obj: 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 statexf: Final state. Defaults to zeros.dt: Time step. Can be either a vector of lengthN-1or a positive real number.tf: Final time. Set to zero.N: Number of knot points. Uses the length of the objective.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{<:AbstractVector}.
Methods
Getters
TrajectoryOptimization.cost — Methodcost(::Problem)Compute the cost for the current trajectory
RobotDynamics.states — Methodstates(::Problem, args...)Get the state trajectory.
RobotDynamics.controls — Methodcontrols(::Problem, args...)Get the control trajectory
TrajectoryOptimization.horizonlength — Functionhorizonlength(prob::Problem)Number of knot points in the time horizon, i.e. the length of the sampled state and control trajectories.
TrajectoryOptimization.get_objective — FunctionGet the objective. Returns an AbstractObjective.
TrajectoryOptimization.get_constraints — FunctionGet problem constraints. Returns ConstraintList.
TrajectoryOptimization.get_model — Functionget_model(prob::Problem)Get the dynamics models used at each time step. Returns Vector{RobotDynamics.DiscreteDynamics}.
get_model(prob::Problem, k::Integer)Get the dynamics model at time step k.
TrajectoryOptimization.get_trajectory — FunctionGet the trajectory. Returns an RobotDynamics.SampledTrajectory
TrajectoryOptimization.get_initial_time — Functionget_initial_time(problem)Get the initial time of the trajectory.
TrajectoryOptimization.get_final_time — Functionget_final_time(problem)Get the final time of the trajectory.
TrajectoryOptimization.get_initial_state — FunctionGet the in initial state. Returns an AbstractVector.
TrajectoryOptimization.get_final_state — FunctionGet the in initial state. Returns an AbstractVector.
TrajectoryOptimization.is_constrained — FunctionDetermines if the problem is constrained.
RobotDynamics.gettimes — Functiongettimes(Z)Get a vector of times for the entire trajectory.
gettimes(::Problem)Get the times for all the knot points in the problem.
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)Copies the trajectory data from Z to the problem.
TrajectoryOptimization.set_initial_state! — Functionset_initial_state!(prob::Problem, x0::AbstractVector)Set the initial state in prob to x0
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.
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.