11 #ifndef CROCODDYL_CORE_NUMDIFF_DIFF_ACTION_HPP_
12 #define CROCODDYL_CORE_NUMDIFF_DIFF_ACTION_HPP_
17 #include "crocoddyl/core/diff-action-base.hpp"
46 template <
typename _Scalar>
50 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
52 typedef _Scalar Scalar;
58 typedef typename MathBase::VectorXs VectorXs;
59 typedef typename MathBase::MatrixXs MatrixXs;
70 boost::shared_ptr<Base> model,
const bool with_gauss_approx =
false);
77 const boost::shared_ptr<DifferentialActionDataAbstract>& data,
78 const Eigen::Ref<const VectorXs>& x,
const Eigen::Ref<const VectorXs>& u);
86 const boost::shared_ptr<DifferentialActionDataAbstract>& data,
87 const Eigen::Ref<const VectorXs>& x);
93 const boost::shared_ptr<DifferentialActionDataAbstract>& data,
94 const Eigen::Ref<const VectorXs>& x,
const Eigen::Ref<const VectorXs>& u);
102 const boost::shared_ptr<DifferentialActionDataAbstract>& data,
103 const Eigen::Ref<const VectorXs>& x);
108 virtual boost::shared_ptr<DifferentialActionDataAbstract>
createData();
114 const boost::shared_ptr<DifferentialActionDataAbstract>& data,
115 Eigen::Ref<VectorXs> u,
const Eigen::Ref<const VectorXs>& x,
116 const std::size_t maxiter = 100,
const Scalar tol = Scalar(1e-9));
146 virtual void print(std::ostream& os)
const;
158 void assertStableStateFD(
const Eigen::Ref<const VectorXs>& x);
159 boost::shared_ptr<Base> model_;
160 bool with_gauss_approx_;
167 template <
typename _Scalar>
170 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
172 typedef _Scalar Scalar;
175 typedef typename MathBase::VectorXs VectorXs;
176 typedef typename MathBase::MatrixXs MatrixXs;
184 template <
template <
typename Scalar>
class Model>
187 Rx(model->get_model()->get_nr(),
188 model->get_model()->get_state()->get_ndx()),
189 Ru(model->get_model()->get_nr(), model->get_model()->get_nu()),
190 dx(model->get_model()->get_state()->get_ndx()),
191 du(model->get_model()->get_nu()),
192 xp(model->get_model()->get_state()->get_nx()) {
199 const std::size_t ndx = model->get_model()->get_state()->get_ndx();
200 const std::size_t nu = model->get_model()->get_nu();
201 data_0 = model->get_model()->createData();
202 for (std::size_t i = 0; i < ndx; ++i) {
203 data_x.push_back(model->get_model()->createData());
205 for (std::size_t i = 0; i < nu; ++i) {
206 data_u.push_back(model->get_model()->createData());
221 Scalar xuh_hess_pow2;
227 boost::shared_ptr<Base> data_0;
228 std::vector<boost::shared_ptr<Base> > data_x;
229 std::vector<boost::shared_ptr<Base> > data_u;
254 #include "crocoddyl/core/numdiff/diff-action.hxx"
Abstract class for differential action model.
VectorXs u_lb_
Lower control limits.
VectorXs u_ub_
Upper control limits.
boost::shared_ptr< StateAbstract > state_
Model of the state.
std::size_t nu_
Control dimension.
std::size_t nr_
Dimension of the cost residual.
This class computes the numerical differentiation of a differential action model.
virtual void calc(const boost::shared_ptr< DifferentialActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
virtual void calcDiff(const boost::shared_ptr< DifferentialActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the derivatives of the dynamics and cost functions.
const Scalar get_disturbance() const
Return the disturbance constant used in the numerical differentiation routine.
bool get_with_gauss_approx()
Identify if the Gauss approximation is going to be used or not.
void set_disturbance(const Scalar disturbance)
Modify the disturbance constant used in the numerical differentiation routine.
virtual boost::shared_ptr< DifferentialActionDataAbstract > createData()
Create the differential action data.
virtual void print(std::ostream &os) const
Print relevant information of the action numdiff model.
const boost::shared_ptr< Base > & get_model() const
Return the differential acton model that we use to numerical differentiate.
virtual void calc(const boost::shared_ptr< DifferentialActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the system acceleration and cost value.
virtual void quasiStatic(const boost::shared_ptr< DifferentialActionDataAbstract > &data, Eigen::Ref< VectorXs > u, const Eigen::Ref< const VectorXs > &x, const std::size_t maxiter=100, const Scalar tol=Scalar(1e-9))
Computes the quasic static commands.
DifferentialActionModelNumDiffTpl(boost::shared_ptr< Base > model, const bool with_gauss_approx=false)
Initialize the numdiff differential action model.
virtual void calcDiff(const boost::shared_ptr< DifferentialActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
MatrixXs Fx
Jacobian of the dynamics w.r.t. the state .
MatrixXs Fu
Jacobian of the dynamics w.r.t. the control .
VectorXs h
Equality constraint values.
MatrixXs Luu
Hessian of the cost w.r.t. the control .
VectorXs g
Inequality constraint values.
VectorXs Lx
Jacobian of the cost w.r.t. the state .
MatrixXs Lxx
Hessian of the cost w.r.t. the state .
VectorXs Lu
Jacobian of the cost w.r.t. the control .
VectorXs xout
evolution state
DifferentialActionDataNumDiffTpl(Model< Scalar > *const model)
Construct a new ActionDataNumDiff object.
Scalar x_norm
Norm of the state vector.
Scalar uh_jac
Disturbance value used for computing .
Scalar xh_jac
Disturbance value used for computing .