Directory: | ./ |
---|---|
File: | include/crocoddyl/core/action-base.hpp |
Date: | 2025-03-26 19:23:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 46 | 49 | 93.9% |
Branches: | 86 | 186 | 46.2% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | ||
2 | // BSD 3-Clause License | ||
3 | // | ||
4 | // Copyright (C) 2019-2025, LAAS-CNRS, University of Edinburgh, | ||
5 | // University of Oxford, Heriot-Watt University | ||
6 | // Copyright note valid unless otherwise stated in individual files. | ||
7 | // All rights reserved. | ||
8 | /////////////////////////////////////////////////////////////////////////////// | ||
9 | |||
10 | #ifndef CROCODDYL_CORE_ACTION_BASE_HPP_ | ||
11 | #define CROCODDYL_CORE_ACTION_BASE_HPP_ | ||
12 | |||
13 | #include <memory> | ||
14 | #include <stdexcept> | ||
15 | |||
16 | #include "crocoddyl/core/fwd.hpp" | ||
17 | #include "crocoddyl/core/state-base.hpp" | ||
18 | |||
19 | namespace crocoddyl { | ||
20 | |||
21 | class ActionModelBase { | ||
22 | public: | ||
23 | 3404 | virtual ~ActionModelBase() = default; | |
24 | |||
25 | ✗ | CROCODDYL_BASE_CAST(ActionModelBase, ActionModelAbstractTpl) | |
26 | }; | ||
27 | |||
28 | /** | ||
29 | * @brief Abstract class for action model | ||
30 | * | ||
31 | * An action model combines dynamics, cost functions and constraints. Each node, | ||
32 | * in our optimal control problem, is described through an action model. Every | ||
33 | * time that we want describe a problem, we need to provide ways of computing | ||
34 | * the dynamics, cost functions, constraints and their derivatives. All these is | ||
35 | * described inside the action model. | ||
36 | * | ||
37 | * Concretely speaking, the action model describes a time-discrete action model | ||
38 | * with a first-order ODE along a cost function, i.e. | ||
39 | * - the state \f$\mathbf{z}\in\mathcal{Z}\f$ lies in a manifold described with | ||
40 | * a `nx`-tuple, | ||
41 | * - the state rate \f$\mathbf{\dot{x}}\in T_{\mathbf{q}}\mathcal{Q}\f$ is the | ||
42 | * tangent vector to the state manifold with `ndx` dimension, | ||
43 | * - the control input \f$\mathbf{u}\in\mathbb{R}^{nu}\f$ is an Euclidean | ||
44 | * vector | ||
45 | * - \f$\mathbf{r}(\cdot)\f$ and \f$a(\cdot)\f$ are the residual and activation | ||
46 | * functions (see `ResidualModelAbstractTpl` and `ActivationModelAbstractTpl`, | ||
47 | * respetively), | ||
48 | * - \f$\mathbf{g}(\cdot)\in\mathbb{R}^{ng}\f$ and | ||
49 | * \f$\mathbf{h}(\cdot)\in\mathbb{R}^{nh}\f$ are the inequality and equality | ||
50 | * vector functions, respectively. | ||
51 | * | ||
52 | * The computation of these equations are carried out out inside `calc()` | ||
53 | * function. In short, this function computes the system acceleration, cost and | ||
54 | * constraints values (also called constraints violations). This procedure is | ||
55 | * equivalent to running a forward pass of the action model. | ||
56 | * | ||
57 | * However, during numerical optimization, we also need to run backward passes | ||
58 | * of the action model. These calculations are performed by `calcDiff()`. In | ||
59 | * short, this method builds a linear-quadratic approximation of the action | ||
60 | * model, i.e.: \f[ \begin{aligned} | ||
61 | * &\delta\mathbf{x}_{k+1} = | ||
62 | * \mathbf{f_x}\delta\mathbf{x}_k+\mathbf{f_u}\delta\mathbf{u}_k, | ||
63 | * &\textrm{(dynamics)}\\ | ||
64 | * &\ell(\delta\mathbf{x}_k,\delta\mathbf{u}_k) = \begin{bmatrix}1 | ||
65 | * \\ \delta\mathbf{x}_k \\ \delta\mathbf{u}_k\end{bmatrix}^T \begin{bmatrix}0 & | ||
66 | * \mathbf{\ell_x}^T & \mathbf{\ell_u}^T \\ \mathbf{\ell_x} & \mathbf{\ell_{xx}} | ||
67 | * & | ||
68 | * \mathbf{\ell_{ux}}^T \\ | ||
69 | * \mathbf{\ell_u} & \mathbf{\ell_{ux}} & \mathbf{\ell_{uu}}\end{bmatrix} | ||
70 | * \begin{bmatrix}1 \\ \delta\mathbf{x}_k \\ | ||
71 | * \delta\mathbf{u}_k\end{bmatrix}, &\textrm{(cost)}\\ | ||
72 | * &\mathbf{g}(\delta\mathbf{x}_k,\delta\mathbf{u}_k)<\mathbf{0}, | ||
73 | * &\textrm{(inequality constraint)}\\ | ||
74 | * &\mathbf{h}(\delta\mathbf{x}_k,\delta\mathbf{u}_k)=\mathbf{0}, | ||
75 | * &\textrm{(equality constraint)} \end{aligned} \f] where | ||
76 | * - \f$\mathbf{f_x}\in\mathbb{R}^{ndx\times ndx}\f$ and | ||
77 | * \f$\mathbf{f_u}\in\mathbb{R}^{ndx\times nu}\f$ are the Jacobians of the | ||
78 | * dynamics, | ||
79 | * - \f$\mathbf{\ell_x}\in\mathbb{R}^{ndx}\f$ and | ||
80 | * \f$\mathbf{\ell_u}\in\mathbb{R}^{nu}\f$ are the Jacobians of the cost | ||
81 | * function, | ||
82 | * - \f$\mathbf{\ell_{xx}}\in\mathbb{R}^{ndx\times ndx}\f$, | ||
83 | * \f$\mathbf{\ell_{xu}}\in\mathbb{R}^{ndx\times nu}\f$ and | ||
84 | * \f$\mathbf{\ell_{uu}}\in\mathbb{R}^{nu\times nu}\f$ are the Hessians of the | ||
85 | * cost function, | ||
86 | * - \f$\mathbf{g_x}\in\mathbb{R}^{ng\times ndx}\f$ and | ||
87 | * \f$\mathbf{g_u}\in\mathbb{R}^{ng\times nu}\f$ are the Jacobians of the | ||
88 | * inequality constraints, and | ||
89 | * - \f$\mathbf{h_x}\in\mathbb{R}^{nh\times ndx}\f$ and | ||
90 | * \f$\mathbf{h_u}\in\mathbb{R}^{nh\times nu}\f$ are the Jacobians of the | ||
91 | * equality constraints. | ||
92 | * | ||
93 | * Additionally, it is important to note that `calcDiff()` computes the | ||
94 | * derivatives using the latest stored values by `calc()`. Thus, we need to | ||
95 | * first run `calc()`. | ||
96 | * | ||
97 | * \sa `calc()`, `calcDiff()`, `createData()` | ||
98 | */ | ||
99 | template <typename _Scalar> | ||
100 | class ActionModelAbstractTpl : public ActionModelBase { | ||
101 | public: | ||
102 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW | ||
103 | |||
104 | typedef _Scalar Scalar; | ||
105 | typedef typename ScalarSelector<Scalar>::type ScalarType; | ||
106 | typedef MathBaseTpl<Scalar> MathBase; | ||
107 | typedef ActionDataAbstractTpl<Scalar> ActionDataAbstract; | ||
108 | typedef StateAbstractTpl<Scalar> StateAbstract; | ||
109 | typedef typename MathBase::VectorXs VectorXs; | ||
110 | |||
111 | /** | ||
112 | * @brief Initialize the action model | ||
113 | * | ||
114 | * @param[in] state State description | ||
115 | * @param[in] nu Dimension of control vector | ||
116 | * @param[in] nr Dimension of cost-residual vector | ||
117 | * @param[in] ng Number of inequality constraints (default 0) | ||
118 | * @param[in] nh Number of equality constraints (default 0) | ||
119 | * @param[in] ng_T Number of inequality terminal constraints (default 0) | ||
120 | * @param[in] nh_T Number of equality terminal constraints (default 0) | ||
121 | */ | ||
122 | ActionModelAbstractTpl(std::shared_ptr<StateAbstract> state, | ||
123 | const std::size_t nu, const std::size_t nr = 0, | ||
124 | const std::size_t ng = 0, const std::size_t nh = 0, | ||
125 | const std::size_t ng_T = 0, | ||
126 | const std::size_t nh_T = 0); | ||
127 | /** | ||
128 | * @brief Copy constructor | ||
129 | * @param other Action model to be copied | ||
130 | */ | ||
131 | ActionModelAbstractTpl(const ActionModelAbstractTpl<Scalar>& other); | ||
132 | |||
133 | 3404 | virtual ~ActionModelAbstractTpl() = default; | |
134 | |||
135 | /** | ||
136 | * @brief Compute the next state and cost value | ||
137 | * | ||
138 | * @param[in] data Action data | ||
139 | * @param[in] x State point \f$\mathbf{x}\in\mathbb{R}^{ndx}\f$ | ||
140 | * @param[in] u Control input \f$\mathbf{u}\in\mathbb{R}^{nu}\f$ | ||
141 | */ | ||
142 | virtual void calc(const std::shared_ptr<ActionDataAbstract>& data, | ||
143 | const Eigen::Ref<const VectorXs>& x, | ||
144 | const Eigen::Ref<const VectorXs>& u) = 0; | ||
145 | |||
146 | /** | ||
147 | * @brief Compute the total cost value for nodes that depends only on the | ||
148 | * state | ||
149 | * | ||
150 | * It updates the total cost and the next state is not computed as it is not | ||
151 | * expected to change. This function is used in the terminal nodes of an | ||
152 | * optimal control problem. | ||
153 | * | ||
154 | * @param[in] data Action data | ||
155 | * @param[in] x State point \f$\mathbf{x}\in\mathbb{R}^{ndx}\f$ | ||
156 | */ | ||
157 | virtual void calc(const std::shared_ptr<ActionDataAbstract>& data, | ||
158 | const Eigen::Ref<const VectorXs>& x); | ||
159 | |||
160 | /** | ||
161 | * @brief Compute the derivatives of the dynamics and cost functions | ||
162 | * | ||
163 | * It computes the partial derivatives of the dynamical system and the cost | ||
164 | * function. It assumes that `calc()` has been run first. This function builds | ||
165 | * a linear-quadratic approximation of the action model (i.e. dynamical system | ||
166 | * and cost function). | ||
167 | * | ||
168 | * @param[in] data Action data | ||
169 | * @param[in] x State point \f$\mathbf{x}\in\mathbb{R}^{ndx}\f$ | ||
170 | * @param[in] u Control input \f$\mathbf{u}\in\mathbb{R}^{nu}\f$ | ||
171 | */ | ||
172 | virtual void calcDiff(const std::shared_ptr<ActionDataAbstract>& data, | ||
173 | const Eigen::Ref<const VectorXs>& x, | ||
174 | const Eigen::Ref<const VectorXs>& u) = 0; | ||
175 | |||
176 | /** | ||
177 | * @brief Compute the derivatives of the cost functions with respect to the | ||
178 | * state only | ||
179 | * | ||
180 | * It updates the derivatives of the cost function with respect to the state | ||
181 | * only. This function is used in the terminal nodes of an optimal control | ||
182 | * problem. | ||
183 | * | ||
184 | * @param[in] data Action data | ||
185 | * @param[in] x State point \f$\mathbf{x}\in\mathbb{R}^{ndx}\f$ | ||
186 | */ | ||
187 | virtual void calcDiff(const std::shared_ptr<ActionDataAbstract>& data, | ||
188 | const Eigen::Ref<const VectorXs>& x); | ||
189 | |||
190 | /** | ||
191 | * @brief Create the action data | ||
192 | * | ||
193 | * @return the action data | ||
194 | */ | ||
195 | virtual std::shared_ptr<ActionDataAbstract> createData(); | ||
196 | |||
197 | /** | ||
198 | * @brief Checks that a specific data belongs to this model | ||
199 | */ | ||
200 | virtual bool checkData(const std::shared_ptr<ActionDataAbstract>& data); | ||
201 | |||
202 | /** | ||
203 | * @brief Computes the quasic static commands | ||
204 | * | ||
205 | * The quasic static commands are the ones produced for a the reference | ||
206 | * posture as an equilibrium point, i.e. for | ||
207 | * \f$\mathbf{f^q_x}\delta\mathbf{q}+\mathbf{f_u}\delta\mathbf{u}=\mathbf{0}\f$ | ||
208 | * | ||
209 | * @param[in] data Action data | ||
210 | * @param[out] u Quasic static commands | ||
211 | * @param[in] x State point (velocity has to be zero) | ||
212 | * @param[in] maxiter Maximum allowed number of iterations | ||
213 | * @param[in] tol Tolerance | ||
214 | */ | ||
215 | virtual void quasiStatic(const std::shared_ptr<ActionDataAbstract>& data, | ||
216 | Eigen::Ref<VectorXs> u, | ||
217 | const Eigen::Ref<const VectorXs>& x, | ||
218 | const std::size_t maxiter = 100, | ||
219 | const Scalar tol = Scalar(1e-9)); | ||
220 | |||
221 | /** | ||
222 | * @copybrief quasicStatic() | ||
223 | * | ||
224 | * @copydetails quasicStatic() | ||
225 | * | ||
226 | * @param[in] data Action data | ||
227 | * @param[in] x State point (velocity has to be zero) | ||
228 | * @param[in] maxiter Maximum allowed number of iterations | ||
229 | * @param[in] tol Tolerance | ||
230 | * @return Quasic static commands | ||
231 | */ | ||
232 | VectorXs quasiStatic_x(const std::shared_ptr<ActionDataAbstract>& data, | ||
233 | const VectorXs& x, const std::size_t maxiter = 100, | ||
234 | const Scalar tol = Scalar(1e-9)); | ||
235 | |||
236 | /** | ||
237 | * @brief Return the dimension of the control input | ||
238 | */ | ||
239 | std::size_t get_nu() const; | ||
240 | |||
241 | /** | ||
242 | * @brief Return the dimension of the cost-residual vector | ||
243 | */ | ||
244 | std::size_t get_nr() const; | ||
245 | |||
246 | /** | ||
247 | * @brief Return the number of inequality constraints | ||
248 | */ | ||
249 | virtual std::size_t get_ng() const; | ||
250 | |||
251 | /** | ||
252 | * @brief Return the number of equality constraints | ||
253 | */ | ||
254 | virtual std::size_t get_nh() const; | ||
255 | |||
256 | /** | ||
257 | * @brief Return the number of inequality terminal constraints | ||
258 | */ | ||
259 | virtual std::size_t get_ng_T() const; | ||
260 | |||
261 | /** | ||
262 | * @brief Return the number of equality terminal constraints | ||
263 | */ | ||
264 | virtual std::size_t get_nh_T() const; | ||
265 | |||
266 | /** | ||
267 | * @brief Return the state | ||
268 | */ | ||
269 | const std::shared_ptr<StateAbstract>& get_state() const; | ||
270 | |||
271 | /** | ||
272 | * @brief Return the lower bound of the inequality constraints | ||
273 | */ | ||
274 | virtual const VectorXs& get_g_lb() const; | ||
275 | |||
276 | /** | ||
277 | * @brief Return the upper bound of the inequality constraints | ||
278 | */ | ||
279 | virtual const VectorXs& get_g_ub() const; | ||
280 | |||
281 | /** | ||
282 | * @brief Return the control lower bound | ||
283 | */ | ||
284 | const VectorXs& get_u_lb() const; | ||
285 | |||
286 | /** | ||
287 | * @brief Return the control upper bound | ||
288 | */ | ||
289 | const VectorXs& get_u_ub() const; | ||
290 | |||
291 | /** | ||
292 | * @brief Indicates if there are defined control limits | ||
293 | */ | ||
294 | bool get_has_control_limits() const; | ||
295 | |||
296 | /** | ||
297 | * @brief Modify the lower bound of the inequality constraints | ||
298 | */ | ||
299 | void set_g_lb(const VectorXs& g_lb); | ||
300 | |||
301 | /** | ||
302 | * @brief Modify the upper bound of the inequality constraints | ||
303 | */ | ||
304 | void set_g_ub(const VectorXs& g_ub); | ||
305 | |||
306 | /** | ||
307 | * @brief Modify the control lower bounds | ||
308 | */ | ||
309 | void set_u_lb(const VectorXs& u_lb); | ||
310 | |||
311 | /** | ||
312 | * @brief Modify the control upper bounds | ||
313 | */ | ||
314 | void set_u_ub(const VectorXs& u_ub); | ||
315 | |||
316 | /** | ||
317 | * @brief Print information on the action model | ||
318 | */ | ||
319 | template <class Scalar> | ||
320 | friend std::ostream& operator<<(std::ostream& os, | ||
321 | const ActionModelAbstractTpl<Scalar>& model); | ||
322 | |||
323 | /** | ||
324 | * @brief Print relevant information of the action model | ||
325 | * | ||
326 | * @param[out] os Output stream object | ||
327 | */ | ||
328 | virtual void print(std::ostream& os) const; | ||
329 | |||
330 | protected: | ||
331 | std::size_t nu_; //!< Control dimension | ||
332 | std::size_t nr_; //!< Dimension of the cost residual | ||
333 | std::size_t ng_; //!< Number of inequality constraints | ||
334 | std::size_t nh_; //!< Number of equality constraints | ||
335 | std::size_t ng_T_; //!< Number of inequality terminal constraints | ||
336 | std::size_t nh_T_; //!< Number of equality terminal constraints | ||
337 | std::shared_ptr<StateAbstract> state_; //!< Model of the state | ||
338 | VectorXs unone_; //!< Neutral state | ||
339 | VectorXs g_lb_; //!< Lower bound of the inequality constraints | ||
340 | VectorXs g_ub_; //!< Lower bound of the inequality constraints | ||
341 | VectorXs u_lb_; //!< Lower control limits | ||
342 | VectorXs u_ub_; //!< Upper control limits | ||
343 | bool has_control_limits_; //!< Indicates whether any of the control limits is | ||
344 | //!< finite | ||
345 | ✗ | ActionModelAbstractTpl() | |
346 | ✗ | : nu_(0), nr_(0), ng_(0), nh_(0), ng_T_(0), nh_T_(0), state_(nullptr) {} | |
347 | |||
348 | /** | ||
349 | * @brief Update the status of the control limits (i.e. if there are defined | ||
350 | * limits) | ||
351 | */ | ||
352 | void update_has_control_limits(); | ||
353 | |||
354 | template <class Scalar> | ||
355 | friend class ConstraintModelManagerTpl; | ||
356 | }; | ||
357 | |||
358 | template <typename _Scalar> | ||
359 | struct ActionDataAbstractTpl { | ||
360 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW | ||
361 | |||
362 | typedef _Scalar Scalar; | ||
363 | typedef MathBaseTpl<Scalar> MathBase; | ||
364 | typedef typename MathBase::VectorXs VectorXs; | ||
365 | typedef typename MathBase::MatrixXs MatrixXs; | ||
366 | |||
367 | template <template <typename Scalar> class Model> | ||
368 | 47742 | explicit ActionDataAbstractTpl(Model<Scalar>* const model) | |
369 | 47742 | : cost(Scalar(0.)), | |
370 |
1/2✓ Branch 3 taken 46501 times.
✗ Branch 4 not taken.
|
47742 | xnext(model->get_state()->get_nx()), |
371 |
5/10✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 46501 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 46501 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 46501 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 46501 times.
✗ Branch 16 not taken.
|
47742 | Fx(model->get_state()->get_ndx(), model->get_state()->get_ndx()), |
372 |
4/8✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 46501 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 46501 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 46501 times.
✗ Branch 12 not taken.
|
47742 | Fu(model->get_state()->get_ndx(), model->get_nu()), |
373 |
2/4✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 46501 times.
✗ Branch 5 not taken.
|
47742 | r(model->get_nr()), |
374 |
3/6✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 46501 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 46501 times.
✗ Branch 9 not taken.
|
47742 | Lx(model->get_state()->get_ndx()), |
375 |
2/4✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 46501 times.
✗ Branch 5 not taken.
|
47742 | Lu(model->get_nu()), |
376 |
5/10✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 46501 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 46501 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 46501 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 46501 times.
✗ Branch 16 not taken.
|
47742 | Lxx(model->get_state()->get_ndx(), model->get_state()->get_ndx()), |
377 |
4/8✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 46501 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 46501 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 46501 times.
✗ Branch 12 not taken.
|
47742 | Lxu(model->get_state()->get_ndx(), model->get_nu()), |
378 |
3/6✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 46501 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 46501 times.
✗ Branch 8 not taken.
|
47742 | Luu(model->get_nu(), model->get_nu()), |
379 |
4/10✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 46501 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 46501 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 12 taken 46501 times.
✗ Branch 13 not taken.
|
95484 | g(model->get_ng() > model->get_ng_T() ? model->get_ng() |
380 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | : model->get_ng_T()), |
381 |
3/8✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 46501 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 9 taken 46501 times.
✗ Branch 10 not taken.
|
95484 | Gx(model->get_ng() > model->get_ng_T() ? model->get_ng() |
382 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | : model->get_ng_T(), |
383 |
3/6✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 46501 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 46501 times.
✗ Branch 9 not taken.
|
47742 | model->get_state()->get_ndx()), |
384 |
3/8✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 46501 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 9 taken 46501 times.
✗ Branch 10 not taken.
|
95484 | Gu(model->get_ng() > model->get_ng_T() ? model->get_ng() |
385 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | : model->get_ng_T(), |
386 |
2/4✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 46501 times.
✗ Branch 5 not taken.
|
47742 | model->get_nu()), |
387 |
6/10✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 46501 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12667 times.
✓ Branch 7 taken 33834 times.
✓ Branch 9 taken 12667 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 46501 times.
✗ Branch 13 not taken.
|
82817 | h(model->get_nh() > model->get_nh_T() ? model->get_nh() |
388 |
1/2✓ Branch 1 taken 33834 times.
✗ Branch 2 not taken.
|
35075 | : model->get_nh_T()), |
389 |
5/8✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12667 times.
✓ Branch 4 taken 33834 times.
✓ Branch 6 taken 12667 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 46501 times.
✗ Branch 10 not taken.
|
82817 | Hx(model->get_nh() > model->get_nh_T() ? model->get_nh() |
390 |
1/2✓ Branch 1 taken 33834 times.
✗ Branch 2 not taken.
|
35075 | : model->get_nh_T(), |
391 |
3/6✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 46501 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 46501 times.
✗ Branch 9 not taken.
|
47742 | model->get_state()->get_ndx()), |
392 |
5/8✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12667 times.
✓ Branch 4 taken 33834 times.
✓ Branch 6 taken 12667 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 46501 times.
✗ Branch 10 not taken.
|
82817 | Hu(model->get_nh() > model->get_nh_T() ? model->get_nh() |
393 |
1/2✓ Branch 1 taken 33834 times.
✗ Branch 2 not taken.
|
35075 | : model->get_nh_T(), |
394 |
2/4✓ Branch 2 taken 46501 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 46501 times.
✗ Branch 6 not taken.
|
95484 | model->get_nu()) { |
395 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | xnext.setZero(); |
396 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | Fx.setZero(); |
397 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | Fu.setZero(); |
398 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | r.setZero(); |
399 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | Lx.setZero(); |
400 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | Lu.setZero(); |
401 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | Lxx.setZero(); |
402 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | Lxu.setZero(); |
403 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | Luu.setZero(); |
404 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | g.setZero(); |
405 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | Gx.setZero(); |
406 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | Gu.setZero(); |
407 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | h.setZero(); |
408 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | Hx.setZero(); |
409 |
1/2✓ Branch 1 taken 46501 times.
✗ Branch 2 not taken.
|
47742 | Hu.setZero(); |
410 | 47742 | } | |
411 | 91768 | virtual ~ActionDataAbstractTpl() = default; | |
412 | |||
413 | Scalar cost; //!< cost value | ||
414 | VectorXs xnext; //!< evolution state | ||
415 | MatrixXs Fx; //!< Jacobian of the dynamics w.r.t. the state \f$\mathbf{x}\f$ | ||
416 | MatrixXs | ||
417 | Fu; //!< Jacobian of the dynamics w.r.t. the control \f$\mathbf{u}\f$ | ||
418 | VectorXs r; //!< Cost residual | ||
419 | VectorXs Lx; //!< Jacobian of the cost w.r.t. the state \f$\mathbf{x}\f$ | ||
420 | VectorXs Lu; //!< Jacobian of the cost w.r.t. the control \f$\mathbf{u}\f$ | ||
421 | MatrixXs Lxx; //!< Hessian of the cost w.r.t. the state \f$\mathbf{x}\f$ | ||
422 | MatrixXs Lxu; //!< Hessian of the cost w.r.t. the state \f$\mathbf{x}\f$ and | ||
423 | //!< control \f$\mathbf{u}\f$ | ||
424 | MatrixXs Luu; //!< Hessian of the cost w.r.t. the control \f$\mathbf{u}\f$ | ||
425 | VectorXs g; //!< Inequality constraint values | ||
426 | MatrixXs Gx; //!< Jacobian of the inequality constraint w.r.t. the state | ||
427 | //!< \f$\mathbf{x}\f$ | ||
428 | MatrixXs Gu; //!< Jacobian of the inequality constraint w.r.t. the control | ||
429 | //!< \f$\mathbf{u}\f$ | ||
430 | VectorXs h; //!< Equality constraint values | ||
431 | MatrixXs Hx; //!< Jacobian of the equality constraint w.r.t. the state | ||
432 | //!< \f$\mathbf{x}\f$ | ||
433 | MatrixXs Hu; //!< Jacobian of the equality constraint w.r.t. the control | ||
434 | //!< \f$\mathbf{u}\f$ | ||
435 | }; | ||
436 | |||
437 | } // namespace crocoddyl | ||
438 | |||
439 | /* --- Details -------------------------------------------------------------- */ | ||
440 | /* --- Details -------------------------------------------------------------- */ | ||
441 | /* --- Details -------------------------------------------------------------- */ | ||
442 | #include "crocoddyl/core/action-base.hxx" | ||
443 | |||
444 | CROCODDYL_DECLARE_EXTERN_TEMPLATE_CLASS(crocoddyl::ActionModelAbstractTpl) | ||
445 | CROCODDYL_DECLARE_EXTERN_TEMPLATE_STRUCT(crocoddyl::ActionDataAbstractTpl) | ||
446 | |||
447 | #endif // CROCODDYL_CORE_ACTION_BASE_HPP_ | ||
448 |