GCC Code Coverage Report


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