crocoddyl  1.5.0
Contact RObot COntrol by Differential DYnamic programming Library (Crocoddyl)
unicycle.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_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  protected:
47  using Base::nr_;
48  using Base::nu_;
49  using Base::state_;
50  using Base::u_lb_;
51  using Base::u_ub_;
52  using Base::unone_;
53 
54  private:
55  Vector2s cost_weights_;
56  Scalar dt_;
57 };
58 
59 template <typename _Scalar>
60 struct ActionDataUnicycleTpl : public ActionDataAbstractTpl<_Scalar> {
61  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
62 
63  typedef _Scalar Scalar;
66  using Base::cost;
67  using Base::Fu;
68  using Base::Fx;
69  using Base::Lu;
70  using Base::Luu;
71  using Base::Lx;
72  using Base::Lxu;
73  using Base::Lxx;
74  using Base::r;
75  using Base::xnext;
76 
77  template <template <typename Scalar> class Model>
78  explicit ActionDataUnicycleTpl(Model<Scalar>* const model) : Base(model) {
79  Fx.diagonal().array() = Scalar(1.);
80  }
81 };
82 
83 } // namespace crocoddyl
84 
85 /* --- Details -------------------------------------------------------------- */
86 /* --- Details -------------------------------------------------------------- */
87 /* --- Details -------------------------------------------------------------- */
88 #include "crocoddyl/core/actions/unicycle.hxx"
89 
90 #endif // CROCODDYL_CORE_ACTIONS_UNICYCLE_HPP_
bool has_control_limits_
Indicates whether any of the control limits is finite.
Definition: action-base.hpp:96
std::size_t nu_
Control dimension.
Definition: action-base.hpp:90
VectorXs unone_
Neutral state.
Definition: action-base.hpp:93
VectorXs u_ub_
Upper control limits.
Definition: action-base.hpp:95
VectorXs u_lb_
Lower control limits.
Definition: action-base.hpp:94
boost::shared_ptr< StateAbstract > state_
Model of the state.
Definition: action-base.hpp:92
std::size_t nr_
Dimension of the cost residual.
Definition: action-base.hpp:91