Crocoddyl
poly-two-rk.hpp
1 // BSD 3-Clause License
3 //
4 // Copyright (C) 2021, University of Edinburgh, University of Trento
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
8 
9 #ifndef CROCODDYL_CORE_CONTROLS_POLY_TWO_RK_HPP_
10 #define CROCODDYL_CORE_CONTROLS_POLY_TWO_RK_HPP_
11 
12 #include "crocoddyl/core/control-base.hpp"
13 #include "crocoddyl/core/fwd.hpp"
14 #include "crocoddyl/core/integrator/rk.hpp"
15 #include "crocoddyl/core/utils/exception.hpp"
16 
17 namespace crocoddyl {
18 
49 template <typename _Scalar>
51  : public ControlParametrizationModelAbstractTpl<_Scalar> {
52  public:
53  typedef _Scalar Scalar;
59  typedef typename MathBase::VectorXs VectorXs;
60  typedef typename MathBase::MatrixXs MatrixXs;
61 
68  explicit ControlParametrizationModelPolyTwoRKTpl(const std::size_t nw,
69  const RKType rktype);
71 
79  virtual void calc(
80  const boost::shared_ptr<ControlParametrizationDataAbstract>& data,
81  const Scalar t, const Eigen::Ref<const VectorXs>& u) const;
82 
93  virtual void calcDiff(
94  const boost::shared_ptr<ControlParametrizationDataAbstract>& data,
95  const Scalar t, const Eigen::Ref<const VectorXs>& u) const;
96 
102  virtual boost::shared_ptr<ControlParametrizationDataAbstract> createData();
103 
112  virtual void params(
113  const boost::shared_ptr<ControlParametrizationDataAbstract>& data,
114  const Scalar t, const Eigen::Ref<const VectorXs>& w) const;
115 
125  virtual void convertBounds(const Eigen::Ref<const VectorXs>& w_lb,
126  const Eigen::Ref<const VectorXs>& w_ub,
127  Eigen::Ref<VectorXs> u_lb,
128  Eigen::Ref<VectorXs> u_ub) const;
129 
143  virtual void multiplyByJacobian(
144  const boost::shared_ptr<ControlParametrizationDataAbstract>& data,
145  const Eigen::Ref<const MatrixXs>& A, Eigen::Ref<MatrixXs> out,
146  const AssignmentOp = setto) const;
147 
162  const boost::shared_ptr<ControlParametrizationDataAbstract>& data,
163  const Eigen::Ref<const MatrixXs>& A, Eigen::Ref<MatrixXs> out,
164  const AssignmentOp = setto) const;
165 
166  protected:
167  using Base::nu_;
168  using Base::nw_;
169 
170  private:
171  RKType rktype_;
172 };
173 
174 template <typename _Scalar>
176  : public ControlParametrizationDataAbstractTpl<_Scalar> {
177  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
178 
179  typedef _Scalar Scalar;
182  typedef typename MathBase::Vector3s Vector3s;
183 
184  template <template <typename Scalar> class Model>
185  explicit ControlParametrizationDataPolyTwoRKTpl(Model<Scalar>* const model)
186  : Base(model), tmp_t2(0.) {
187  c.setZero();
188  }
189 
191 
192  Vector3s c;
194  Scalar tmp_t2;
195 };
196 
197 } // namespace crocoddyl
198 
199 /* --- Details -------------------------------------------------------------- */
200 /* --- Details -------------------------------------------------------------- */
201 /* --- Details -------------------------------------------------------------- */
202 #include "crocoddyl/core/controls/poly-two-rk.hxx"
203 
204 #endif // CROCODDYL_CORE_CONTROLS_POLY_TWO_RK_HPP_
Abstract class for the control trajectory parametrization.
std::size_t nu_
Control parameters dimension.
A polynomial function of time of degree two, that is a quadratic function.
Definition: poly-two-rk.hpp:51
ControlParametrizationModelPolyTwoRKTpl(const std::size_t nw, const RKType rktype)
Initialize the poly-two RK control parametrization.
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 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 params(const boost::shared_ptr< ControlParametrizationDataAbstract > &data, const Scalar t, const Eigen::Ref< const VectorXs > &w) const
Get a value of the control parameters u such that the control at the specified time t is equal to the...
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.
virtual void multiplyJacobianTransposeBy(const boost::shared_ptr< ControlParametrizationDataAbstract > &data, const Eigen::Ref< const MatrixXs > &A, Eigen::Ref< MatrixXs > out, const AssignmentOp=setto) const
Compute the product between the transposed Jacobian of the control (with respect to the parameters) a...
virtual void multiplyByJacobian(const boost::shared_ptr< ControlParametrizationDataAbstract > &data, const Eigen::Ref< const MatrixXs > &A, Eigen::Ref< MatrixXs > out, const AssignmentOp=setto) const
Compute the product between a specified matrix and the Jacobian of the control (with respect to the p...
virtual boost::shared_ptr< ControlParametrizationDataAbstract > createData()
Create the control-parametrization data.
Scalar tmp_t2
Temporary variable to store the square of the time.