Line |
Branch |
Exec |
Source |
1 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// BSD 3-Clause License |
3 |
|
|
// |
4 |
|
|
// Copyright (C) 2019-2025, LAAS-CNRS, University of Edinburgh, |
5 |
|
|
// Heriot-Watt University |
6 |
|
|
// Copyright note valid unless otherwise stated in individual files. |
7 |
|
|
// All rights reserved. |
8 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
9 |
|
|
|
10 |
|
|
#ifndef CROCODDYL_CORE_ACTIONS_UNICYCLE_HPP_ |
11 |
|
|
#define CROCODDYL_CORE_ACTIONS_UNICYCLE_HPP_ |
12 |
|
|
|
13 |
|
|
#include "crocoddyl/core/action-base.hpp" |
14 |
|
|
#include "crocoddyl/core/fwd.hpp" |
15 |
|
|
#include "crocoddyl/core/states/euclidean.hpp" |
16 |
|
|
|
17 |
|
|
namespace crocoddyl { |
18 |
|
|
template <typename _Scalar> |
19 |
|
|
class ActionModelUnicycleTpl : public ActionModelAbstractTpl<_Scalar> { |
20 |
|
|
public: |
21 |
|
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW |
22 |
|
✗ |
CROCODDYL_DERIVED_CAST(ActionModelBase, ActionModelUnicycleTpl) |
23 |
|
|
|
24 |
|
|
typedef _Scalar Scalar; |
25 |
|
|
typedef ActionDataAbstractTpl<Scalar> ActionDataAbstract; |
26 |
|
|
typedef ActionModelAbstractTpl<Scalar> Base; |
27 |
|
|
typedef ActionDataUnicycleTpl<Scalar> Data; |
28 |
|
|
typedef MathBaseTpl<Scalar> MathBase; |
29 |
|
|
typedef typename MathBase::VectorXs VectorXs; |
30 |
|
|
typedef typename MathBase::Vector2s Vector2s; |
31 |
|
|
|
32 |
|
|
ActionModelUnicycleTpl(); |
33 |
|
✗ |
virtual ~ActionModelUnicycleTpl() = default; |
34 |
|
|
|
35 |
|
|
virtual void calc(const std::shared_ptr<ActionDataAbstract>& data, |
36 |
|
|
const Eigen::Ref<const VectorXs>& x, |
37 |
|
|
const Eigen::Ref<const VectorXs>& u) override; |
38 |
|
|
virtual void calc(const std::shared_ptr<ActionDataAbstract>& data, |
39 |
|
|
const Eigen::Ref<const VectorXs>& x) override; |
40 |
|
|
virtual void calcDiff(const std::shared_ptr<ActionDataAbstract>& data, |
41 |
|
|
const Eigen::Ref<const VectorXs>& x, |
42 |
|
|
const Eigen::Ref<const VectorXs>& u) override; |
43 |
|
|
virtual void calcDiff(const std::shared_ptr<ActionDataAbstract>& data, |
44 |
|
|
const Eigen::Ref<const VectorXs>& x) override; |
45 |
|
|
virtual std::shared_ptr<ActionDataAbstract> createData() override; |
46 |
|
|
|
47 |
|
|
/** |
48 |
|
|
* @brief Cast the unicycle model to a different scalar type. |
49 |
|
|
* |
50 |
|
|
* It is useful for operations requiring different precision or scalar types. |
51 |
|
|
* |
52 |
|
|
* @tparam NewScalar The new scalar type to cast to. |
53 |
|
|
* @return ActionModelUnicycleTpl<NewScalar> A unicycle model with the |
54 |
|
|
* new scalar type. |
55 |
|
|
*/ |
56 |
|
|
template <typename NewScalar> |
57 |
|
|
ActionModelUnicycleTpl<NewScalar> cast() const; |
58 |
|
|
|
59 |
|
|
virtual bool checkData( |
60 |
|
|
const std::shared_ptr<ActionDataAbstract>& data) override; |
61 |
|
|
|
62 |
|
|
const Vector2s& get_cost_weights() const; |
63 |
|
|
void set_cost_weights(const Vector2s& weights); |
64 |
|
|
|
65 |
|
|
Scalar get_dt() const; |
66 |
|
|
void set_dt(const Scalar dt); |
67 |
|
|
|
68 |
|
|
/** |
69 |
|
|
* @brief Print relevant information of the unicycle model |
70 |
|
|
* |
71 |
|
|
* @param[out] os Output stream object |
72 |
|
|
*/ |
73 |
|
|
virtual void print(std::ostream& os) const override; |
74 |
|
|
|
75 |
|
|
protected: |
76 |
|
|
using Base::nu_; //!< Control dimension |
77 |
|
|
using Base::state_; //!< Model of the state |
78 |
|
|
|
79 |
|
|
private: |
80 |
|
|
Vector2s cost_weights_; |
81 |
|
|
Scalar dt_; |
82 |
|
|
}; |
83 |
|
|
|
84 |
|
|
template <typename _Scalar> |
85 |
|
|
struct ActionDataUnicycleTpl : public ActionDataAbstractTpl<_Scalar> { |
86 |
|
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW |
87 |
|
|
|
88 |
|
|
typedef _Scalar Scalar; |
89 |
|
|
typedef MathBaseTpl<Scalar> MathBase; |
90 |
|
|
typedef ActionDataAbstractTpl<Scalar> Base; |
91 |
|
|
using Base::cost; |
92 |
|
|
using Base::Fu; |
93 |
|
|
using Base::Fx; |
94 |
|
|
using Base::Lu; |
95 |
|
|
using Base::Luu; |
96 |
|
|
using Base::Lx; |
97 |
|
|
using Base::Lxu; |
98 |
|
|
using Base::Lxx; |
99 |
|
|
using Base::r; |
100 |
|
|
using Base::xnext; |
101 |
|
|
|
102 |
|
|
template <template <typename Scalar> class Model> |
103 |
|
✗ |
explicit ActionDataUnicycleTpl(Model<Scalar>* const model) : Base(model) { |
104 |
|
✗ |
Fx.diagonal().array() = Scalar(1.); |
105 |
|
|
} |
106 |
|
✗ |
virtual ~ActionDataUnicycleTpl() = default; |
107 |
|
|
}; |
108 |
|
|
|
109 |
|
|
} // namespace crocoddyl |
110 |
|
|
|
111 |
|
|
/* --- Details -------------------------------------------------------------- */ |
112 |
|
|
/* --- Details -------------------------------------------------------------- */ |
113 |
|
|
/* --- Details -------------------------------------------------------------- */ |
114 |
|
|
#include "crocoddyl/core/actions/unicycle.hxx" |
115 |
|
|
|
116 |
|
|
CROCODDYL_DECLARE_EXTERN_TEMPLATE_CLASS(crocoddyl::ActionModelUnicycleTpl) |
117 |
|
|
CROCODDYL_DECLARE_EXTERN_TEMPLATE_STRUCT(crocoddyl::ActionDataUnicycleTpl) |
118 |
|
|
|
119 |
|
|
#endif // CROCODDYL_CORE_ACTIONS_UNICYCLE_HPP_ |
120 |
|
|
|