Crocoddyl
ShootingProblemTpl< _Scalar > Class Template Reference

This class encapsulates a shooting problem. More...

#include <shooting.hpp>

Public Types

typedef ActionDataAbstractTpl< Scalar > ActionDataAbstract
 
typedef ActionModelAbstractTpl< Scalar > ActionModelAbstract
 
typedef MathBaseTpl< Scalar > MathBase
 
typedef MathBase::VectorXs VectorXs
 

Public Member Functions

 ShootingProblemTpl (const ShootingProblemTpl< Scalar > &problem)
 Initialize the shooting problem.
 
 ShootingProblemTpl (const VectorXs &x0, const std::vector< boost::shared_ptr< ActionModelAbstract > > &running_models, boost::shared_ptr< ActionModelAbstract > terminal_model)
 Initialize the shooting problem and allocate its data. More...
 
 ShootingProblemTpl (const VectorXs &x0, const std::vector< boost::shared_ptr< ActionModelAbstract > > &running_models, boost::shared_ptr< ActionModelAbstract > terminal_model, const std::vector< boost::shared_ptr< ActionDataAbstract > > &running_datas, boost::shared_ptr< ActionDataAbstract > terminal_data)
 Initialize the shooting problem (models and datas) More...
 
Scalar calc (const std::vector< VectorXs > &xs, const std::vector< VectorXs > &us)
 Compute the cost and the next states. More...
 
Scalar calcDiff (const std::vector< VectorXs > &xs, const std::vector< VectorXs > &us)
 Compute the derivatives of the cost and dynamics. More...
 
void circularAppend (boost::shared_ptr< ActionModelAbstract > model)
 Circular append of the model and data onto the end running node. More...
 
void circularAppend (boost::shared_ptr< ActionModelAbstract > model, boost::shared_ptr< ActionDataAbstract > data)
 Circular append of the model and data onto the end running node. More...
 
std::size_t get_ndx () const
 Return the dimension of the tangent space of the state manifold.
 
std::size_t get_nx () const
 Return the dimension of the state tuple.
 
const std::vector< boost::shared_ptr< ActionDataAbstract > > & get_runningDatas () const
 Return the running datas.
 
const std::vector< boost::shared_ptr< ActionModelAbstract > > & get_runningModels () const
 Return the running models.
 
std::size_t get_T () const
 Return the number of running nodes.
 
const boost::shared_ptr< ActionDataAbstract > & get_terminalData () const
 Return the terminal data.
 
const boost::shared_ptr< ActionModelAbstract > & get_terminalModel () const
 Return the terminal model.
 
const VectorXs & get_x0 () const
 Return the initial state.
 
DEPRECATED("Compute yourself the maximum dimension of the control vector", std::size_t get_nu_max() const ;) std bool is_updated ()
 Return the maximum dimension of the control vector. More...
 
void quasiStatic (std::vector< VectorXs > &us, const std::vector< VectorXs > &xs)
 Compute the quasic static commands given a state trajectory. More...
 
std::vector< VectorXs > quasiStatic_xs (const std::vector< VectorXs > &xs)
 Compute the quasic static commands given a state trajectory. More...
 
void rollout (const std::vector< VectorXs > &us, std::vector< VectorXs > &xs)
 Integrate the dynamics given a control sequence. More...
 
std::vector< VectorXs > rollout_us (const std::vector< VectorXs > &us)
 Integrate the dynamics given a control sequence. More...
 
void set_nthreads (const int nthreads)
 Modify the number of threads using with multithreading support. More...
 
void set_runningModels (const std::vector< boost::shared_ptr< ActionModelAbstract > > &models)
 Modify the running models and allocate new data.
 
void set_terminalModel (boost::shared_ptr< ActionModelAbstract > model)
 Modify the terminal model and allocate new data.
 
void set_x0 (const VectorXs &x0_in)
 Modify the initial state.
 
void updateModel (const std::size_t i, boost::shared_ptr< ActionModelAbstract > model)
 Update a model and allocated new data for a specific node. More...
 
void updateNode (const std::size_t i, boost::shared_ptr< ActionModelAbstract > model, boost::shared_ptr< ActionDataAbstract > data)
 Update the model and data for a specific node. More...
 

Public Attributes

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar
 

Protected Attributes

Scalar cost_
 Total cost.
 
bool is_updated_
 
std::size_t ndx_
 State rate dimension.
 
std::size_t nthreads_
 
std::size_t nu_max_
 Maximum control dimension.
 
std::size_t nx_
 State dimension.
 
std::vector< boost::shared_ptr< ActionDataAbstract > > running_datas_
 Running action data.
 
std::vector< boost::shared_ptr< ActionModelAbstract > > running_models_
 Running action model.
 
std::size_t T_
 number of running nodes
 
boost::shared_ptr< ActionDataAbstractterminal_data_
 Terminal action data.
 
boost::shared_ptr< ActionModelAbstractterminal_model_
 Terminal action model.
 
VectorXs x0_
 Initial state.
 

Friends

template<class Scalar >
std::ostream & operator<< (std::ostream &os, const ShootingProblemTpl< Scalar > &problem)
 Print information on the 'ShootingProblem'.
 

Detailed Description

template<typename _Scalar>
class crocoddyl::ShootingProblemTpl< _Scalar >

This class encapsulates a shooting problem.

A shooting problem encapsulates the initial state \(\mathbf{x}_{0}\in\mathcal{M}\), a set of running action models and a terminal action model for a discretized trajectory into \(T\) nodes. It has three main methods - calc, calcDiff and rollout. The first computes the set of next states and cost values per each node \(k\). Instead, calcDiff updates the derivatives of all action models. Finally, rollout integrates the system dynamics. This class is used to decouple problem formulation and resolution.

Definition at line 35 of file shooting.hpp.

Constructor & Destructor Documentation

◆ ShootingProblemTpl() [1/2]

ShootingProblemTpl ( const VectorXs &  x0,
const std::vector< boost::shared_ptr< ActionModelAbstract > > &  running_models,
boost::shared_ptr< ActionModelAbstract terminal_model 
)

Initialize the shooting problem and allocate its data.

Parameters
[in]x0Initial state
[in]running_modelsRunning action models (size \(T\))
[in]terminal_modelTerminal action model

◆ ShootingProblemTpl() [2/2]

ShootingProblemTpl ( const VectorXs &  x0,
const std::vector< boost::shared_ptr< ActionModelAbstract > > &  running_models,
boost::shared_ptr< ActionModelAbstract terminal_model,
const std::vector< boost::shared_ptr< ActionDataAbstract > > &  running_datas,
boost::shared_ptr< ActionDataAbstract terminal_data 
)

Initialize the shooting problem (models and datas)

Parameters
[in]x0Initial state
[in]running_modelsRunning action models (size \(T\))
[in]terminal_modelTerminal action model
[in]running_datasRunning action datas (size \(T\))
[in]terminal_dataTerminal action data

Member Function Documentation

◆ calc()

Scalar calc ( const std::vector< VectorXs > &  xs,
const std::vector< VectorXs > &  us 
)

Compute the cost and the next states.

For each node \(k\), and along the state \(\mathbf{x_{s}}\) and control \(\mathbf{u_{s}}\) trajectory, it computes the next state \(\mathbf{x}_{k+1}\) and cost \(l_{k}\).

Parameters
[in]xstime-discrete state trajectory \(\mathbf{x_{s}}\) (size \(T+1\))
[in]ustime-discrete control sequence \(\mathbf{u_{s}}\) (size \(T\))
Returns
The total cost value \(l_{k}\)

◆ calcDiff()

Scalar calcDiff ( const std::vector< VectorXs > &  xs,
const std::vector< VectorXs > &  us 
)

Compute the derivatives of the cost and dynamics.

For each node \(k\), and along the state \(\mathbf{x_{s}}\) and control \(\mathbf{u_{s}}\) trajectory, it computes the derivatives of the cost \((\mathbf{l}_{\mathbf{x}}, \mathbf{l}_{\mathbf{u}}, \mathbf{l}_{\mathbf{xx}}, \mathbf{l}_{\mathbf{xu}}, \mathbf{l}_{\mathbf{uu}})\) and dynamics \((\mathbf{f}_{\mathbf{x}}, \mathbf{f}_{\mathbf{u}})\).

Parameters
[in]xstime-discrete state trajectory \(\mathbf{x_{s}}\) (size \(T+1\))
[in]ustime-discrete control sequence \(\mathbf{u_{s}}\) (size \(T\))
Returns
The total cost value \(l_{k}\)

◆ rollout()

void rollout ( const std::vector< VectorXs > &  us,
std::vector< VectorXs > &  xs 
)

Integrate the dynamics given a control sequence.

Parameters
[in]xstime-discrete state trajectory \(\mathbf{x_{s}}\) (size \(T+1\))
[in]ustime-discrete control sequence \(\mathbf{u_{s}}\) (size \(T\))

◆ rollout_us()

std::vector<VectorXs> rollout_us ( const std::vector< VectorXs > &  us)

Integrate the dynamics given a control sequence.

Parameters
[in]ustime-discrete control sequence \(\mathbf{u_{s}}\) (size \(T\))
Returns
the time-discrete state trajectory \(\mathbf{x_{s}}\) (size \(T+1\))

◆ quasiStatic()

void quasiStatic ( std::vector< VectorXs > &  us,
const std::vector< VectorXs > &  xs 
)

Compute the quasic static commands given a state trajectory.

Parameters
[out]ustime-discrete control sequence \(\mathbf{u_{s}}\) (size \(T\))
[in]xstime-discrete state trajectory \(\mathbf{x_{s}}\) (size \(T+1\))

◆ quasiStatic_xs()

std::vector<VectorXs> quasiStatic_xs ( const std::vector< VectorXs > &  xs)

Compute the quasic static commands given a state trajectory.

Parameters
[in]xstime-discrete state trajectory \(\mathbf{x_{s}}\) (size \(T+1\))
Returns
the time-discrete quasic static commands \(\mathbf{u_{s}}\) (size \(T\))

◆ circularAppend() [1/2]

void circularAppend ( boost::shared_ptr< ActionModelAbstract model,
boost::shared_ptr< ActionDataAbstract data 
)

Circular append of the model and data onto the end running node.

Once we update the end running node, the first running mode is removed as in a circular buffer.

Parameters
[in]modelaction model
[in]dataaction data

◆ circularAppend() [2/2]

void circularAppend ( boost::shared_ptr< ActionModelAbstract model)

Circular append of the model and data onto the end running node.

Once we update the end running node, the first running mode is removed as in a circular buffer. Note that this method allocates new data for the end running node.

Parameters
[in]modelaction model

◆ updateNode()

void updateNode ( const std::size_t  i,
boost::shared_ptr< ActionModelAbstract model,
boost::shared_ptr< ActionDataAbstract data 
)

Update the model and data for a specific node.

Parameters
[in]inode index \((0\leq i \lt T+1)\)
[in]modelaction model
[in]dataaction data

◆ updateModel()

void updateModel ( const std::size_t  i,
boost::shared_ptr< ActionModelAbstract model 
)

Update a model and allocated new data for a specific node.

Parameters
[in]inode index \((0\leq i \lt T+1)\)
[in]modelaction model

◆ set_nthreads()

void set_nthreads ( const int  nthreads)

Modify the number of threads using with multithreading support.

For values lower than 1, the number of threads is chosen by CROCODDYL_WITH_NTHREADS macro

◆ is_updated()

DEPRECATED ("Compute yourself the maximum dimension of the control vector", std::size_t get_nu_max() const;) std bool is_updated ( )

Return the maximum dimension of the control vector.

Return the number of threads

Return only once true is the shooting problem has been changed, otherwise false

Member Data Documentation

◆ nthreads_

std::size_t nthreads_
protected

Number of threads launch by the multi-threading application

Definition at line 301 of file shooting.hpp.


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