Crocoddyl
control.hpp
1 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2024, 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_CORE_RESIDUALS_CONTROL_HPP_
11 #define CROCODDYL_CORE_RESIDUALS_CONTROL_HPP_
12 
13 #include "crocoddyl/core/fwd.hpp"
14 #include "crocoddyl/core/residual-base.hpp"
15 
16 namespace crocoddyl {
17 
34 template <typename _Scalar>
36  public:
37  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
38 
39  typedef _Scalar Scalar;
44  typedef typename MathBase::VectorXs VectorXs;
45  typedef typename MathBase::MatrixXs MatrixXs;
46 
55  ResidualModelControlTpl(boost::shared_ptr<typename Base::StateAbstract> state,
56  const VectorXs& uref);
57 
66  ResidualModelControlTpl(boost::shared_ptr<typename Base::StateAbstract> state,
67  const std::size_t nu);
68 
78  boost::shared_ptr<typename Base::StateAbstract> state);
79  virtual ~ResidualModelControlTpl();
80 
88  virtual void calc(const boost::shared_ptr<ResidualDataAbstract>& data,
89  const Eigen::Ref<const VectorXs>& x,
90  const Eigen::Ref<const VectorXs>& u);
91 
96  virtual void calc(const boost::shared_ptr<ResidualDataAbstract>& data,
97  const Eigen::Ref<const VectorXs>& x);
98 
106  virtual void calcDiff(const boost::shared_ptr<ResidualDataAbstract>& data,
107  const Eigen::Ref<const VectorXs>& x,
108  const Eigen::Ref<const VectorXs>& u);
109 
113  virtual boost::shared_ptr<ResidualDataAbstract> createData(
114  DataCollectorAbstract* const data);
115 
128  virtual void calcCostDiff(
129  const boost::shared_ptr<CostDataAbstract>& cdata,
130  const boost::shared_ptr<ResidualDataAbstract>& rdata,
131  const boost::shared_ptr<ActivationDataAbstract>& adata,
132  const bool update_u = true);
133 
137  const VectorXs& get_reference() const;
138 
142  void set_reference(const VectorXs& reference);
143 
149  virtual void print(std::ostream& os) const;
150 
151  protected:
152  using Base::nu_;
153  using Base::state_;
154 
155  private:
156  VectorXs uref_;
157 };
158 
159 } // namespace crocoddyl
160 
161 /* --- Details -------------------------------------------------------------- */
162 /* --- Details -------------------------------------------------------------- */
163 /* --- Details -------------------------------------------------------------- */
164 #include "crocoddyl/core/residuals/control.hxx"
165 
166 #endif // CROCODDYL_CORE_RESIDUALS_CONTROL_HPP_
Abstract class for residual models.
boost::shared_ptr< StateAbstract > state_
State description.
std::size_t nu_
Control dimension.
Define a control residual.
Definition: control.hpp:35
virtual void calc(const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
ResidualModelControlTpl(boost::shared_ptr< typename Base::StateAbstract > state, const VectorXs &uref)
Initialize the control residual model.
virtual void print(std::ostream &os) const
Print relevant information of the control residual.
ResidualModelControlTpl(boost::shared_ptr< typename Base::StateAbstract > state)
Initialize the control residual model.
ResidualModelControlTpl(boost::shared_ptr< typename Base::StateAbstract > state, const std::size_t nu)
Initialize the control residual model.
virtual void calc(const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the control 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 control-cost function.
void set_reference(const VectorXs &reference)
Modify the reference control vector.
virtual void calcDiff(const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the derivatives of the control residual.
const VectorXs & get_reference() const
Return the reference control vector.
virtual boost::shared_ptr< ResidualDataAbstract > createData(DataCollectorAbstract *const data)
Create the control residual data.