Crocoddyl
 
Loading...
Searching...
No Matches
state.hpp
1
2// BSD 3-Clause License
3//
4// Copyright (C) 2022-2025, 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
19namespace crocoddyl {
20
37template <typename _Scalar>
39 public:
40 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
41 CROCODDYL_DERIVED_CAST(ResidualModelBase, ResidualModelStateTpl)
42
43 typedef _Scalar Scalar;
51 typedef typename MathBase::VectorXs VectorXs;
52 typedef typename MathBase::MatrixXs MatrixXs;
53
61 ResidualModelStateTpl(std::shared_ptr<typename Base::StateAbstract> state,
62 const VectorXs& xref, const std::size_t nu);
63
72 ResidualModelStateTpl(std::shared_ptr<typename Base::StateAbstract> state,
73 const VectorXs& xref);
74
83 ResidualModelStateTpl(std::shared_ptr<typename Base::StateAbstract> state,
84 const std::size_t nu);
85
95 ResidualModelStateTpl(std::shared_ptr<typename Base::StateAbstract> state);
96 virtual ~ResidualModelStateTpl() = default;
97
105 virtual void calc(const std::shared_ptr<ResidualDataAbstract>& data,
106 const Eigen::Ref<const VectorXs>& x,
107 const Eigen::Ref<const VectorXs>& u) override;
108
116 virtual void calcDiff(const std::shared_ptr<ResidualDataAbstract>& data,
117 const Eigen::Ref<const VectorXs>& x,
118 const Eigen::Ref<const VectorXs>& u) override;
119
133 virtual void calcCostDiff(
134 const std::shared_ptr<CostDataAbstract>& cdata,
135 const std::shared_ptr<ResidualDataAbstract>& rdata,
136 const std::shared_ptr<ActivationDataAbstract>& adata,
137 const bool update_u = true) override;
138
148 template <typename NewScalar>
150
154 const VectorXs& get_reference() const;
155
159 void set_reference(const VectorXs& reference);
160
166 virtual void print(std::ostream& os) const override;
167
168 protected:
169 using Base::nr_;
170 using Base::nu_;
171 using Base::state_;
172 using Base::u_dependent_;
173
174 private:
175 VectorXs xref_;
176 std::shared_ptr<typename StateMultibody::PinocchioModel>
177 pin_model_;
178};
179
180} // namespace crocoddyl
181
182/* --- Details -------------------------------------------------------------- */
183/* --- Details -------------------------------------------------------------- */
184/* --- Details -------------------------------------------------------------- */
185#include "crocoddyl/multibody/residuals/state.hxx"
186
187extern template class CROCODDYL_EXPLICIT_INSTANTIATION_DECLARATION_DLLAPI
189extern template class CROCODDYL_EXPLICIT_INSTANTIATION_DECLARATION_DLLAPI
191
192#endif // CROCODDYL_MULTIBODY_RESIDUALS_STATE_HPP_
Abstract class for residual models.
std::shared_ptr< StateAbstract > state_
State description.
std::size_t nu_
Control dimension.
std::size_t nr_
Residual vector dimension.
virtual void calcDiff(const std::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u) override
Compute the Jacobians of the state residual.
void set_reference(const VectorXs &reference)
Modify the reference state.
virtual void calcCostDiff(const std::shared_ptr< CostDataAbstract > &cdata, const std::shared_ptr< ResidualDataAbstract > &rdata, const std::shared_ptr< ActivationDataAbstract > &adata, const bool update_u=true) override
Compute the derivative of the state-cost function and store it in cost data.
ResidualModelStateTpl(std::shared_ptr< typename Base::StateAbstract > state, const VectorXs &xref)
Initialize the state residual model.
ResidualModelStateTpl(std::shared_ptr< typename Base::StateAbstract > state)
Initialize the state residual model.
ResidualModelStateTpl< NewScalar > cast() const
Cast the state residual model to a different scalar type.
ResidualModelStateTpl(std::shared_ptr< typename Base::StateAbstract > state, const VectorXs &xref, const std::size_t nu)
Initialize the state residual model.
virtual void calc(const std::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u) override
Compute the state residual.
virtual void print(std::ostream &os) const override
Print relevant information of the state residual.
const VectorXs & get_reference() const
Return the reference state.
ResidualModelStateTpl(std::shared_ptr< typename Base::StateAbstract > state, const std::size_t nu)
Initialize the state residual model.
State multibody representation.
Definition multibody.hpp:34