10 #ifndef CROCODDYL_CORE_NUMDIFF_CONTROL_HPP_
11 #define CROCODDYL_CORE_NUMDIFF_CONTROL_HPP_
13 #include "crocoddyl/core/control-base.hpp"
14 #include "crocoddyl/core/fwd.hpp"
18 template <
typename _Scalar>
22 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
26 typedef _Scalar Scalar;
32 typedef typename MathBase::VectorXs VectorXs;
33 typedef typename MathBase::MatrixXs MatrixXs;
50 void calc(
const std::shared_ptr<ControlParametrizationDataAbstract>& data,
51 const Scalar t,
const Eigen::Ref<const VectorXs>& u)
const override;
61 void calcDiff(
const std::shared_ptr<ControlParametrizationDataAbstract>& data,
63 const Eigen::Ref<const VectorXs>& u)
const override;
70 virtual std::shared_ptr<ControlParametrizationDataAbstract>
createData()
81 void params(
const std::shared_ptr<ControlParametrizationDataAbstract>& data,
83 const Eigen::Ref<const VectorXs>& w)
const override;
95 const Eigen::Ref<const VectorXs>& w_ub,
96 Eigen::Ref<VectorXs> u_lb,
97 Eigen::Ref<VectorXs> u_ub)
const override;
111 const std::shared_ptr<ControlParametrizationDataAbstract>& data,
112 const Eigen::Ref<const MatrixXs>& A, Eigen::Ref<MatrixXs> out,
113 const AssignmentOp = setto)
const override;
127 const std::shared_ptr<ControlParametrizationDataAbstract>& data,
128 const Eigen::Ref<const MatrixXs>& A, Eigen::Ref<MatrixXs> out,
129 const AssignmentOp = setto)
const override;
131 template <
typename NewScalar>
153 std::shared_ptr<Base>
163 template <
typename _Scalar>
166 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
168 typedef _Scalar Scalar;
170 typedef typename MathBase::VectorXs VectorXs;
171 typedef typename MathBase::MatrixXs MatrixXs;
174 template <
template <
typename Scalar>
class Model>
176 :
Base(model),
du(model->get_nu()) {
179 const std::size_t nu = model->get_model()->get_nu();
180 data_0 = model->get_model()->createData();
181 for (std::size_t i = 0; i < nu; ++i) {
182 data_u.push_back(model->get_model()->createData());
190 std::vector<std::shared_ptr<Base> >
199 #include "crocoddyl/core/numdiff/control.hxx"
Abstract class for the control trajectory parametrization.
std::size_t nw_
Control dimension.
std::size_t nu_
Control parameters dimension.
const std::shared_ptr< Base > & get_model() const
Get the model_ object.
void params(const std::shared_ptr< ControlParametrizationDataAbstract > &data, const Scalar t, const Eigen::Ref< const VectorXs > &w) const override
Get a value of the control parameters such that the control at the specified time t is equal to the s...
void calcDiff(const std::shared_ptr< ControlParametrizationDataAbstract > &data, const Scalar t, const Eigen::Ref< const VectorXs > &u) const override
Get the value of the Jacobian of the control with respect to the parameters.
void calc(const std::shared_ptr< ControlParametrizationDataAbstract > &data, const Scalar t, const Eigen::Ref< const VectorXs > &u) const override
Get the value of the control at the specified time.
const Scalar get_disturbance() const
Return the disturbance constant used in the numerical differentiation routine.
void set_disturbance(const Scalar disturbance)
Modify the disturbance constant used in the numerical differentiation routine.
ControlParametrizationModelNumDiffTpl(std::shared_ptr< Base > model)
Construct a new ControlParametrizationModelNumDiff object.
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 override
Convert the bounds on the control to bounds on the control parameters.
virtual std::shared_ptr< ControlParametrizationDataAbstract > createData() override
Create the control-parametrization data.
void multiplyByJacobian(const std::shared_ptr< ControlParametrizationDataAbstract > &data, const Eigen::Ref< const MatrixXs > &A, Eigen::Ref< MatrixXs > out, const AssignmentOp=setto) const override
Compute the product between a specified matrix and the Jacobian of the control (with respect to the p...
void multiplyJacobianTransposeBy(const std::shared_ptr< ControlParametrizationDataAbstract > &data, const Eigen::Ref< const MatrixXs > &A, Eigen::Ref< MatrixXs > out, const AssignmentOp=setto) const override
Compute the product between the transposed Jacobian of the control (with respect to the parameters) a...
std::vector< std::shared_ptr< Base > > data_u
The temporary data associated with the control variation.
VectorXs du
temporary variable used for finite differencing
std::shared_ptr< Base > data_0
The data that contains the final results.