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" 51 template <
typename _Scalar>
52 class ActionModelNumDiffTpl :
public ActionModelAbstractTpl<_Scalar> {
54 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
56 typedef _Scalar Scalar;
57 typedef ActionDataAbstractTpl<Scalar> ActionDataAbstract;
58 typedef ActionModelAbstractTpl<Scalar> Base;
59 typedef ActionDataNumDiffTpl<Scalar> Data;
60 typedef MathBaseTpl<Scalar> MathBase;
61 typedef typename MathBaseTpl<Scalar>::VectorXs VectorXs;
62 typedef typename MathBaseTpl<Scalar>::MatrixXs MatrixXs;
79 virtual void calc(
const boost::shared_ptr<ActionDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
80 const Eigen::Ref<const VectorXs>& u);
85 virtual void calcDiff(
const boost::shared_ptr<ActionDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
86 const Eigen::Ref<const VectorXs>& u);
93 virtual boost::shared_ptr<ActionDataAbstract>
createData();
100 const boost::shared_ptr<Base>&
get_model()
const;
145 void assertStableStateFD(
const Eigen::Ref<const VectorXs>& x);
151 boost::shared_ptr<Base> model_;
159 bool with_gauss_approx_;
162 template <
typename _Scalar>
163 struct ActionDataNumDiffTpl :
public ActionDataAbstractTpl<_Scalar> {
164 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
166 typedef _Scalar Scalar;
167 typedef MathBaseTpl<Scalar> MathBase;
168 typedef ActionDataAbstractTpl<Scalar> Base;
169 typedef typename MathBaseTpl<Scalar>::VectorXs VectorXs;
170 typedef typename MathBaseTpl<Scalar>::MatrixXs MatrixXs;
178 template <
template <
typename Scalar>
class Model>
192 const std::size_t ndx = model->get_model()->get_state()->get_ndx();
193 const std::size_t nu = model->get_model()->get_nu();
194 data_0 = model->get_model()->createData();
195 for (std::size_t i = 0; i < ndx; ++i) {
196 data_x.push_back(model->get_model()->createData());
198 for (std::size_t i = 0; i < nu; ++i) {
199 data_u.push_back(model->get_model()->createData());
220 std::vector<boost::shared_ptr<Base> >
data_x;
221 std::vector<boost::shared_ptr<Base> >
data_u;
229 #include "crocoddyl/core/numdiff/action.hxx" 231 #endif // CROCODDYL_CORE_NUMDIFF_ACTION_HPP_ virtual boost::shared_ptr< ActionDataAbstract > createData()
Create a Data object from the given model.
bool has_control_limits_
Indicates whether any of the control limits is finite.
MatrixXs Ru
Cost residual jacobian: .
const boost::shared_ptr< StateAbstract > & get_state() const
Return the state.
VectorXs dx
State disturbance.
const boost::shared_ptr< Base > & get_model() const
Get the model_ object.
std::size_t nu_
Control dimension.
std::size_t get_nu() const
Return the dimension of the control input.
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.
ActionDataNumDiffTpl(Model< Scalar > *const model)
Construct a new ActionDataNumDiff object.
const Scalar get_disturbance() const
Get the disturbance_ object.
virtual ~ActionModelNumDiffTpl()
Destroy the ActionModelNumDiff object.
VectorXs xp
The integrated state from the disturbance on one DoF "\f$ \int x dx_i \f$".
boost::shared_ptr< Base > data_0
The data that contains the final results.
std::size_t get_nr() const
Return the dimension of the cost-residual vector.
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.
ActionModelNumDiffTpl(boost::shared_ptr< Base > model, bool with_gauss_approx=false)
Construct a new ActionModelNumDiff object.
std::vector< boost::shared_ptr< Base > > data_u
The temporary data associated with the control variation.
MatrixXs Rx
Cost residual jacobian: .
VectorXs unone_
Neutral state.
VectorXs u_ub_
Upper control limits.
std::vector< boost::shared_ptr< Base > > data_x
The temporary data associated with the state variation.
VectorXs u_lb_
Lower control limits.
boost::shared_ptr< StateAbstract > state_
Model of the state.
void set_disturbance(const Scalar disturbance)
Set the disturbance_ object.
bool get_with_gauss_approx()
Identify if the Gauss approximation is going to be used or not.
VectorXs du
Control disturbance.
std::size_t nr_
Dimension of the cost residual.