Drake
Drake C++ Documentation
MultipleShooting Class Referenceabstract

Detailed Description

MultipleShooting is an abstract class for trajectory optimization that creates decision variables for inputs, states, and (optionally) sample times along the trajectory, then provides a number of methods for working with those decision variables.

MultipleShooting classes add decision variables, costs, and constraints to a MathematicalProgram. You can retrieve that program using prog(), and add additional variables, costs, and constraints using the MathematicalProgram interface directly.

Subclasses must implement the abstract methods: DoAddRunningCost() ReconstructInputTrajectory() ReconstructStateTrajectory() using all of the correct interpolation schemes for the specific transcription method, and should add the constraints to impose the System% dynamics in their constructor.

This class assumes that there are a fixed number (N) time steps/samples, and that the trajectory is discretized into time steps h (N-1 of these), state x (N of these), and control input u (N of these).

#include <drake/planning/trajectory_optimization/multiple_shooting.h>

Public Types

typedef std::function< void(const Eigen::Ref< const Eigen::VectorXd > &sample_times, const Eigen::Ref< const Eigen::MatrixXd > &values)> TrajectoryCallback
 
typedef std::function< void(const Eigen::Ref< const Eigen::VectorXd > &sample_times, const Eigen::Ref< const Eigen::MatrixXd > &states, const Eigen::Ref< const Eigen::MatrixXd > &inputs, const std::vector< Eigen::Ref< const Eigen::MatrixXd >> &values)> CompleteTrajectoryCallback
 

Public Member Functions

virtual ~MultipleShooting ()
 
solvers::MathematicalProgramprog ()
 Returns a reference to the MathematicalProgram associated with the trajectory optimization problem. More...
 
const solvers::MathematicalProgramprog () const
 Returns a const reference to the MathematicalProgram associated with the trajectory optimization problem. More...
 
const solvers::VectorDecisionVariable< 1 > time_step (int index) const
 Returns the decision variable associated with the time step, h, at time index index. More...
 
const solvers::VectorDecisionVariable< 1 > & time () const
 Returns a placeholder decision variable (not actually declared as a decision variable in the MathematicalProgram) associated with the time, t. More...
 
const solvers::VectorXDecisionVariablestate () const
 Returns placeholder decision variables (not actually declared as decision variables in the MathematicalProgram) associated with the state, x, but with the time-index undetermined. More...
 
const solvers::VectorXDecisionVariableinput () const
 Returns placeholder decision variables (not actually declared as decision variables in the MathematicalProgram) associated with the input, u, but with the time-index undetermined. More...
 
Eigen::VectorBlock< const solvers::VectorXDecisionVariablestate (int index) const
 Returns the decision variables associated with the state, x, at time index index. More...
 
Eigen::VectorBlock< const solvers::VectorXDecisionVariableinitial_state () const
 Returns the decision variables associated with the state, x, at the initial time index. More...
 
Eigen::VectorBlock< const solvers::VectorXDecisionVariablefinal_state () const
 Returns the decision variables associated with the state, x, at the final time index. More...
 
Eigen::VectorBlock< const solvers::VectorXDecisionVariableinput (int index) const
 Returns the decision variables associated with the input, u, at time index index. More...
 
solvers::VectorXDecisionVariable NewSequentialVariable (int rows, const std::string &name)
 Adds a sequential variable (a variable that has associated decision variables for each time index) to the optimization problem and returns a placeholder variable (not actually declared as a decision variable in the MathematicalProgram). More...
 
solvers::VectorXDecisionVariable GetSequentialVariableAtIndex (const std::string &name, int index) const
 Returns the decision variables associated with the sequential variable name at time index index. More...
 
void AddRunningCost (const symbolic::Expression &g)
 Adds an integrated cost to all time steps, of the form

\[ cost = \int_0^T g(t,x,u) dt, \]

where any instances of time(), state(), and/or input() placeholder variables, as well as placeholder variables returned by calls to NewSequentialVariable(), are substituted with the relevant variables for each time index. More...

 
template<typename Derived >
void AddRunningCost (const Eigen::MatrixBase< Derived > &g)
 Adds support for passing in a (scalar) matrix Expression, which is a common output of most symbolic linear algebra operations. More...
 
template<typename C >
std::vector< solvers::Binding< C > > AddConstraintToAllKnotPoints (std::shared_ptr< C > constraint, const Eigen::Ref< const VectorX< symbolic::Variable >> &vars)
 Adds a constraint to all breakpoints, where any instances in vars of time(), state(), and/or input() placeholder variables, as well as placeholder variables returned by calls to NewSequentialVariable(), are substituted with the relevant variables for each time index. More...
 
std::vector< solvers::Binding< solvers::Constraint > > AddConstraintToAllKnotPoints (const symbolic::Formula &f)
 Adds a constraint to all breakpoints, where any instances of time(), state(), and/or input() placeholder variables, as well as placeholder variables returned by calls to NewSequentialVariable(), are substituted with the relevant variables for each time index. More...
 
std::vector< solvers::Binding< solvers::Constraint > > AddConstraintToAllKnotPoints (const Eigen::Ref< const VectorX< symbolic::Formula >> &f)
 Variant of AddConstraintToAllKnotPoints that accepts a vector of formulas. More...
 
solvers::Binding< solvers::BoundingBoxConstraintAddTimeIntervalBounds (double lower_bound, double upper_bound)
 Adds bounds on all time intervals. More...
 
std::vector< solvers::Binding< solvers::LinearConstraint > > AddEqualTimeIntervalsConstraints ()
 Adds constraints to enforce that all time steps have equal duration. More...
 
solvers::Binding< solvers::LinearConstraintAddDurationBounds (double lower_bound, double upper_bound)
 Adds a constraint on the total duration of the trajectory. More...
 
solvers::Binding< solvers::CostAddFinalCost (const symbolic::Expression &e)
 Adds a cost to the final time, of the form

\[ cost = e(t,x,u), \]

where any instances of time(), state(), and/or input() placeholder variables, as well as placeholder variables returned by calls to NewSequentialVariable(), are substituted with the relevant variables for the final time index. More...

 
solvers::Binding< solvers::CostAddFinalCost (const Eigen::Ref< const MatrixX< symbolic::Expression >> &matrix)
 Adds support for passing in a (scalar) matrix Expression, which is a common output of most symbolic linear algebra operations. More...
 
solvers::Binding< solvers::VisualizationCallbackAddInputTrajectoryCallback (const TrajectoryCallback &callback)
 Adds a callback method to visualize intermediate results of input variables used in the trajectory optimization. More...
 
solvers::Binding< solvers::VisualizationCallbackAddStateTrajectoryCallback (const TrajectoryCallback &callback)
 Adds a callback method to visualize intermediate results of state variables used in the trajectory optimization. More...
 
solvers::Binding< solvers::VisualizationCallbackAddCompleteTrajectoryCallback (const CompleteTrajectoryCallback &callback, const std::vector< std::string > &names)
 Adds a callback method to visualize intermediate results of all variables used in the trajectory optimization. More...
 
void SetInitialTrajectory (const trajectories::PiecewisePolynomial< double > &traj_init_u, const trajectories::PiecewisePolynomial< double > &traj_init_x)
 Set the initial guess for the trajectory decision variables. More...
 
Eigen::VectorXd GetSampleTimes (const Eigen::Ref< const Eigen::VectorXd > &h_var_values) const
 Returns a vector containing the elapsed time at each breakpoint. More...
 
Eigen::VectorXd GetSampleTimes (const solvers::MathematicalProgramResult &result) const
 Returns a vector containing the elapsed time at each breakpoint at the solution. More...
 
Eigen::MatrixXd GetInputSamples (const solvers::MathematicalProgramResult &result) const
 Returns a matrix containing the input values (arranged in columns) at each breakpoint at the solution. More...
 
Eigen::MatrixXd GetStateSamples (const solvers::MathematicalProgramResult &result) const
 Returns a matrix containing the state values (arranged in columns) at each breakpoint at the solution. More...
 
Eigen::MatrixXd GetSequentialVariableSamples (const solvers::MathematicalProgramResult &result, const std::string &name) const
 Returns a matrix containing the sequential variable values (arranged in columns) at each breakpoint at the solution. More...
 
virtual trajectories::PiecewisePolynomial< doubleReconstructInputTrajectory (const solvers::MathematicalProgramResult &) const =0
 Get the input trajectory at the solution as a PiecewisePolynomial. More...
 
virtual trajectories::PiecewisePolynomial< doubleReconstructStateTrajectory (const solvers::MathematicalProgramResult &) const =0
 Get the state trajectory at the solution as a PiecewisePolynomial. More...
 
double fixed_time_step () const
 
Does not allow copy, move, or assignment
 MultipleShooting (const MultipleShooting &)=delete
 
MultipleShootingoperator= (const MultipleShooting &)=delete
 
 MultipleShooting (MultipleShooting &&)=delete
 
MultipleShootingoperator= (MultipleShooting &&)=delete
 

Protected Member Functions

 MultipleShooting (int num_inputs, int num_states, int num_time_samples, double fixed_time_step, solvers::MathematicalProgram *prog=nullptr)
 Constructs a MultipleShooting instance with fixed sample times. More...
 
 MultipleShooting (const solvers::VectorXDecisionVariable &input, const solvers::VectorXDecisionVariable &state, int num_time_samples, double fixed_time_step, solvers::MathematicalProgram *prog=nullptr)
 Constructs a MultipleShooting instance with fixed sample times. More...
 
 MultipleShooting (int num_inputs, int num_states, int num_time_samples, double minimum_time_step, double maximum_time_step, solvers::MathematicalProgram *prog=nullptr)
 Constructs a MultipleShooting instance with sample times as decision variables. More...
 
 MultipleShooting (const solvers::VectorXDecisionVariable &input, const solvers::VectorXDecisionVariable &state, const solvers::DecisionVariable &time, int num_time_samples, double minimum_time_step, double maximum_time_step, solvers::MathematicalProgram *prog=nullptr)
 Constructs a MultipleShooting instance with sample times as decision variables. More...
 
symbolic::Expression SubstitutePlaceholderVariables (const symbolic::Expression &e, int interval_index) const
 Replaces e.g. More...
 
symbolic::Formula SubstitutePlaceholderVariables (const symbolic::Formula &f, int interval_index) const
 Replaces e.g. More...
 
int num_inputs () const
 
int num_states () const
 
int N () const
 
bool time_steps_are_decision_variables () const
 
const solvers::VectorXDecisionVariableh_vars () const
 
const solvers::VectorXDecisionVariableu_vars () const
 
const solvers::VectorXDecisionVariablex_vars () const
 
const solvers::VectorXDecisionVariable GetSequentialVariable (const std::string &name) const
 Returns the decision variables associated with the sequential variable name. More...
 

Member Typedef Documentation

◆ CompleteTrajectoryCallback

typedef std::function<void( const Eigen::Ref<const Eigen::VectorXd>& sample_times, const Eigen::Ref<const Eigen::MatrixXd>& states, const Eigen::Ref<const Eigen::MatrixXd>& inputs, const std::vector<Eigen::Ref<const Eigen::MatrixXd>>& values)> CompleteTrajectoryCallback

◆ TrajectoryCallback

typedef std::function<void( const Eigen::Ref<const Eigen::VectorXd>& sample_times, const Eigen::Ref<const Eigen::MatrixXd>& values)> TrajectoryCallback

Constructor & Destructor Documentation

◆ MultipleShooting() [1/6]

MultipleShooting ( const MultipleShooting )
delete

◆ MultipleShooting() [2/6]

◆ ~MultipleShooting()

virtual ~MultipleShooting ( )
virtual

◆ MultipleShooting() [3/6]

MultipleShooting ( int  num_inputs,
int  num_states,
int  num_time_samples,
double  fixed_time_step,
solvers::MathematicalProgram prog = nullptr 
)
protected

Constructs a MultipleShooting instance with fixed sample times.

It creates new placeholder variables for input and state.

Parameters
num_inputsNumber of inputs at each sample point.
num_statesNumber of states at each sample point.
num_time_samplesNumber of time samples.
fixed_time_stepThe spacing between sample times.
prog(optional). If non-null, then additional decision variables, costs, and constraints will be added into the existing MathematicalProgram. This can be useful for, e.g., combining multiple trajectory optimizations into a single program, coupled by a few constraints. If nullptr, then a new MathematicalProgram will be allocated.

◆ MultipleShooting() [4/6]

MultipleShooting ( const solvers::VectorXDecisionVariable input,
const solvers::VectorXDecisionVariable state,
int  num_time_samples,
double  fixed_time_step,
solvers::MathematicalProgram prog = nullptr 
)
protected

Constructs a MultipleShooting instance with fixed sample times.

It uses the provided input and state as placeholders instead of creating new placeholder variables for them.

Parameters
inputPlaceholder variables for input.
statePlaceholder variables for state.
num_time_samplesNumber of time samples.
fixed_time_stepThe spacing between sample times.
prog(optional). If non-null, then additional decision variables, costs, and constraints will be added into the existing MathematicalProgram. This can be useful for, e.g., combining multiple trajectory optimizations into a single program, coupled by a few constraints. If nullptr, then a new MathematicalProgram will be allocated.

◆ MultipleShooting() [5/6]

MultipleShooting ( int  num_inputs,
int  num_states,
int  num_time_samples,
double  minimum_time_step,
double  maximum_time_step,
solvers::MathematicalProgram prog = nullptr 
)
protected

Constructs a MultipleShooting instance with sample times as decision variables.

It creates new placeholder variables for input, state, and time.

Parameters
num_inputsNumber of inputs at each sample point.
num_statesNumber of states at each sample point.
num_time_samplesNumber of time samples.
minimum_time_stepMinimum spacing between sample times.
maximum_time_stepMaximum spacing between sample times.
prog(optional). If non-null, then additional decision variables, costs, and constraints will be added into the existing MathematicalProgram. This can be useful for, e.g., combining multiple trajectory optimizations into a single program, coupled by a few constraints. If nullptr, then a new MathematicalProgram will be allocated.

◆ MultipleShooting() [6/6]

MultipleShooting ( const solvers::VectorXDecisionVariable input,
const solvers::VectorXDecisionVariable state,
const solvers::DecisionVariable time,
int  num_time_samples,
double  minimum_time_step,
double  maximum_time_step,
solvers::MathematicalProgram prog = nullptr 
)
protected

Constructs a MultipleShooting instance with sample times as decision variables.

It uses the provided input, state, and time as placeholders instead of creating new placeholder variables for them.

Parameters
inputPlaceholder variables for input.
statePlaceholder variables for state.
timePlaceholder variable for time.
num_time_samplesNumber of time samples.
minimum_time_stepMinimum spacing between sample times.
maximum_time_stepMaximum spacing between sample times.
prog(optional). If non-null, then additional decision variables, costs, and constraints will be added into the existing MathematicalProgram. This can be useful for, e.g., combining multiple trajectory optimizations into a single program, coupled by a few constraints. If nullptr, then a new MathematicalProgram will be allocated.

Member Function Documentation

◆ AddCompleteTrajectoryCallback()

solvers::Binding<solvers::VisualizationCallback> AddCompleteTrajectoryCallback ( const CompleteTrajectoryCallback callback,
const std::vector< std::string > &  names 
)

Adds a callback method to visualize intermediate results of all variables used in the trajectory optimization.

The callback should be of the form MyVisualization(sample_times, states, inputs, values), where sample_times is an N-by-1 VectorXd of sample times, states is a num_states-by-N MatrixXd of the current (intermediate) state trajectory at the break points, inputs is a num_inputs-by-N MatrixXd of the current (intermediate) input trajectory at the break points and values is a vector of num_rows-by-N MatrixXds of the current (intermediate) extra sequential variables specified by names at the break points.

Note
Just like other costs/constraints, not all solvers support callbacks. Adding a callback here will force MathematicalProgram::Solve to select a solver that support callbacks. For instance, adding a visualization callback to a quadratic programming problem may result in using a nonlinear programming solver as the default solver.

◆ AddConstraintToAllKnotPoints() [1/3]

std::vector<solvers::Binding<C> > AddConstraintToAllKnotPoints ( std::shared_ptr< C >  constraint,
const Eigen::Ref< const VectorX< symbolic::Variable >> &  vars 
)

Adds a constraint to all breakpoints, where any instances in vars of time(), state(), and/or input() placeholder variables, as well as placeholder variables returned by calls to NewSequentialVariable(), are substituted with the relevant variables for each time index.

Returns
A vector of the bindings added to each knot point.

◆ AddConstraintToAllKnotPoints() [2/3]

std::vector<solvers::Binding<solvers::Constraint> > AddConstraintToAllKnotPoints ( const symbolic::Formula f)

Adds a constraint to all breakpoints, where any instances of time(), state(), and/or input() placeholder variables, as well as placeholder variables returned by calls to NewSequentialVariable(), are substituted with the relevant variables for each time index.

Returns
A vector of the bindings added to each knot point.

◆ AddConstraintToAllKnotPoints() [3/3]

std::vector<solvers::Binding<solvers::Constraint> > AddConstraintToAllKnotPoints ( const Eigen::Ref< const VectorX< symbolic::Formula >> &  f)

Variant of AddConstraintToAllKnotPoints that accepts a vector of formulas.

◆ AddDurationBounds()

solvers::Binding<solvers::LinearConstraint> AddDurationBounds ( double  lower_bound,
double  upper_bound 
)

Adds a constraint on the total duration of the trajectory.

Parameters
lower_boundA scalar double lower bound.
upper_boundA scalar double upper bound.
Returns
The constraint enforcing the duration bounds.
Exceptions
std::exceptionif time steps are not declared as decision variables.

◆ AddEqualTimeIntervalsConstraints()

std::vector<solvers::Binding<solvers::LinearConstraint> > AddEqualTimeIntervalsConstraints ( )

Adds constraints to enforce that all time steps have equal duration.

Returns
A vector of constraints enforcing all time intervals are equal.
Exceptions
std::exceptionif time steps are not declared as decision variables.

◆ AddFinalCost() [1/2]

solvers::Binding<solvers::Cost> AddFinalCost ( const symbolic::Expression e)

Adds a cost to the final time, of the form

\[ cost = e(t,x,u), \]

where any instances of time(), state(), and/or input() placeholder variables, as well as placeholder variables returned by calls to NewSequentialVariable(), are substituted with the relevant variables for the final time index.

Returns
The final cost added to the problem.

◆ AddFinalCost() [2/2]

solvers::Binding<solvers::Cost> AddFinalCost ( const Eigen::Ref< const MatrixX< symbolic::Expression >> &  matrix)

Adds support for passing in a (scalar) matrix Expression, which is a common output of most symbolic linear algebra operations.

Returns
The final cost added to the problem.
Note
Derived classes will need to type using MultipleShooting::AddFinalCost; to "unhide" this method.

◆ AddInputTrajectoryCallback()

solvers::Binding<solvers::VisualizationCallback> AddInputTrajectoryCallback ( const TrajectoryCallback callback)

Adds a callback method to visualize intermediate results of input variables used in the trajectory optimization.

The callback should be of the form MyVisualization(sample_times, values), where breaks is a N-by-1 VectorXd of sample times, and values is a num_inputs-by-N MatrixXd representing the current (intermediate) value of the input trajectory at the break points in each column.

Note
Just like other costs/constraints, not all solvers support callbacks. Adding a callback here will force MathematicalProgram::Solve to select a solver that support callbacks. For instance, adding a visualization callback to a quadratic programming problem may result in using a nonlinear programming solver as the default solver.

◆ AddRunningCost() [1/2]

void AddRunningCost ( const symbolic::Expression g)

Adds an integrated cost to all time steps, of the form

\[ cost = \int_0^T g(t,x,u) dt, \]

where any instances of time(), state(), and/or input() placeholder variables, as well as placeholder variables returned by calls to NewSequentialVariable(), are substituted with the relevant variables for each time index.

The particular integration scheme is determined by the derived class implementation.

◆ AddRunningCost() [2/2]

void AddRunningCost ( const Eigen::MatrixBase< Derived > &  g)

Adds support for passing in a (scalar) matrix Expression, which is a common output of most symbolic linear algebra operations.

◆ AddStateTrajectoryCallback()

solvers::Binding<solvers::VisualizationCallback> AddStateTrajectoryCallback ( const TrajectoryCallback callback)

Adds a callback method to visualize intermediate results of state variables used in the trajectory optimization.

The callback should be of the form MyVisualization(sample_times, values), where sample_times is a N-by-1 VectorXd of sample times, and values is a num_states-by-N MatrixXd representing the current (intermediate) value of the state trajectory at the break points in each column.

Note
Just like other costs/constraints, not all solvers support callbacks. Adding a callback here will force MathematicalProgram::Solve to select a solver that support callbacks. For instance, adding a visualization callback to a quadratic programming problem may result in using a nonlinear programming solver as the default solver.

◆ AddTimeIntervalBounds()

solvers::Binding<solvers::BoundingBoxConstraint> AddTimeIntervalBounds ( double  lower_bound,
double  upper_bound 
)

Adds bounds on all time intervals.

Parameters
lower_boundA scalar double lower bound.
upper_boundA scalar double upper bound.
Returns
The bounding box constraint enforcing time interval bounds.
Exceptions
std::exceptionif time steps are not declared as decision variables.

◆ final_state()

Eigen::VectorBlock<const solvers::VectorXDecisionVariable> final_state ( ) const

Returns the decision variables associated with the state, x, at the final time index.

◆ fixed_time_step()

double fixed_time_step ( ) const

◆ GetInputSamples()

Eigen::MatrixXd GetInputSamples ( const solvers::MathematicalProgramResult result) const

Returns a matrix containing the input values (arranged in columns) at each breakpoint at the solution.

◆ GetSampleTimes() [1/2]

Eigen::VectorXd GetSampleTimes ( const Eigen::Ref< const Eigen::VectorXd > &  h_var_values) const

Returns a vector containing the elapsed time at each breakpoint.

◆ GetSampleTimes() [2/2]

Eigen::VectorXd GetSampleTimes ( const solvers::MathematicalProgramResult result) const

Returns a vector containing the elapsed time at each breakpoint at the solution.

◆ GetSequentialVariable()

const solvers::VectorXDecisionVariable GetSequentialVariable ( const std::string &  name) const
protected

Returns the decision variables associated with the sequential variable name.

◆ GetSequentialVariableAtIndex()

solvers::VectorXDecisionVariable GetSequentialVariableAtIndex ( const std::string &  name,
int  index 
) const

Returns the decision variables associated with the sequential variable name at time index index.

See also
NewSequentialVariable().

◆ GetSequentialVariableSamples()

Eigen::MatrixXd GetSequentialVariableSamples ( const solvers::MathematicalProgramResult result,
const std::string &  name 
) const

Returns a matrix containing the sequential variable values (arranged in columns) at each breakpoint at the solution.

Parameters
nameThe name of sequential variable to get the results for. Must correspond to an already added sequential variable.

◆ GetStateSamples()

Eigen::MatrixXd GetStateSamples ( const solvers::MathematicalProgramResult result) const

Returns a matrix containing the state values (arranged in columns) at each breakpoint at the solution.

◆ h_vars()

const solvers::VectorXDecisionVariable& h_vars ( ) const
protected

◆ initial_state()

Eigen::VectorBlock<const solvers::VectorXDecisionVariable> initial_state ( ) const

Returns the decision variables associated with the state, x, at the initial time index.

◆ input() [1/2]

const solvers::VectorXDecisionVariable& input ( ) const

Returns placeholder decision variables (not actually declared as decision variables in the MathematicalProgram) associated with the input, u, but with the time-index undetermined.

These variables will be substituted for real decision variables at particular times in methods like AddRunningCost. Passing these variables directly into objectives/constraints for the parent classes will result in an error.

◆ input() [2/2]

Eigen::VectorBlock<const solvers::VectorXDecisionVariable> input ( int  index) const

Returns the decision variables associated with the input, u, at time index index.

◆ N()

int N ( ) const
protected

◆ NewSequentialVariable()

solvers::VectorXDecisionVariable NewSequentialVariable ( int  rows,
const std::string &  name 
)

Adds a sequential variable (a variable that has associated decision variables for each time index) to the optimization problem and returns a placeholder variable (not actually declared as a decision variable in the MathematicalProgram).

This variable will be substituted for real decision variables at particular times in methods like AddRunningCost(). Passing this variable directly into objectives/constraints for the parent classes will result in an error.

◆ num_inputs()

int num_inputs ( ) const
protected

◆ num_states()

int num_states ( ) const
protected

◆ operator=() [1/2]

MultipleShooting& operator= ( MultipleShooting &&  )
delete

◆ operator=() [2/2]

MultipleShooting& operator= ( const MultipleShooting )
delete

◆ prog() [1/2]

Returns a reference to the MathematicalProgram associated with the trajectory optimization problem.

◆ prog() [2/2]

const solvers::MathematicalProgram& prog ( ) const

Returns a const reference to the MathematicalProgram associated with the trajectory optimization problem.

◆ ReconstructInputTrajectory()

virtual trajectories::PiecewisePolynomial<double> ReconstructInputTrajectory ( const solvers::MathematicalProgramResult ) const
pure virtual

Get the input trajectory at the solution as a PiecewisePolynomial.

The order of the trajectory will be determined by the integrator used in the dynamic constraints. Requires that the system has at least one input port.

Implemented in DirectTranscription, and DirectCollocation.

◆ ReconstructStateTrajectory()

virtual trajectories::PiecewisePolynomial<double> ReconstructStateTrajectory ( const solvers::MathematicalProgramResult ) const
pure virtual

Get the state trajectory at the solution as a PiecewisePolynomial.

The order of the trajectory will be determined by the integrator used in the dynamic constraints.

Implemented in DirectTranscription, and DirectCollocation.

◆ SetInitialTrajectory()

void SetInitialTrajectory ( const trajectories::PiecewisePolynomial< double > &  traj_init_u,
const trajectories::PiecewisePolynomial< double > &  traj_init_x 
)

Set the initial guess for the trajectory decision variables.

Parameters
traj_init_uInitial guess for trajectory for control input. The number of rows for each segment in traj_init_u must be equal to num_inputs (the first param of the constructor). If empty, then a default small non-zero initial value is used instead.
traj_init_xInitial guess for trajectory for state input. The number of rows for each segment in traj_init_x must be equal to num_states (the second param of the constructor). If empty, then a default small non-zero initial value is used instead.

If time steps are decision variables, then the initial guess for the time steps are evenly distributed to match the duration of the traj_init_u and traj_init_x.

Exceptions
std::exceptionif traj_init_u and traj_init_x are both empty, or if traj_init_u and traj_init_x are both non-empty, and have different start and end times.

◆ state() [1/2]

const solvers::VectorXDecisionVariable& state ( ) const

Returns placeholder decision variables (not actually declared as decision variables in the MathematicalProgram) associated with the state, x, but with the time-index undetermined.

These variables will be substituted for real decision variables at particular times in methods like AddRunningCost. Passing these variables directly into objectives/constraints for the parent classes will result in an error.

◆ state() [2/2]

Eigen::VectorBlock<const solvers::VectorXDecisionVariable> state ( int  index) const

Returns the decision variables associated with the state, x, at time index index.

◆ SubstitutePlaceholderVariables() [1/2]

symbolic::Expression SubstitutePlaceholderVariables ( const symbolic::Expression e,
int  interval_index 
) const
protected

Replaces e.g.

placeholder_x_var_ with x_vars_ at time interval interval_index, for all placeholder variables.

◆ SubstitutePlaceholderVariables() [2/2]

symbolic::Formula SubstitutePlaceholderVariables ( const symbolic::Formula f,
int  interval_index 
) const
protected

Replaces e.g.

placeholder_x_var_ with x_vars_ at time interval interval_index, for all placeholder variables.

◆ time()

const solvers::VectorDecisionVariable<1>& time ( ) const

Returns a placeholder decision variable (not actually declared as a decision variable in the MathematicalProgram) associated with the time, t.

This variable will be substituted for real decision variables at particular times in methods like AddRunningCost. Passing this variable directly into objectives/constraints for the parent classes will result in an error.

◆ time_step()

const solvers::VectorDecisionVariable<1> time_step ( int  index) const

Returns the decision variable associated with the time step, h, at time index index.

Exceptions
std::exceptionif time steps are not declared as decision variables.

◆ time_steps_are_decision_variables()

bool time_steps_are_decision_variables ( ) const
protected

◆ u_vars()

const solvers::VectorXDecisionVariable& u_vars ( ) const
protected

◆ x_vars()

const solvers::VectorXDecisionVariable& x_vars ( ) const
protected

The documentation for this class was generated from the following file: