8template <
typename Scalar>
9typename math_types<Scalar>::VectorOfVectors
rollout(
11 const typename math_types<Scalar>::VectorXs &x0,
12 const typename math_types<Scalar>::VectorOfVectors &us,
13 typename math_types<Scalar>::VectorOfVectors &xout) {
15 const std::size_t N = us.size();
16 if (dyn_models.size() != N) {
18 "Number of controls should be the same as number of dynamical models!");
23 for (std::size_t i = 0; i < N; i++) {
24 shared_ptr<Data> data = dyn_models[i]->createData();
25 const ManifoldAbstractTpl<Scalar> &space = dyn_models[i]->space();
26 xout.push_back(space.neutral());
34template <
typename Scalar>
35typename math_types<Scalar>::VectorOfVectors
37 const typename math_types<Scalar>::VectorXs &x0,
38 const typename math_types<Scalar>::VectorOfVectors &us) {
39 using VectorXs =
typename math_types<Scalar>::VectorXs;
41 const std::size_t N = us.size();
42 std::vector<VectorXs> xs{x0};
44 shared_ptr<DynamicsDataTpl<Scalar>> data = dyn_model.
createData();
46 for (std::size_t i = 0; i < N; i++) {
47 const ManifoldAbstractTpl<Scalar> &space = dyn_model.
space();
48 xs.push_back(space.neutral());
56template <
typename Scalar>
60 const typename math_types<Scalar>::VectorXs &x0,
61 const typename math_types<Scalar>::VectorOfVectors &us,
62 typename math_types<Scalar>::VectorOfVectors &xout) {
64 const std::size_t N = us.size();
67 if (dyn_models.size() != N) {
69 "number of dynamical models ({:d})!",
70 N, dyn_models.size());
73 for (std::size_t i = 0; i < N; i++) {
74 shared_ptr<DataType> data =
75 std::static_pointer_cast<DataType>(dyn_models[i]->createData());
76 dyn_models[i]->forward(xout[i], us[i], *data);
77 xout[i + 1] = data->xnext_;
82template <
typename Scalar>
84 const typename math_types<Scalar>::VectorXs &x0,
85 const typename math_types<Scalar>::VectorOfVectors &us,
86 typename math_types<Scalar>::VectorOfVectors &xout) {
88 const std::size_t N = us.size();
92 shared_ptr<DataType> data =
93 std::static_pointer_cast<DataType>(dyn_model.
createData());
94 for (std::size_t i = 0; i < N; i++) {
95 dyn_model.
forward(xout[i], us[i], *data);
96 xout[i + 1] = data->xnext_;
101template <
template <
typename>
class C,
typename Scalar>
102typename math_types<Scalar>::VectorOfVectors
103rollout(
const C<Scalar> &dms,
const typename math_types<Scalar>::VectorXs &x0,
104 const typename math_types<Scalar>::VectorOfVectors &us) {
105 const std::size_t N = us.size();
106 typename math_types<Scalar>::VectorOfVectors xout;
113template <
template <
typename>
class C,
typename Scalar>
114typename math_types<Scalar>::VectorOfVectors
115rollout(
const std::vector<xyz::polymorphic<C<Scalar>>> &dms,
116 const typename math_types<Scalar>::VectorXs &x0,
117 const typename math_types<Scalar>::VectorOfVectors &us) {
118 const std::size_t N = us.size();
119 typename math_types<Scalar>::VectorOfVectors xout;
#define ALIGATOR_RUNTIME_ERROR(...)
math_types< Scalar >::VectorOfVectors rollout(const std::vector< xyz::polymorphic< DynamicsModelTpl< Scalar > > > &dyn_models, const typename math_types< Scalar >::VectorXs &x0, const typename math_types< Scalar >::VectorOfVectors &us, typename math_types< Scalar >::VectorOfVectors &xout)
Perform a rollout of the supplied dynamical models.
Dynamics model: describes system dynamics through an implicit relation .
const Manifold & space() const
State space for the input.
virtual shared_ptr< Data > createData() const
Specific data struct for explicit dynamics ExplicitDynamicsModelTpl.
Explicit forward dynamics model .
virtual shared_ptr< BaseData > createData() const
virtual void forward(const ConstVectorRef &x, const ConstVectorRef &u, Data &data) const =0
Evaluate the forward discrete dynamics.
static void run(const DynamicsModelTpl< T > &model, const ConstVectorRef &x, const ConstVectorRef &u, DynamicsDataTpl< T > &data, VectorRef xout, const std::optional< ConstVectorRef > &gap=std::nullopt, const uint max_iters=1000, const T EPS=1e-6)