Crocoddyl
state.hpp
1 // BSD 3-Clause License
3 //
4 // Copyright (C) 2022-2023, LAAS-CNRS, University of Edinburgh,
5 // Heriot-Watt University
6 // Copyright note valid unless otherwise stated in individual files.
7 // All rights reserved.
9 
10 #ifndef CROCODDYL_MULTIBODY_RESIDUALS_STATE_HPP_
11 #define CROCODDYL_MULTIBODY_RESIDUALS_STATE_HPP_
12 
13 #include "crocoddyl/core/fwd.hpp"
14 #include "crocoddyl/core/residual-base.hpp"
15 #include "crocoddyl/core/state-base.hpp"
16 #include "crocoddyl/multibody/fwd.hpp"
17 #include "crocoddyl/multibody/states/multibody.hpp"
18 
19 namespace crocoddyl {
20 
37 template <typename _Scalar>
39  public:
40  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
41 
42  typedef _Scalar Scalar;
51  typedef typename MathBase::VectorXs VectorXs;
52  typedef typename MathBase::MatrixXs MatrixXs;
53 
61  ResidualModelStateTpl(boost::shared_ptr<typename Base::StateAbstract> state,
62  const VectorXs& xref, const std::size_t nu);
63 
72  ResidualModelStateTpl(boost::shared_ptr<typename Base::StateAbstract> state,
73  const VectorXs& xref);
74 
83  ResidualModelStateTpl(boost::shared_ptr<typename Base::StateAbstract> state,
84  const std::size_t nu);
85 
95  ResidualModelStateTpl(boost::shared_ptr<typename Base::StateAbstract> state);
96  virtual ~ResidualModelStateTpl();
97 
105  virtual void calc(const boost::shared_ptr<ResidualDataAbstract>& data,
106  const Eigen::Ref<const VectorXs>& x,
107  const Eigen::Ref<const VectorXs>& u);
108 
116  virtual void calcDiff(const boost::shared_ptr<ResidualDataAbstract>& data,
117  const Eigen::Ref<const VectorXs>& x,
118  const Eigen::Ref<const VectorXs>& u);
119 
133  virtual void calcCostDiff(
134  const boost::shared_ptr<CostDataAbstract>& cdata,
135  const boost::shared_ptr<ResidualDataAbstract>& rdata,
136  const boost::shared_ptr<ActivationDataAbstract>& adata,
137  const bool update_u = true);
138 
142  const VectorXs& get_reference() const;
143 
147  void set_reference(const VectorXs& reference);
148 
154  virtual void print(std::ostream& os) const;
155 
156  protected:
157  using Base::nr_;
158  using Base::nu_;
159  using Base::state_;
160  using Base::u_dependent_;
161 
162  private:
163  VectorXs xref_;
164  boost::shared_ptr<typename StateMultibody::PinocchioModel>
165  pin_model_;
166 };
167 
168 } // namespace crocoddyl
169 
170 /* --- Details -------------------------------------------------------------- */
171 /* --- Details -------------------------------------------------------------- */
172 /* --- Details -------------------------------------------------------------- */
173 #include "crocoddyl/multibody/residuals/state.hxx"
174 
175 #endif // CROCODDYL_MULTIBODY_RESIDUALS_STATE_HPP_
Abstract class for residual models.
boost::shared_ptr< StateAbstract > state_
State description.
std::size_t nu_
Control dimension.
std::size_t nr_
Residual vector dimension.
ResidualModelStateTpl(boost::shared_ptr< typename Base::StateAbstract > state, const std::size_t nu)
Initialize the state residual model.
ResidualModelStateTpl(boost::shared_ptr< typename Base::StateAbstract > state, const VectorXs &xref, const std::size_t nu)
Initialize the state residual model.
virtual void print(std::ostream &os) const
Print relevant information of the state residual.
virtual void calc(const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the state residual.
virtual void calcCostDiff(const boost::shared_ptr< CostDataAbstract > &cdata, const boost::shared_ptr< ResidualDataAbstract > &rdata, const boost::shared_ptr< ActivationDataAbstract > &adata, const bool update_u=true)
Compute the derivative of the state-cost function and store it in cost data.
ResidualModelStateTpl(boost::shared_ptr< typename Base::StateAbstract > state)
Initialize the state residual model.
void set_reference(const VectorXs &reference)
Modify the reference state.
virtual void calcDiff(const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the Jacobians of the state residual.
const VectorXs & get_reference() const
Return the reference state.
ResidualModelStateTpl(boost::shared_ptr< typename Base::StateAbstract > state, const VectorXs &xref)
Initialize the state residual model.
State multibody representation.
Definition: multibody.hpp:35