Crocoddyl
integ-action-base.hpp
1 // BSD 3-Clause License
3 //
4 // Copyright (C) 2021-2025, 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>
42  : public ActionModelAbstractTpl<_Scalar> {
43  public:
44  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
45 
46  typedef _Scalar Scalar;
55  typedef typename MathBase::VectorXs VectorXs;
56  typedef typename MathBase::MatrixXs MatrixXs;
57 
67  std::shared_ptr<DifferentialActionModelAbstract> model,
68  std::shared_ptr<ControlParametrizationModelAbstract> control,
69  const Scalar time_step = Scalar(1e-3),
70  const bool with_cost_residual = true);
71 
83  std::shared_ptr<DifferentialActionModelAbstract> model,
84  const Scalar time_step = Scalar(1e-3),
85  const bool with_cost_residual = true);
86  virtual ~IntegratedActionModelAbstractTpl() = default;
87 
93  virtual std::shared_ptr<ActionDataAbstract> createData() override;
94 
98  virtual std::size_t get_ng() const override;
99 
103  virtual std::size_t get_nh() const override;
104 
108  virtual std::size_t get_ng_T() const override;
109 
113  virtual std::size_t get_nh_T() const override;
114 
118  virtual const VectorXs& get_g_lb() const override;
119 
123  virtual const VectorXs& get_g_ub() const override;
124 
129  const std::shared_ptr<DifferentialActionModelAbstract>& get_differential()
130  const;
131 
136  const std::shared_ptr<ControlParametrizationModelAbstract>& get_control()
137  const;
138 
142  const Scalar get_dt() const;
143 
147  void set_dt(const Scalar dt);
148 
149  DEPRECATED("The DifferentialActionModel should be set at construction time",
150  void set_differential(
151  std::shared_ptr<DifferentialActionModelAbstract> model));
152 
153  protected:
156  using Base::nr_;
157  using Base::nu_;
158  using Base::state_;
159  using Base::u_lb_;
160  using Base::u_ub_;
161 
163  : differential_(nullptr),
164  control_(nullptr),
165  time_step_(0),
166  time_step2_(0),
167  with_cost_residual_(false) {}
168  void init();
169 
170  std::shared_ptr<DifferentialActionModelAbstract>
172  std::shared_ptr<ControlParametrizationModelAbstract>
174 
175  Scalar time_step_;
176  Scalar time_step2_;
177  bool
179 };
180 
181 template <typename _Scalar>
183  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
184 
185  typedef _Scalar Scalar;
188  typedef typename MathBase::VectorXs VectorXs;
189  typedef typename MathBase::MatrixXs MatrixXs;
190 
191  template <template <typename Scalar> class Model>
192  explicit IntegratedActionDataAbstractTpl(Model<Scalar>* const model)
193  : Base(model) {}
194  virtual ~IntegratedActionDataAbstractTpl() = default;
195 
196  using Base::cost;
197  using Base::Fu;
198  using Base::Fx;
199  using Base::Lu;
200  using Base::Luu;
201  using Base::Lx;
202  using Base::Lxu;
203  using Base::Lxx;
204  using Base::r;
205  using Base::xnext;
206 };
207 
208 } // namespace crocoddyl
209 
210 /* --- Details -------------------------------------------------------------- */
211 /* --- Details -------------------------------------------------------------- */
212 /* --- Details -------------------------------------------------------------- */
213 #include "crocoddyl/core/integ-action-base.hxx"
214 
215 CROCODDYL_DECLARE_EXTERN_TEMPLATE_CLASS(
217 CROCODDYL_DECLARE_EXTERN_TEMPLATE_STRUCT(
219 
220 #endif // CROCODDYL_CORE_INTEGRATED_ACTION_BASE_HPP_
Abstract class for action model.
Definition: action-base.hpp:97
std::shared_ptr< StateAbstract > state_
Model of the state.
VectorXs u_lb_
Lower control limits.
VectorXs u_ub_
Upper control limits.
std::size_t nu_
Control dimension.
std::size_t nr_
Dimension of the cost residual.
Abstract class for the control trajectory parametrization.
Abstract class for differential action model.
Abstract class for an integrated action model.
const Scalar get_dt() const
Return the time step used for the integration.
bool with_cost_residual_
Flag indicating whether a cost residual is used.
const std::shared_ptr< DifferentialActionModelAbstract > & get_differential() const
Return the differential action model associated to this integrated action model.
const std::shared_ptr< ControlParametrizationModelAbstract > & get_control() const
Return the control parametrization model associated to this integrated action model.
Scalar time_step_
Time step used for integration.
virtual std::shared_ptr< ActionDataAbstract > createData() override
Create the integrator data.
IntegratedActionModelAbstractTpl()
< Upper control limits
void set_dt(const Scalar dt)
Set the time step for the integration.
virtual std::size_t get_ng() const override
Return the number of inequality constraints.
std::shared_ptr< ControlParametrizationModelAbstract > control_
Model of the control parametrization.
virtual const VectorXs & get_g_ub() const override
Return the upper bound of the inequality constraints.
virtual std::size_t get_nh_T() const override
Return the number of equality terminal constraints.
virtual std::size_t get_nh() const override
Return the number of equality constraints.
std::shared_ptr< DifferentialActionModelAbstract > differential_
Differential action model that is integrated.
virtual std::size_t get_ng_T() const override
Return the number of inequality terminal constraints.
IntegratedActionModelAbstractTpl(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 integrator.
Scalar time_step2_
Square of the time step used for integration.
IntegratedActionModelAbstractTpl(std::shared_ptr< DifferentialActionModelAbstract > model, const Scalar time_step=Scalar(1e-3), const bool with_cost_residual=true)
Initialize the integrator.
virtual const VectorXs & get_g_lb() const override
Return the lower bound of the inequality constraints.
VectorXs xnext
evolution state
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 .
VectorXs r
Cost residual.