crocoddyl  1.4.0
Contact RObot COntrol by Differential DYnamic programming Library (Crocoddyl)
euler.hpp
1 // BSD 3-Clause License
3 //
4 // Copyright (C) 2018-2020, LAAS-CNRS, University of Edinburgh
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
8 
9 #ifndef CROCODDYL_CORE_INTEGRATOR_EULER_HPP_
10 #define CROCODDYL_CORE_INTEGRATOR_EULER_HPP_
11 
12 #include "crocoddyl/core/fwd.hpp"
13 #include "crocoddyl/core/action-base.hpp"
14 #include "crocoddyl/core/diff-action-base.hpp"
15 
16 namespace crocoddyl {
17 
18 template <typename _Scalar>
19 class IntegratedActionModelEulerTpl : public ActionModelAbstractTpl<_Scalar> {
20  public:
21  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
22 
23  typedef _Scalar Scalar;
24  typedef MathBaseTpl<Scalar> MathBase;
25  typedef ActionModelAbstractTpl<Scalar> Base;
26  typedef IntegratedActionDataEulerTpl<Scalar> Data;
27  typedef ActionDataAbstractTpl<Scalar> ActionDataAbstract;
28  typedef DifferentialActionModelAbstractTpl<Scalar> DifferentialActionModelAbstract;
29  typedef typename MathBase::VectorXs VectorXs;
30  typedef typename MathBase::MatrixXs MatrixXs;
31 
32  IntegratedActionModelEulerTpl(boost::shared_ptr<DifferentialActionModelAbstract> model,
33  const Scalar& time_step = Scalar(1e-3), const bool& with_cost_residual = true);
34  virtual ~IntegratedActionModelEulerTpl();
35 
36  virtual void calc(const boost::shared_ptr<ActionDataAbstract>& data, const Eigen::Ref<const VectorXs>& x,
37  const Eigen::Ref<const VectorXs>& u);
38  virtual void calcDiff(const boost::shared_ptr<ActionDataAbstract>& data, const Eigen::Ref<const VectorXs>& x,
39  const Eigen::Ref<const VectorXs>& u);
40  virtual boost::shared_ptr<ActionDataAbstract> createData();
41  virtual bool checkData(const boost::shared_ptr<ActionDataAbstract>& data);
42 
43  const boost::shared_ptr<DifferentialActionModelAbstract>& get_differential() const;
44  const Scalar& get_dt() const;
45 
46  void set_dt(const Scalar& dt);
47  void set_differential(boost::shared_ptr<DifferentialActionModelAbstract> model);
48 
49  protected:
51  using Base::nr_;
52  using Base::nu_;
53  using Base::state_;
54  using Base::u_lb_;
55  using Base::u_ub_;
56  using Base::unone_;
57 
58  private:
59  boost::shared_ptr<DifferentialActionModelAbstract> differential_;
60  Scalar time_step_;
61  Scalar time_step2_;
62  bool with_cost_residual_;
63  bool enable_integration_;
64 };
65 
66 template <typename _Scalar>
67 struct IntegratedActionDataEulerTpl : public ActionDataAbstractTpl<_Scalar> {
68  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
69 
70  typedef _Scalar Scalar;
71  typedef MathBaseTpl<Scalar> MathBase;
72  typedef ActionDataAbstractTpl<Scalar> Base;
73  typedef typename MathBase::VectorXs VectorXs;
74  typedef typename MathBase::MatrixXs MatrixXs;
75 
76  template <template <typename Scalar> class Model>
77  explicit IntegratedActionDataEulerTpl(Model<Scalar>* const model) : Base(model) {
78  differential = model->get_differential()->createData();
79  const std::size_t& ndx = model->get_state()->get_ndx();
80  dx = VectorXs::Zero(ndx);
81  }
82  ~IntegratedActionDataEulerTpl() {}
83 
84  boost::shared_ptr<DifferentialActionDataAbstractTpl<Scalar> > differential;
85  VectorXs dx;
86 
87  using Base::cost;
88  using Base::Fu;
89  using Base::Fx;
90  using Base::Lu;
91  using Base::Luu;
92  using Base::Lx;
93  using Base::Lxu;
94  using Base::Lxx;
95  using Base::r;
96  using Base::xnext;
97 };
98 
99 } // namespace crocoddyl
100 
101 /* --- Details -------------------------------------------------------------- */
102 /* --- Details -------------------------------------------------------------- */
103 /* --- Details -------------------------------------------------------------- */
104 #include "crocoddyl/core/integrator/euler.hxx"
105 
106 #endif // CROCODDYL_CORE_INTEGRATOR_EULER_HPP_
bool has_control_limits_
Indicates whether any of the control limits is finite.
Definition: action-base.hpp:71
std::size_t nu_
Control dimension.
Definition: action-base.hpp:65
VectorXs unone_
Neutral state.
Definition: action-base.hpp:68
VectorXs u_ub_
Upper control limits.
Definition: action-base.hpp:70
VectorXs u_lb_
Lower control limits.
Definition: action-base.hpp:69
boost::shared_ptr< StateAbstract > state_
Model of the state.
Definition: action-base.hpp:67
std::size_t nr_
Dimension of the cost residual.
Definition: action-base.hpp:66