GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/crocoddyl/core/numdiff/state.hpp Lines: 0 1 0.0 %
Date: 2024-02-13 11:12:33 Branches: 0 0 - %

Line Branch Exec Source
1
///////////////////////////////////////////////////////////////////////////////
2
// BSD 3-Clause License
3
//
4
// Copyright (C) 2019-2023, LAAS-CNRS, New York University, Max Planck
5
// Gesellschaft,
6
//                          University of Edinburgh, Heriot-Watt University
7
// Copyright note valid unless otherwise stated in individual files.
8
// All rights reserved.
9
///////////////////////////////////////////////////////////////////////////////
10
11
#ifndef CROCODDYL_CORE_NUMDIFF_STATE_HPP_
12
#define CROCODDYL_CORE_NUMDIFF_STATE_HPP_
13
14
#include <boost/make_shared.hpp>
15
#include <boost/shared_ptr.hpp>
16
17
#include "crocoddyl/core/fwd.hpp"
18
#include "crocoddyl/core/state-base.hpp"
19
20
namespace crocoddyl {
21
22
template <typename _Scalar>
23
class StateNumDiffTpl : public StateAbstractTpl<_Scalar> {
24
 public:
25
  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
26
27
  typedef _Scalar Scalar;
28
  typedef MathBaseTpl<Scalar> MathBase;
29
  typedef StateAbstractTpl<_Scalar> Base;
30
  typedef typename MathBase::VectorXs VectorXs;
31
  typedef typename MathBase::MatrixXs MatrixXs;
32
33
  explicit StateNumDiffTpl(boost::shared_ptr<Base> state);
34
  virtual ~StateNumDiffTpl();
35
36
  virtual VectorXs zero() const;
37
  virtual VectorXs rand() const;
38
  virtual void diff(const Eigen::Ref<const VectorXs>& x0,
39
                    const Eigen::Ref<const VectorXs>& x1,
40
                    Eigen::Ref<VectorXs> dxout) const;
41
  virtual void integrate(const Eigen::Ref<const VectorXs>& x,
42
                         const Eigen::Ref<const VectorXs>& dx,
43
                         Eigen::Ref<VectorXs> xout) const;
44
  /**
45
   * @brief This computes the Jacobian of the diff method by finite
46
   * differentiation:
47
   * \f{equation}{
48
   *    Jfirst[:,k] = diff(int(x_1, dx_dist), x_2) - diff(x_1, x_2)/disturbance
49
   * \f}
50
   * and
51
   * \f{equation}{
52
   *    Jsecond[:,k] = diff(x_1, int(x_2, dx_dist)) - diff(x_1, x_2)/disturbance
53
   * \f}
54
   *
55
   * @param Jfirst
56
   * @param Jsecond
57
   * @param firstsecond
58
   */
59
  virtual void Jdiff(const Eigen::Ref<const VectorXs>& x0,
60
                     const Eigen::Ref<const VectorXs>& x1,
61
                     Eigen::Ref<MatrixXs> Jfirst, Eigen::Ref<MatrixXs> Jsecond,
62
                     Jcomponent firstsecond = both) const;
63
  /**
64
   * @brief This computes the Jacobian of the integrate method by finite
65
   * differentiation:
66
   * \f{equation}{
67
   *    Jfirst[:,k] = diff( int(x, d_x), int( int(x, dx_dist), dx) )/disturbance
68
   * \f}
69
   * and
70
   * \f{equation}{
71
   *    Jsecond[:,k] = diff( int(x, d_x), int( x, dx + dx_dist) )/disturbance
72
   * \f}
73
   *
74
   * @param Jfirst
75
   * @param Jsecond
76
   * @param firstsecond
77
   */
78
  virtual void Jintegrate(const Eigen::Ref<const VectorXs>& x,
79
                          const Eigen::Ref<const VectorXs>& dx,
80
                          Eigen::Ref<MatrixXs> Jfirst,
81
                          Eigen::Ref<MatrixXs> Jsecond,
82
                          const Jcomponent firstsecond = both,
83
                          const AssignmentOp op = setto) const;
84
85
  virtual void JintegrateTransport(const Eigen::Ref<const VectorXs>& x,
86
                                   const Eigen::Ref<const VectorXs>& dx,
87
                                   Eigen::Ref<MatrixXs> Jin,
88
                                   const Jcomponent firstsecond = both) const;
89
90
  /**
91
   * @brief Return the disturbance constant used in the numerical
92
   * differentiation routine
93
   */
94
  const Scalar get_disturbance() const;
95
96
  /**
97
   * @brief Modify the disturbance constant used by the numerical
98
   * differentiation routine
99
   */
100
  void set_disturbance(const Scalar disturbance);
101
102
 private:
103
  boost::shared_ptr<Base>
104
      state_;     //!< state we need to compute the numerical differentiation
105
  Scalar e_jac_;  //!< Constant used for computing disturbances in Jacobian
106
                  //!< calculation
107
108
 protected:
109
  using Base::has_limits_;
110
  using Base::lb_;
111
  using Base::ndx_;
112
  using Base::nq_;
113
  using Base::nv_;
114
  using Base::nx_;
115
  using Base::ub_;
116
};
117
118
}  // namespace crocoddyl
119
120
/* --- Details -------------------------------------------------------------- */
121
/* --- Details -------------------------------------------------------------- */
122
/* --- Details -------------------------------------------------------------- */
123
#include "crocoddyl/core/numdiff/state.hxx"
124
125
#endif  // CROCODDYL_CORE_NUMDIFF_STATE_HPP_