Crocoddyl
 
Loading...
Searching...
No Matches
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< std::shared_ptr< ActionModelAbstract > > &running_models, std::shared_ptr< ActionModelAbstract > terminal_model)
 Initialize the shooting problem and allocate its data.
 
 ShootingProblemTpl (const VectorXs &x0, const std::vector< std::shared_ptr< ActionModelAbstract > > &running_models, std::shared_ptr< ActionModelAbstract > terminal_model, const std::vector< std::shared_ptr< ActionDataAbstract > > &running_datas, std::shared_ptr< ActionDataAbstract > terminal_data)
 Initialize the shooting problem (models and datas)
 
Scalar calc (const std::vector< VectorXs > &xs, const std::vector< VectorXs > &us)
 Compute the cost and the next states.
 
Scalar calcDiff (const std::vector< VectorXs > &xs, const std::vector< VectorXs > &us)
 Compute the derivatives of the cost and dynamics.
 
template<typename NewScalar >
ShootingProblemTpl< NewScalar > cast () const
 Cast the shooting problem to a different scalar type.
 
void circularAppend (std::shared_ptr< ActionModelAbstract > model)
 Circular append of the model and data onto the end running node.
 
void circularAppend (std::shared_ptr< ActionModelAbstract > model, std::shared_ptr< ActionDataAbstract > data)
 Circular append of the model and data onto the end running node.
 
std::size_t get_ndx () const
 Return the dimension of the tangent space of the state manifold.
 
std::size_t get_nthreads () const
 Return the number of threads.
 
std::size_t get_nx () const
 Return the dimension of the state tuple.
 
const std::vector< std::shared_ptr< ActionDataAbstract > > & get_runningDatas () const
 Return the running datas.
 
const std::vector< std::shared_ptr< ActionModelAbstract > > & get_runningModels () const
 Return the running models.
 
std::size_t get_T () const
 Return the number of running nodes.
 
const std::shared_ptr< ActionDataAbstract > & get_terminalData () const
 Return the terminal data.
 
const std::shared_ptr< ActionModelAbstract > & get_terminalModel () const
 Return the terminal model.
 
const VectorXs & get_x0 () const
 Return the initial state.
 
bool is_updated ()
 Return only once true is the shooting problem has been changed, otherwise false.
 
void quasiStatic (std::vector< VectorXs > &us, const std::vector< VectorXs > &xs)
 Compute the quasic static commands given a state trajectory.
 
std::vector< VectorXs > quasiStatic_xs (const std::vector< VectorXs > &xs)
 Compute the quasic static commands given a state trajectory.
 
void rollout (const std::vector< VectorXs > &us, std::vector< VectorXs > &xs)
 Integrate the dynamics given a control sequence.
 
std::vector< VectorXs > rollout_us (const std::vector< VectorXs > &us)
 Integrate the dynamics given a control sequence.
 
void set_nthreads (const int nthreads)
 Modify the number of threads using with multithreading support.
 
void set_runningModels (const std::vector< std::shared_ptr< ActionModelAbstract > > &models)
 Modify the running models and allocate new data.
 
void set_terminalModel (std::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, std::shared_ptr< ActionModelAbstract > model)
 Update a model and allocated new data for a specific node.
 
void updateNode (const std::size_t i, std::shared_ptr< ActionModelAbstract > model, std::shared_ptr< ActionDataAbstract > data)
 Update the model and data for a specific node.
 

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 nx_
 State dimension.
 
std::vector< std::shared_ptr< ActionDataAbstract > > running_datas_
 Running action data.
 
std::vector< std::shared_ptr< ActionModelAbstract > > running_models_
 Running action model.
 
std::size_t T_
 number of running nodes
 
std::shared_ptr< ActionDataAbstractterminal_data_
 Terminal action data.
 
std::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 32 of file shooting.hpp.

Member Typedef Documentation

◆ ActionModelAbstract

template<typename _Scalar >
typedef ActionModelAbstractTpl<Scalar> ActionModelAbstract

Definition at line 37 of file shooting.hpp.

◆ ActionDataAbstract

template<typename _Scalar >
typedef ActionDataAbstractTpl<Scalar> ActionDataAbstract

Definition at line 38 of file shooting.hpp.

◆ MathBase

template<typename _Scalar >
typedef MathBaseTpl<Scalar> MathBase

Definition at line 39 of file shooting.hpp.

◆ VectorXs

template<typename _Scalar >
typedef MathBase::VectorXs VectorXs

Definition at line 40 of file shooting.hpp.

Constructor & Destructor Documentation

◆ ShootingProblemTpl() [1/2]

template<typename _Scalar >
ShootingProblemTpl ( const VectorXs &  x0,
const std::vector< std::shared_ptr< ActionModelAbstract > > &  running_models,
std::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]

template<typename _Scalar >
ShootingProblemTpl ( const VectorXs &  x0,
const std::vector< std::shared_ptr< ActionModelAbstract > > &  running_models,
std::shared_ptr< ActionModelAbstract terminal_model,
const std::vector< std::shared_ptr< ActionDataAbstract > > &  running_datas,
std::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()

template<typename _Scalar >
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()

template<typename _Scalar >
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()

template<typename _Scalar >
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()

template<typename _Scalar >
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()

template<typename _Scalar >
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()

template<typename _Scalar >
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]

template<typename _Scalar >
void circularAppend ( std::shared_ptr< ActionModelAbstract model,
std::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]

template<typename _Scalar >
void circularAppend ( std::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()

template<typename _Scalar >
void updateNode ( const std::size_t  i,
std::shared_ptr< ActionModelAbstract model,
std::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()

template<typename _Scalar >
void updateModel ( const std::size_t  i,
std::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

◆ cast()

template<typename _Scalar >
template<typename NewScalar >
ShootingProblemTpl< NewScalar > cast ( ) const

Cast the shooting problem to a different scalar type.

It is useful for operations requiring different precision or scalar types.

Template Parameters
NewScalarThe new scalar type to cast to.
Returns
ShootingProblemTpl<NewScalar> A shooting problem with the new scalar type.

◆ set_nthreads()

template<typename _Scalar >
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

Member Data Documentation

◆ Scalar

template<typename _Scalar >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar

Definition at line 36 of file shooting.hpp.

◆ cost_

template<typename _Scalar >
Scalar cost_
protected

Total cost.

Definition at line 289 of file shooting.hpp.

◆ T_

template<typename _Scalar >
std::size_t T_
protected

number of running nodes

Definition at line 290 of file shooting.hpp.

◆ x0_

template<typename _Scalar >
VectorXs x0_
protected

Initial state.

Definition at line 291 of file shooting.hpp.

◆ terminal_model_

template<typename _Scalar >
std::shared_ptr<ActionModelAbstract> terminal_model_
protected

Terminal action model.

Definition at line 293 of file shooting.hpp.

◆ terminal_data_

template<typename _Scalar >
std::shared_ptr<ActionDataAbstract> terminal_data_
protected

Terminal action data.

Definition at line 294 of file shooting.hpp.

◆ running_models_

template<typename _Scalar >
std::vector<std::shared_ptr<ActionModelAbstract> > running_models_
protected

Running action model.

Definition at line 296 of file shooting.hpp.

◆ running_datas_

template<typename _Scalar >
std::vector<std::shared_ptr<ActionDataAbstract> > running_datas_
protected

Running action data.

Definition at line 298 of file shooting.hpp.

◆ nx_

template<typename _Scalar >
std::size_t nx_
protected

State dimension.

Definition at line 299 of file shooting.hpp.

◆ ndx_

template<typename _Scalar >
std::size_t ndx_
protected

State rate dimension.

Definition at line 300 of file shooting.hpp.

◆ nthreads_

template<typename _Scalar >
std::size_t nthreads_
protected

Number of threads launch by the multi-threading application

Definition at line 301 of file shooting.hpp.

◆ is_updated_

template<typename _Scalar >
bool is_updated_
protected

Definition at line 303 of file shooting.hpp.


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