10#ifndef CROCODDYL_CORE_NUMDIFF_ACTION_HPP_
11#define CROCODDYL_CORE_NUMDIFF_ACTION_HPP_
15#include "crocoddyl/core/fwd.hpp"
16#include "crocoddyl/core/action-base.hpp"
41template <
typename _Scalar>
44 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
46 typedef _Scalar Scalar;
51 typedef typename MathBaseTpl<Scalar>::VectorXs VectorXs;
52 typedef typename MathBaseTpl<Scalar>::MatrixXs MatrixXs;
66 virtual void calc(
const boost::shared_ptr<ActionDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
67 const Eigen::Ref<const VectorXs>& u);
72 virtual void calc(
const boost::shared_ptr<ActionDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x);
77 virtual void calcDiff(
const boost::shared_ptr<ActionDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
78 const Eigen::Ref<const VectorXs>& u);
84 virtual void calcDiff(
const boost::shared_ptr<ActionDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x);
89 virtual boost::shared_ptr<ActionDataAbstract>
createData();
132 void assertStableStateFD(
const Eigen::Ref<const VectorXs>& x);
134 boost::shared_ptr<Base> model_;
136 bool with_gauss_approx_;
139template <
typename _Scalar>
141 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
143 typedef _Scalar Scalar;
146 typedef typename MathBaseTpl<Scalar>::VectorXs VectorXs;
147 typedef typename MathBaseTpl<Scalar>::MatrixXs MatrixXs;
155 template <
template <
typename Scalar>
class Model>
158 Rx(model->get_model()->get_nr(), model->get_model()->get_state()->get_ndx()),
159 Ru(model->get_model()->get_nr(), model->get_model()->get_nu()),
160 dx(model->get_model()->get_state()->get_ndx()),
161 du(model->get_model()->get_nu()),
162 xp(model->get_model()->get_state()->get_nx()) {
169 const std::size_t ndx = model->get_model()->get_state()->get_ndx();
170 const std::size_t nu = model->get_model()->get_nu();
171 data_0 = model->get_model()->createData();
172 for (std::size_t i = 0; i < ndx; ++i) {
173 data_x.push_back(model->get_model()->createData());
175 for (std::size_t i = 0; i < nu; ++i) {
176 data_u.push_back(model->get_model()->createData());
197 std::vector<boost::shared_ptr<Base> >
data_x;
198 std::vector<boost::shared_ptr<Base> >
data_u;
206#include "crocoddyl/core/numdiff/action.hxx"
Abstract class for action model.
VectorXs u_lb_
Lower control limits.
VectorXs u_ub_
Upper control limits.
bool has_control_limits_
Indicates whether any of the control limits is finite.
boost::shared_ptr< StateAbstract > state_
Model of the state.
std::size_t nu_
Control dimension.
VectorXs unone_
Neutral state.
std::size_t nr_
Dimension of the cost residual.
This class computes the numerical differentiation of an action model.
const boost::shared_ptr< Base > & get_model() const
Return the acton model that we use to numerical differentiate.
const Scalar get_disturbance() const
Return the disturbance 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 used in the numerical differentiation routine.
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.
virtual boost::shared_ptr< ActionDataAbstract > createData()
Create the action data.
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)
VectorXs xnext
evolution state
MatrixXs Fx
Jacobian of the dynamics.
MatrixXs Fu
Jacobian of the dynamics.
MatrixXs Luu
Hessian of the cost function.
VectorXs Lx
Jacobian of the cost function.
MatrixXs Lxx
Hessian of the cost function.
VectorXs Lu
Jacobian of the cost function.
MatrixXs Lxu
Hessian of the cost function.
std::vector< boost::shared_ptr< Base > > data_u
The temporary data associated with the control variation.
MatrixXs Ru
Cost residual jacobian: .
MatrixXs Rx
Cost residual jacobian: .
boost::shared_ptr< Base > data_0
The data that contains the final results.
VectorXs xp
The integrated state from the disturbance on one DoF "\f$ \int x dx_i \f$".
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.