Crocoddyl
poly-one.hpp
1 // BSD 3-Clause License
3 //
4 // Copyright (C) 2021-2025, University of Edinburgh, University of Trento,
5 // Heriot-Watt University
6 // Copyright note valid unless otherwise stated in individual files.
7 // All rights reserved.
9 
10 #ifndef CROCODDYL_CORE_CONTROLS_POLY_ONE_HPP_
11 #define CROCODDYL_CORE_CONTROLS_POLY_ONE_HPP_
12 
13 #include "crocoddyl/core/control-base.hpp"
14 #include "crocoddyl/core/fwd.hpp"
15 #include "crocoddyl/core/utils/exception.hpp"
16 
17 namespace crocoddyl {
18 
41 template <typename _Scalar>
43  : public ControlParametrizationModelAbstractTpl<_Scalar> {
44  public:
45  typedef _Scalar Scalar;
51  typedef typename MathBase::VectorXs VectorXs;
52  typedef typename MathBase::MatrixXs MatrixXs;
53 
59  explicit ControlParametrizationModelPolyOneTpl(const std::size_t nw);
61 
69  virtual void calc(
70  const boost::shared_ptr<ControlParametrizationDataAbstract>& data,
71  const Scalar t, const Eigen::Ref<const VectorXs>& u) const;
72 
83  virtual void calcDiff(
84  const boost::shared_ptr<ControlParametrizationDataAbstract>& data,
85  const Scalar t, const Eigen::Ref<const VectorXs>& u) const;
86 
92  virtual boost::shared_ptr<ControlParametrizationDataAbstract> createData();
93 
102  virtual void params(
103  const boost::shared_ptr<ControlParametrizationDataAbstract>& data,
104  const Scalar t, const Eigen::Ref<const VectorXs>& w) const;
105 
115  virtual void convertBounds(const Eigen::Ref<const VectorXs>& w_lb,
116  const Eigen::Ref<const VectorXs>& w_ub,
117  Eigen::Ref<VectorXs> u_lb,
118  Eigen::Ref<VectorXs> u_ub) const;
119 
133  virtual void multiplyByJacobian(
134  const boost::shared_ptr<ControlParametrizationDataAbstract>& data,
135  const Eigen::Ref<const MatrixXs>& A, Eigen::Ref<MatrixXs> out,
136  const AssignmentOp op = setto) const;
137 
152  const boost::shared_ptr<ControlParametrizationDataAbstract>& data,
153  const Eigen::Ref<const MatrixXs>& A, Eigen::Ref<MatrixXs> out,
154  const AssignmentOp op = setto) const;
155 
156  protected:
157  using Base::nu_;
158  using Base::nw_;
159 };
160 
161 template <typename _Scalar>
163  : public ControlParametrizationDataAbstractTpl<_Scalar> {
164  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
165 
166  typedef _Scalar Scalar;
169  typedef typename MathBase::Vector2s Vector2s;
170 
171  template <template <typename Scalar> class Model>
172  explicit ControlParametrizationDataPolyOneTpl(Model<Scalar>* const model)
173  : Base(model) {
174  c.setZero();
175  }
176 
178 
179  Vector2s c;
180 };
181 
182 } // namespace crocoddyl
183 
184 /* --- Details -------------------------------------------------------------- */
185 /* --- Details -------------------------------------------------------------- */
186 /* --- Details -------------------------------------------------------------- */
187 #include "crocoddyl/core/controls/poly-one.hxx"
188 
189 #endif // CROCODDYL_CORE_CONTROLS_POLY_ONE_HPP_
Abstract class for the control trajectory parametrization.
std::size_t nu_
Control parameters dimension.
A polynomial function of time of degree one, that is a linear function.
Definition: poly-one.hpp:43
virtual void calc(const boost::shared_ptr< ControlParametrizationDataAbstract > &data, const Scalar t, const Eigen::Ref< const VectorXs > &u) const
Get the value of the control at the specified time.
virtual void multiplyJacobianTransposeBy(const boost::shared_ptr< ControlParametrizationDataAbstract > &data, const Eigen::Ref< const MatrixXs > &A, Eigen::Ref< MatrixXs > out, const AssignmentOp op=setto) const
Compute the product between the transposed Jacobian of the control (with respect to the parameters) a...
virtual void convertBounds(const Eigen::Ref< const VectorXs > &w_lb, const Eigen::Ref< const VectorXs > &w_ub, Eigen::Ref< VectorXs > u_lb, Eigen::Ref< VectorXs > u_ub) const
Map the specified bounds from the control space to the parameter space.
virtual void multiplyByJacobian(const boost::shared_ptr< ControlParametrizationDataAbstract > &data, const Eigen::Ref< const MatrixXs > &A, Eigen::Ref< MatrixXs > out, const AssignmentOp op=setto) const
Compute the product between a specified matrix and the Jacobian of the control (with respect to the p...
virtual void params(const boost::shared_ptr< ControlParametrizationDataAbstract > &data, const Scalar t, const Eigen::Ref< const VectorXs > &w) const
Get a value of the control parameters such that the control at the specified time t is equal to the s...
virtual void calcDiff(const boost::shared_ptr< ControlParametrizationDataAbstract > &data, const Scalar t, const Eigen::Ref< const VectorXs > &u) const
Get the value of the Jacobian of the control with respect to the parameters.
ControlParametrizationModelPolyOneTpl(const std::size_t nw)
Initialize the poly-one control parametrization.
virtual boost::shared_ptr< ControlParametrizationDataAbstract > createData()
Create the control-parametrization data.
Vector2s c
Coefficients of the linear control that depends on time.
Definition: poly-one.hpp:179