12 #ifndef CROCODDYL_CORE_NUMDIFF_CONTROL_HPP_
13 #define CROCODDYL_CORE_NUMDIFF_CONTROL_HPP_
15 #include <boost/make_shared.hpp>
16 #include <boost/shared_ptr.hpp>
19 #include "crocoddyl/core/control-base.hpp"
20 #include "crocoddyl/core/fwd.hpp"
24 template <
typename _Scalar>
28 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
30 typedef _Scalar Scalar;
36 typedef typename MathBase::VectorXs VectorXs;
37 typedef typename MathBase::MatrixXs MatrixXs;
54 void calc(
const boost::shared_ptr<ControlParametrizationDataAbstract>& data,
55 const Scalar t,
const Eigen::Ref<const VectorXs>& u)
const;
66 const boost::shared_ptr<ControlParametrizationDataAbstract>& data,
67 const Scalar t,
const Eigen::Ref<const VectorXs>& u)
const;
74 virtual boost::shared_ptr<ControlParametrizationDataAbstract>
createData();
84 void params(
const boost::shared_ptr<ControlParametrizationDataAbstract>& data,
85 const Scalar t,
const Eigen::Ref<const VectorXs>& w)
const;
97 const Eigen::Ref<const VectorXs>& w_ub,
98 Eigen::Ref<VectorXs> u_lb,
99 Eigen::Ref<VectorXs> u_ub)
const;
113 const boost::shared_ptr<ControlParametrizationDataAbstract>& data,
114 const Eigen::Ref<const MatrixXs>& A, Eigen::Ref<MatrixXs> out,
115 const AssignmentOp = setto)
const;
129 const boost::shared_ptr<ControlParametrizationDataAbstract>& data,
130 const Eigen::Ref<const MatrixXs>& A, Eigen::Ref<MatrixXs> out,
131 const AssignmentOp = setto)
const;
153 boost::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<boost::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 Scalar get_disturbance() const
Return the disturbance constant used in the numerical differentiation routine.
ControlParametrizationModelNumDiffTpl(boost::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
Convert the bounds on the control to bounds on the control parameters.
void set_disturbance(const Scalar disturbance)
Modify the disturbance constant used in the numerical differentiation routine.
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.
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.
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...
const boost::shared_ptr< Base > & get_model() const
Get the model_ object.
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...
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 boost::shared_ptr< ControlParametrizationDataAbstract > createData()
Create the control-parametrization data.
std::vector< boost::shared_ptr< Base > > data_u
The temporary data associated with the control variation.
boost::shared_ptr< Base > data_0
The data that contains the final results.
VectorXs du
temporary variable used for finite differencing