1 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// 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. |
7 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
8 |
|
|
|
9 |
|
|
#ifndef CROCODDYL_CORE_ACTIONS_UNICYCLE_HPP_ |
10 |
|
|
#define CROCODDYL_CORE_ACTIONS_UNICYCLE_HPP_ |
11 |
|
|
|
12 |
|
|
#include <stdexcept> |
13 |
|
|
|
14 |
|
|
#include "crocoddyl/core/action-base.hpp" |
15 |
|
|
#include "crocoddyl/core/fwd.hpp" |
16 |
|
|
#include "crocoddyl/core/states/euclidean.hpp" |
17 |
|
|
|
18 |
|
|
namespace crocoddyl { |
19 |
|
|
template <typename _Scalar> |
20 |
|
|
class ActionModelUnicycleTpl : public ActionModelAbstractTpl<_Scalar> { |
21 |
|
|
public: |
22 |
|
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW |
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(); |
34 |
|
|
|
35 |
|
|
virtual void calc(const boost::shared_ptr<ActionDataAbstract>& data, |
36 |
|
|
const Eigen::Ref<const VectorXs>& x, |
37 |
|
|
const Eigen::Ref<const VectorXs>& u); |
38 |
|
|
virtual void calc(const boost::shared_ptr<ActionDataAbstract>& data, |
39 |
|
|
const Eigen::Ref<const VectorXs>& x); |
40 |
|
|
virtual void calcDiff(const boost::shared_ptr<ActionDataAbstract>& data, |
41 |
|
|
const Eigen::Ref<const VectorXs>& x, |
42 |
|
|
const Eigen::Ref<const VectorXs>& u); |
43 |
|
|
virtual void calcDiff(const boost::shared_ptr<ActionDataAbstract>& data, |
44 |
|
|
const Eigen::Ref<const VectorXs>& x); |
45 |
|
|
virtual boost::shared_ptr<ActionDataAbstract> createData(); |
46 |
|
|
virtual bool checkData(const boost::shared_ptr<ActionDataAbstract>& data); |
47 |
|
|
|
48 |
|
|
const Vector2s& get_cost_weights() const; |
49 |
|
|
void set_cost_weights(const Vector2s& weights); |
50 |
|
|
|
51 |
|
|
Scalar get_dt() const; |
52 |
|
|
void set_dt(const Scalar dt); |
53 |
|
|
|
54 |
|
|
/** |
55 |
|
|
* @brief Print relevant information of the unicycle model |
56 |
|
|
* |
57 |
|
|
* @param[out] os Output stream object |
58 |
|
|
*/ |
59 |
|
|
virtual void print(std::ostream& os) const; |
60 |
|
|
|
61 |
|
|
protected: |
62 |
|
|
using Base::nu_; //!< Control dimension |
63 |
|
|
using Base::state_; //!< Model of the state |
64 |
|
|
|
65 |
|
|
private: |
66 |
|
|
Vector2s cost_weights_; |
67 |
|
|
Scalar dt_; |
68 |
|
|
}; |
69 |
|
|
|
70 |
|
|
template <typename _Scalar> |
71 |
|
|
struct ActionDataUnicycleTpl : public ActionDataAbstractTpl<_Scalar> { |
72 |
|
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW |
73 |
|
|
|
74 |
|
|
typedef _Scalar Scalar; |
75 |
|
|
typedef MathBaseTpl<Scalar> MathBase; |
76 |
|
|
typedef ActionDataAbstractTpl<Scalar> Base; |
77 |
|
|
using Base::cost; |
78 |
|
|
using Base::Fu; |
79 |
|
|
using Base::Fx; |
80 |
|
|
using Base::Lu; |
81 |
|
|
using Base::Luu; |
82 |
|
|
using Base::Lx; |
83 |
|
|
using Base::Lxu; |
84 |
|
|
using Base::Lxx; |
85 |
|
|
using Base::r; |
86 |
|
|
using Base::xnext; |
87 |
|
|
|
88 |
|
|
template <template <typename Scalar> class Model> |
89 |
|
983 |
explicit ActionDataUnicycleTpl(Model<Scalar>* const model) : Base(model) { |
90 |
✓✗✓✗ ✓✗ |
983 |
Fx.diagonal().array() = Scalar(1.); |
91 |
|
983 |
} |
92 |
|
|
}; |
93 |
|
|
|
94 |
|
|
} // namespace crocoddyl |
95 |
|
|
|
96 |
|
|
/* --- Details -------------------------------------------------------------- */ |
97 |
|
|
/* --- Details -------------------------------------------------------------- */ |
98 |
|
|
/* --- Details -------------------------------------------------------------- */ |
99 |
|
|
#include "crocoddyl/core/actions/unicycle.hxx" |
100 |
|
|
|
101 |
|
|
#endif // CROCODDYL_CORE_ACTIONS_UNICYCLE_HPP_ |