crocoddyl  1.8.0
Contact RObot COntrol by Differential DYnamic programming Library (Crocoddyl)
unicycle.hpp
1 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2021, LAAS-CNRS, University of Edinburgh
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
8 
9 #ifndef CROCODDYL_CORE_ACTIONS_UNICYCLE_HPP_
10 #define CROCODDYL_CORE_ACTIONS_UNICYCLE_HPP_
11 
12 #include <stdexcept>
13 
14 #include "crocoddyl/core/fwd.hpp"
15 #include "crocoddyl/core/action-base.hpp"
16 #include "crocoddyl/core/states/euclidean.hpp"
17 
18 namespace crocoddyl {
19 template <typename _Scalar>
21  public:
22  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
23 
24  typedef _Scalar Scalar;
29  typedef typename MathBase::VectorXs VectorXs;
30  typedef typename MathBase::Vector2s Vector2s;
31 
33  virtual ~ActionModelUnicycleTpl();
34 
35  virtual void calc(const boost::shared_ptr<ActionDataAbstract>& data, const Eigen::Ref<const VectorXs>& x,
36  const Eigen::Ref<const VectorXs>& u);
37  virtual void calcDiff(const boost::shared_ptr<ActionDataAbstract>& data, const Eigen::Ref<const VectorXs>& x,
38  const Eigen::Ref<const VectorXs>& u);
39  virtual boost::shared_ptr<ActionDataAbstract> createData();
40  virtual bool checkData(const boost::shared_ptr<ActionDataAbstract>& data);
41 
42  const Vector2s& get_cost_weights() const;
43  void set_cost_weights(const Vector2s& weights);
44 
45  Scalar get_dt() const;
46  void set_dt(const Scalar dt);
47 
53  virtual void print(std::ostream& os) const;
54 
55  protected:
56  using Base::nu_;
57  using Base::state_;
58 
59  private:
60  Vector2s cost_weights_;
61  Scalar dt_;
62 };
63 
64 template <typename _Scalar>
65 struct ActionDataUnicycleTpl : public ActionDataAbstractTpl<_Scalar> {
66  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
67 
68  typedef _Scalar Scalar;
71  using Base::cost;
72  using Base::Fu;
73  using Base::Fx;
74  using Base::Lu;
75  using Base::Luu;
76  using Base::Lx;
77  using Base::Lxu;
78  using Base::Lxx;
79  using Base::r;
80  using Base::xnext;
81 
82  template <template <typename Scalar> class Model>
83  explicit ActionDataUnicycleTpl(Model<Scalar>* const model) : Base(model) {
84  Fx.diagonal().array() = Scalar(1.);
85  }
86 };
87 
88 } // namespace crocoddyl
89 
90 /* --- Details -------------------------------------------------------------- */
91 /* --- Details -------------------------------------------------------------- */
92 /* --- Details -------------------------------------------------------------- */
93 #include "crocoddyl/core/actions/unicycle.hxx"
94 
95 #endif // CROCODDYL_CORE_ACTIONS_UNICYCLE_HPP_
Abstract class for action model.
Definition: action-base.hpp:60
std::size_t nu_
Control dimension.
virtual void print(std::ostream &os) const
Print relevant information of the unicycle model.
virtual boost::shared_ptr< ActionDataAbstract > createData()
Create the action data.
virtual bool checkData(const boost::shared_ptr< ActionDataAbstract > &data)
Checks that a specific data belongs to this model.
boost::shared_ptr< StateAbstract > state_
Model of the state.