11 #ifndef CROCODDYL_CORE_NUMDIFF_ACTION_HPP_
12 #define CROCODDYL_CORE_NUMDIFF_ACTION_HPP_
16 #include "crocoddyl/core/action-base.hpp"
17 #include "crocoddyl/core/fwd.hpp"
45 template <
typename _Scalar>
48 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
50 typedef _Scalar Scalar;
67 bool with_gauss_approx =
false);
73 virtual void calc(
const boost::shared_ptr<ActionDataAbstract>& data,
74 const Eigen::Ref<const VectorXs>& x,
75 const Eigen::Ref<const VectorXs>& u);
81 virtual void calc(
const boost::shared_ptr<ActionDataAbstract>& data,
82 const Eigen::Ref<const VectorXs>& x);
87 virtual void calcDiff(
const boost::shared_ptr<ActionDataAbstract>& data,
88 const Eigen::Ref<const VectorXs>& x,
89 const Eigen::Ref<const VectorXs>& u);
95 virtual void calcDiff(
const boost::shared_ptr<ActionDataAbstract>& data,
96 const Eigen::Ref<const VectorXs>& x);
106 virtual void quasiStatic(
const boost::shared_ptr<ActionDataAbstract>& data,
107 Eigen::Ref<VectorXs> u,
108 const Eigen::Ref<const VectorXs>& x,
109 const std::size_t maxiter = 100,
110 const Scalar tol = Scalar(1e-9));
139 virtual void print(std::ostream& os)
const;
162 void assertStableStateFD(
const Eigen::Ref<const VectorXs>& x);
164 boost::shared_ptr<Base> model_;
170 bool with_gauss_approx_;
174 template <
typename _Scalar>
176 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
178 typedef _Scalar Scalar;
190 template <
template <
typename Scalar>
class Model>
193 Rx(model->get_model()->get_nr(),
194 model->get_model()->get_state()->get_ndx()),
195 Ru(model->get_model()->get_nr(), model->get_model()->get_nu()),
196 dx(model->get_model()->get_state()->get_ndx()),
197 du(model->get_model()->get_nu()),
198 xp(model->get_model()->get_state()->get_nx()) {
205 const std::size_t ndx = model->get_model()->get_state()->get_ndx();
206 const std::size_t nu = model->get_model()->get_nu();
207 data_0 = model->get_model()->createData();
208 for (std::size_t i = 0; i < ndx; ++i) {
209 data_x.push_back(model->get_model()->createData());
211 for (std::size_t i = 0; i < nu; ++i) {
212 data_u.push_back(model->get_model()->createData());
238 Scalar xuh_hess_pow2;
246 std::vector<boost::shared_ptr<Base> >
248 std::vector<boost::shared_ptr<Base> >
257 #include "crocoddyl/core/numdiff/action.hxx"
Abstract class for 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 an action model.
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 void print(std::ostream &os) const
Print relevant information of the diff-action numdiff model.
ActionModelNumDiffTpl(boost::shared_ptr< Base > model, bool with_gauss_approx=false)
Initialize the numdiff action model.
virtual void calc(const boost::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the next state and cost value.
virtual void calcDiff(const boost::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the derivatives of the dynamics and cost functions.
const boost::shared_ptr< Base > & get_model() const
Return the acton model that we use to numerical differentiate.
virtual void calc(const boost::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
virtual void calcDiff(const boost::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
virtual boost::shared_ptr< ActionDataAbstract > createData()
Create the action data.
virtual void quasiStatic(const boost::shared_ptr< ActionDataAbstract > &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.
VectorXs xnext
evolution state
MatrixXs Fx
Jacobian of the dynamics w.r.t. the state .
MatrixXs Fu
Jacobian of the dynamics w.r.t. the control .
MatrixXs Luu
Hessian of the cost w.r.t. the control .
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 .
std::vector< boost::shared_ptr< Base > > data_u
The temporary data associated with the control variation.
Scalar x_norm
Norm of the state vector.
MatrixXs Ru
Cost residual jacobian: .
MatrixXs Rx
Cost residual jacobian: .
boost::shared_ptr< Base > data_0
The data that contains the final results.
Scalar uh_jac
Disturbance value used for computing .
Scalar xh_jac
Disturbance value used for computing .
VectorXs du
Control disturbance.
std::vector< boost::shared_ptr< Base > > data_x
The temporary data associated with the state variation.
ActionDataNumDiffTpl(Model< Scalar > *const model)
Initialize the numdiff action data.
VectorXs dx
State disturbance.