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< ActionDataAbstract > | terminal_data_ |
Terminal action data. | |
boost::shared_ptr< ActionModelAbstract > | terminal_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'. | |
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.
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.
[in] | x0 | Initial state |
[in] | running_models | Running action models (size \(T\)) |
[in] | terminal_model | Terminal action model |
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)
[in] | x0 | Initial state |
[in] | running_models | Running action models (size \(T\)) |
[in] | terminal_model | Terminal action model |
[in] | running_datas | Running action datas (size \(T\)) |
[in] | terminal_data | Terminal action data |
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}\).
[in] | xs | time-discrete state trajectory \(\mathbf{x_{s}}\) (size \(T+1\)) |
[in] | us | time-discrete control sequence \(\mathbf{u_{s}}\) (size \(T\)) |
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}})\).
[in] | xs | time-discrete state trajectory \(\mathbf{x_{s}}\) (size \(T+1\)) |
[in] | us | time-discrete control sequence \(\mathbf{u_{s}}\) (size \(T\)) |
void rollout | ( | const std::vector< VectorXs > & | us, |
std::vector< VectorXs > & | xs | ||
) |
Integrate the dynamics given a control sequence.
[in] | xs | time-discrete state trajectory \(\mathbf{x_{s}}\) (size \(T+1\)) |
[in] | us | time-discrete control sequence \(\mathbf{u_{s}}\) (size \(T\)) |
std::vector<VectorXs> rollout_us | ( | const std::vector< VectorXs > & | us | ) |
Integrate the dynamics given a control sequence.
[in] | us | time-discrete control sequence \(\mathbf{u_{s}}\) (size \(T\)) |
void quasiStatic | ( | std::vector< VectorXs > & | us, |
const std::vector< VectorXs > & | xs | ||
) |
Compute the quasic static commands given a state trajectory.
[out] | us | time-discrete control sequence \(\mathbf{u_{s}}\) (size \(T\)) |
[in] | xs | time-discrete state trajectory \(\mathbf{x_{s}}\) (size \(T+1\)) |
std::vector<VectorXs> quasiStatic_xs | ( | const std::vector< VectorXs > & | xs | ) |
Compute the quasic static commands given a state trajectory.
[in] | xs | time-discrete state trajectory \(\mathbf{x_{s}}\) (size \(T+1\)) |
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.
[in] | model | action model |
[in] | data | action data |
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.
[in] | model | action model |
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.
[in] | i | node index \((0\leq i \lt T+1)\) |
[in] | model | action model |
[in] | data | action data |
void updateModel | ( | const std::size_t | i, |
boost::shared_ptr< ActionModelAbstract > | model | ||
) |
Update a model and allocated new data for a specific node.
[in] | i | node index \((0\leq i \lt T+1)\) |
[in] | model | action model |
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
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
|
protected |
Number of threads launch by the multi-threading application
Definition at line 301 of file shooting.hpp.