Crocoddyl
integ-action-base.hpp
1 // BSD 3-Clause License
3 //
4 // Copyright (C) 2021-2022, LAAS-CNRS, University of Edinburgh,
5 // University of Oxford, University of Trento,
6 // Heriot-Watt University
7 // Copyright note valid unless otherwise stated in individual files.
8 // All rights reserved.
10 
11 #ifndef CROCODDYL_CORE_INTEGRATED_ACTION_BASE_HPP_
12 #define CROCODDYL_CORE_INTEGRATED_ACTION_BASE_HPP_
13 
14 #include "crocoddyl/core/action-base.hpp"
15 #include "crocoddyl/core/control-base.hpp"
16 #include "crocoddyl/core/diff-action-base.hpp"
17 #include "crocoddyl/core/fwd.hpp"
18 #include "crocoddyl/core/utils/deprecate.hpp"
19 
20 namespace crocoddyl {
21 
40 template <typename _Scalar>
41 class IntegratedActionModelAbstractTpl
42  : public ActionModelAbstractTpl<_Scalar> {
43  public:
44  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
45 
46  typedef _Scalar Scalar;
47  typedef MathBaseTpl<Scalar> MathBase;
48  typedef ActionModelAbstractTpl<Scalar> Base;
49  typedef IntegratedActionDataAbstractTpl<Scalar> Data;
50  typedef ActionDataAbstractTpl<Scalar> ActionDataAbstract;
51  typedef DifferentialActionModelAbstractTpl<Scalar>
52  DifferentialActionModelAbstract;
53  typedef ControlParametrizationModelAbstractTpl<Scalar>
54  ControlParametrizationModelAbstract;
55  typedef typename MathBase::VectorXs VectorXs;
56  typedef typename MathBase::MatrixXs MatrixXs;
57 
67  boost::shared_ptr<DifferentialActionModelAbstract> model,
68  boost::shared_ptr<ControlParametrizationModelAbstract> control,
69  const Scalar time_step = Scalar(1e-3),
70  const bool with_cost_residual = true);
71 
83  boost::shared_ptr<DifferentialActionModelAbstract> model,
84  const Scalar time_step = Scalar(1e-3),
85  const bool with_cost_residual = true);
87 
93  virtual boost::shared_ptr<ActionDataAbstract> createData();
94 
98  virtual std::size_t get_ng() const;
99 
103  virtual std::size_t get_nh() const;
104 
108  virtual const VectorXs& get_g_lb() const;
109 
113  virtual const VectorXs& get_g_ub() const;
114 
119  const boost::shared_ptr<DifferentialActionModelAbstract>& get_differential()
120  const;
121 
126  const boost::shared_ptr<ControlParametrizationModelAbstract>& get_control()
127  const;
128 
132  const Scalar get_dt() const;
133 
137  void set_dt(const Scalar dt);
138 
139  DEPRECATED("The DifferentialActionModel should be set at construction time",
140  void set_differential(
141  boost::shared_ptr<DifferentialActionModelAbstract> model));
142 
143  protected:
145  using Base::nr_;
147  using Base::nu_;
148  using Base::state_;
149  using Base::u_lb_;
150  using Base::u_ub_;
151  using Base::unone_;
152 
153  void init();
154 
155  boost::shared_ptr<DifferentialActionModelAbstract>
157  boost::shared_ptr<ControlParametrizationModelAbstract>
159 
160  Scalar time_step_;
161  Scalar time_step2_;
162  bool
164 };
165 
166 template <typename _Scalar>
168  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
169 
170  typedef _Scalar Scalar;
171  typedef MathBaseTpl<Scalar> MathBase;
172  typedef ActionDataAbstractTpl<Scalar> Base;
173  typedef typename MathBase::VectorXs VectorXs;
174  typedef typename MathBase::MatrixXs MatrixXs;
175 
176  template <template <typename Scalar> class Model>
177  explicit IntegratedActionDataAbstractTpl(Model<Scalar>* const model)
178  : Base(model) {}
179  virtual ~IntegratedActionDataAbstractTpl() {}
180 
181  using Base::cost;
182  using Base::Fu;
183  using Base::Fx;
184  using Base::Lu;
185  using Base::Luu;
186  using Base::Lx;
187  using Base::Lxu;
188  using Base::Lxx;
189  using Base::r;
190  using Base::xnext;
191 };
192 
193 } // namespace crocoddyl
194 
195 /* --- Details -------------------------------------------------------------- */
196 /* --- Details -------------------------------------------------------------- */
197 /* --- Details -------------------------------------------------------------- */
198 #include "crocoddyl/core/integ-action-base.hxx"
199 
200 #endif // CROCODDYL_CORE_INTEGRATED_ACTION_BASE_HPP_
crocoddyl::IntegratedActionModelAbstractTpl::differential_
boost::shared_ptr< DifferentialActionModelAbstract > differential_
Differential action model that is integrated.
Definition: integ-action-base.hpp:156
crocoddyl::ActionDataAbstractTpl
Definition: action-base.hpp:329
crocoddyl::ActionModelAbstractTpl::has_control_limits_
bool has_control_limits_
Definition: action-base.hpp:315
crocoddyl::IntegratedActionModelAbstractTpl::with_cost_residual_
bool with_cost_residual_
Flag indicating whether a cost residual is used.
Definition: integ-action-base.hpp:163
crocoddyl::IntegratedActionModelAbstractTpl::set_dt
void set_dt(const Scalar dt)
Set the time step for the integration.
crocoddyl::ActionDataAbstractTpl::Lxu
MatrixXs Lxu
Definition: action-base.hpp:382
crocoddyl::MathBaseTpl< Scalar >
crocoddyl::IntegratedActionModelAbstractTpl::get_nh
virtual std::size_t get_nh() const
Return the number of equality constraints.
crocoddyl::IntegratedActionModelAbstractTpl::createData
virtual boost::shared_ptr< ActionDataAbstract > createData()
Create the integrator data.
crocoddyl::ActionModelAbstractTpl::nu_
std::size_t nu_
Control dimension.
Definition: action-base.hpp:305
crocoddyl::ActionDataAbstractTpl::Lx
VectorXs Lx
Jacobian of the cost w.r.t. the state .
Definition: action-base.hpp:379
crocoddyl::IntegratedActionModelAbstractTpl::time_step2_
Scalar time_step2_
Square of the time step used for integration.
Definition: integ-action-base.hpp:161
crocoddyl::IntegratedActionModelAbstractTpl::time_step_
Scalar time_step_
Time step used for integration.
Definition: integ-action-base.hpp:160
crocoddyl::ActionDataAbstractTpl::xnext
VectorXs xnext
evolution state
Definition: action-base.hpp:374
crocoddyl::IntegratedActionModelAbstractTpl::IntegratedActionModelAbstractTpl
IntegratedActionModelAbstractTpl(boost::shared_ptr< DifferentialActionModelAbstract > model, boost::shared_ptr< ControlParametrizationModelAbstract > control, const Scalar time_step=Scalar(1e-3), const bool with_cost_residual=true)
Initialize the integrator.
crocoddyl::ActionDataAbstractTpl::cost
Scalar cost
cost value
Definition: action-base.hpp:373
crocoddyl::IntegratedActionModelAbstractTpl::get_g_lb
virtual const VectorXs & get_g_lb() const
Return the lower bound of the inequality constraints.
crocoddyl::ActionDataAbstractTpl::r
VectorXs r
Cost residual.
Definition: action-base.hpp:378
crocoddyl::ActionModelAbstractTpl::state_
boost::shared_ptr< StateAbstract > state_
Model of the state.
Definition: action-base.hpp:309
crocoddyl::ActionModelAbstractTpl::unone_
VectorXs unone_
Neutral state.
Definition: action-base.hpp:310
crocoddyl::IntegratedActionModelAbstractTpl::control_
boost::shared_ptr< ControlParametrizationModelAbstract > control_
Model of the control parametrization.
Definition: integ-action-base.hpp:158
crocoddyl::IntegratedActionModelAbstractTpl::get_ng
virtual std::size_t get_ng() const
Return the number of inequality constraints.
crocoddyl::ActionDataAbstractTpl::Fx
MatrixXs Fx
Jacobian of the dynamics w.r.t. the state .
Definition: action-base.hpp:375
crocoddyl::IntegratedActionModelAbstractTpl::get_g_ub
virtual const VectorXs & get_g_ub() const
Return the upper bound of the inequality constraints.
crocoddyl::ActionModelAbstractTpl::u_lb_
VectorXs u_lb_
Lower control limits.
Definition: action-base.hpp:313
crocoddyl::ActionModelAbstractTpl::u_ub_
VectorXs u_ub_
Upper control limits.
Definition: action-base.hpp:314
crocoddyl::IntegratedActionModelAbstractTpl::get_differential
const boost::shared_ptr< DifferentialActionModelAbstract > & get_differential() const
Return the differential action model associated to this integrated action model.
crocoddyl::IntegratedActionModelAbstractTpl::get_control
const boost::shared_ptr< ControlParametrizationModelAbstract > & get_control() const
Return the control parametrization model associated to this integrated action model.
crocoddyl::ActionDataAbstractTpl::Lu
VectorXs Lu
Jacobian of the cost w.r.t. the control .
Definition: action-base.hpp:380
crocoddyl::IntegratedActionModelAbstractTpl::init
void init()
< Neutral state
crocoddyl::ActionDataAbstractTpl::Lxx
MatrixXs Lxx
Hessian of the cost w.r.t. the state .
Definition: action-base.hpp:381
crocoddyl::ActionDataAbstractTpl::Fu
MatrixXs Fu
Jacobian of the dynamics w.r.t. the control .
Definition: action-base.hpp:377
crocoddyl::IntegratedActionModelAbstractTpl::get_dt
const Scalar get_dt() const
Return the time step used for the integration.
crocoddyl::ActionModelAbstractTpl::nr_
std::size_t nr_
Dimension of the cost residual.
Definition: action-base.hpp:306
crocoddyl::IntegratedActionDataAbstractTpl
Definition: fwd.hpp:59
crocoddyl::ActionDataAbstractTpl::Luu
MatrixXs Luu
Hessian of the cost w.r.t. the control .
Definition: action-base.hpp:384