Crocoddyl
 
Loading...
Searching...
No Matches
euler.hpp
1
2// BSD 3-Clause License
3//
4// Copyright (C) 2019-2022, LAAS-CNRS, University of Edinburgh,
5// University of Oxford, Heriot-Watt University
6// Copyright note valid unless otherwise stated in individual files.
7// All rights reserved.
9
10#ifndef CROCODDYL_CORE_INTEGRATOR_EULER_HPP_
11#define CROCODDYL_CORE_INTEGRATOR_EULER_HPP_
12
13#include "crocoddyl/core/fwd.hpp"
14#include "crocoddyl/core/integ-action-base.hpp"
15
16namespace crocoddyl {
17
36template <typename _Scalar>
38 : public IntegratedActionModelAbstractTpl<_Scalar> {
39 public:
40 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
41
42 typedef _Scalar Scalar;
53 typedef typename MathBase::VectorXs VectorXs;
54 typedef typename MathBase::MatrixXs MatrixXs;
55
65 std::shared_ptr<DifferentialActionModelAbstract> model,
66 std::shared_ptr<ControlParametrizationModelAbstract> control,
67 const Scalar time_step = Scalar(1e-3),
68 const bool with_cost_residual = true);
69
81 std::shared_ptr<DifferentialActionModelAbstract> model,
82 const Scalar time_step = Scalar(1e-3),
83 const bool with_cost_residual = true);
85
94 virtual void calc(const std::shared_ptr<ActionDataAbstract>& data,
95 const Eigen::Ref<const VectorXs>& x,
96 const Eigen::Ref<const VectorXs>& u);
97
108 virtual void calc(const std::shared_ptr<ActionDataAbstract>& data,
109 const Eigen::Ref<const VectorXs>& x);
110
118 virtual void calcDiff(const std::shared_ptr<ActionDataAbstract>& data,
119 const Eigen::Ref<const VectorXs>& x,
120 const Eigen::Ref<const VectorXs>& u);
121
132 virtual void calcDiff(const std::shared_ptr<ActionDataAbstract>& data,
133 const Eigen::Ref<const VectorXs>& x);
134
140 virtual std::shared_ptr<ActionDataAbstract> createData();
141
145 virtual bool checkData(const std::shared_ptr<ActionDataAbstract>& data);
146
160 virtual void quasiStatic(const std::shared_ptr<ActionDataAbstract>& data,
161 Eigen::Ref<VectorXs> u,
162 const Eigen::Ref<const VectorXs>& x,
163 const std::size_t maxiter = 100,
164 const Scalar tol = Scalar(1e-9));
165
171 virtual void print(std::ostream& os) const;
172
173 protected:
174 using Base::control_;
175 using Base::differential_;
176 using Base::ng_;
177 using Base::nh_;
178 using Base::nu_;
179 using Base::state_;
180 using Base::time_step2_;
181 using Base::time_step_;
184};
185
186template <typename _Scalar>
188 : public IntegratedActionDataAbstractTpl<_Scalar> {
189 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
190
191 typedef _Scalar Scalar;
198 typedef typename MathBase::VectorXs VectorXs;
199 typedef typename MathBase::MatrixXs MatrixXs;
200
201 template <template <typename Scalar> class Model>
202 explicit IntegratedActionDataEulerTpl(Model<Scalar>* const model)
203 : Base(model) {
204 differential = model->get_differential()->createData();
205 control = model->get_control()->createData();
206 const std::size_t ndx = model->get_state()->get_ndx();
207 const std::size_t nv = model->get_state()->get_nv();
208 dx = VectorXs::Zero(ndx);
209 da_du = MatrixXs::Zero(nv, model->get_nu());
210 Lwu = MatrixXs::Zero(model->get_control()->get_nw(), model->get_nu());
211 }
213
214 std::shared_ptr<DifferentialActionDataAbstract>
216 std::shared_ptr<ControlParametrizationDataAbstract>
218 VectorXs dx;
219 MatrixXs da_du;
220 MatrixXs Lwu;
222
223 using Base::cost;
224 using Base::Fu;
225 using Base::Fx;
226 using Base::Lu;
227 using Base::Luu;
228 using Base::Lx;
229 using Base::Lxu;
230 using Base::Lxx;
231 using Base::r;
232 using Base::xnext;
233};
234
235} // namespace crocoddyl
236
237/* --- Details -------------------------------------------------------------- */
238/* --- Details -------------------------------------------------------------- */
239/* --- Details -------------------------------------------------------------- */
240#include "crocoddyl/core/integrator/euler.hxx"
241
242#endif // CROCODDYL_CORE_INTEGRATOR_EULER_HPP_
std::size_t nh_
Number of equality constraints.
std::size_t ng_
Number of inequality constraints.
Abstract class for the control trajectory parametrization.
Abstract class for differential action model.
Abstract class for an integrated action model.
bool with_cost_residual_
Flag indicating whether a cost residual is used.
Scalar time_step_
Time step used for integration.
std::shared_ptr< StateAbstract > state_
< Dimension of the control
std::shared_ptr< ControlParametrizationModelAbstract > control_
Model of the control parametrization.
std::size_t nu_
< Dimension of the cost residual
std::shared_ptr< DifferentialActionModelAbstract > differential_
Differential action model that is integrated.
Scalar time_step2_
Square of the time step used for integration.
Symplectic Euler integrator.
Definition euler.hpp:38
virtual void calc(const std::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Integrate the differential action model using symplectic Euler scheme.
IntegratedActionModelEulerTpl(std::shared_ptr< DifferentialActionModelAbstract > model, const Scalar time_step=Scalar(1e-3), const bool with_cost_residual=true)
Initialize the symplectic Euler integrator.
virtual void calcDiff(const std::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the partial derivatives of the symplectic Euler integrator.
virtual void calcDiff(const std::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
Compute the partial derivatives of the cost.
virtual void print(std::ostream &os) const
Print relevant information of the Euler integrator model.
virtual std::shared_ptr< ActionDataAbstract > createData()
Create the symplectic Euler data.
virtual void quasiStatic(const std::shared_ptr< ActionDataAbstract > &data, Eigen::Ref< VectorXs > u, const Eigen::Ref< const VectorXs > &x, const std::size_t maxiter=100, const Scalar tol=Scalar(1e-9))
Computes the quasic static commands.
IntegratedActionModelEulerTpl(std::shared_ptr< DifferentialActionModelAbstract > model, std::shared_ptr< ControlParametrizationModelAbstract > control, const Scalar time_step=Scalar(1e-3), const bool with_cost_residual=true)
Initialize the symplectic Euler integrator.
virtual void calc(const std::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
Integrate the total cost value for nodes that depends only on the state using symplectic Euler scheme...
virtual bool checkData(const std::shared_ptr< ActionDataAbstract > &data)
Checks that a specific data belongs to this model.
MatrixXs Fx
Jacobian of the dynamics w.r.t. the state .
MatrixXs Fu
Jacobian of the dynamics w.r.t. the control .
MatrixXs Luu
Hessian of the cost w.r.t. the control .
VectorXs Lx
Jacobian of the cost w.r.t. the state .
MatrixXs Lxx
Hessian of the cost w.r.t. the state .
VectorXs Lu
Jacobian of the cost w.r.t. the control .
std::shared_ptr< ControlParametrizationDataAbstract > control
Control parametrization data.
Definition euler.hpp:217
std::shared_ptr< DifferentialActionDataAbstract > differential
Differential model data.
Definition euler.hpp:215