9 #ifndef CROCODDYL_CORE_NUMDIFF_CONSTRAINT_HPP_
10 #define CROCODDYL_CORE_NUMDIFF_CONSTRAINT_HPP_
12 #include <boost/function.hpp>
14 #include "crocoddyl/core/constraint-base.hpp"
29 template <
typename _Scalar>
32 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
34 typedef _Scalar Scalar;
41 typedef boost::function<void(
const VectorXs&,
const VectorXs&)>
59 virtual void calc(
const boost::shared_ptr<ConstraintDataAbstract>& data,
60 const Eigen::Ref<const VectorXs>& x,
61 const Eigen::Ref<const VectorXs>& u);
68 virtual void calc(
const boost::shared_ptr<ConstraintDataAbstract>& data,
69 const Eigen::Ref<const VectorXs>& x);
74 virtual void calcDiff(
const boost::shared_ptr<ConstraintDataAbstract>& data,
75 const Eigen::Ref<const VectorXs>& x,
76 const Eigen::Ref<const VectorXs>& u);
83 virtual void calcDiff(
const boost::shared_ptr<ConstraintDataAbstract>& data,
84 const Eigen::Ref<const VectorXs>& x);
89 virtual boost::shared_ptr<ConstraintDataAbstract>
createData(
116 void set_reevals(
const std::vector<ReevaluationFunction>& reevals);
132 void assertStableStateFD(
const Eigen::Ref<const VectorXs>& );
134 boost::shared_ptr<Base> model_;
138 std::vector<ReevaluationFunction>
142 template <
typename _Scalar>
144 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
146 typedef _Scalar Scalar;
153 template <
template <
typename Scalar>
class Model>
156 :
Base(model, shared_data),
157 dx(model->get_state()->get_ndx()),
158 xp(model->get_state()->get_nx()),
160 up(model->get_nu()) {
166 const std::size_t& ndx = model->get_model()->get_state()->get_ndx();
167 const std::size_t& nu = model->get_model()->get_nu();
168 data_0 = model->get_model()->createData(shared_data);
169 for (std::size_t i = 0; i < ndx; ++i) {
170 data_x.push_back(model->get_model()->createData(shared_data));
172 for (std::size_t i = 0; i < nu; ++i) {
173 data_u.push_back(model->get_model()->createData(shared_data));
197 std::vector<boost::shared_ptr<Base> >
199 std::vector<boost::shared_ptr<Base> >
208 #include "crocoddyl/core/numdiff/constraint.hxx"
Abstract class for constraint models.
boost::shared_ptr< StateAbstract > state_
State description.
std::size_t nu_
Control dimension.
VectorXs unone_
No control vector.
This class computes the numerical differentiation of a constraint model.
virtual boost::shared_ptr< ConstraintDataAbstract > createData(DataCollectorAbstract *const data)
Create the constraint data.
virtual ~ConstraintModelNumDiffTpl()
Initialize the numdiff constraint model.
virtual void calcDiff(const boost::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
const Scalar get_disturbance() const
Return the disturbance constant used by the numerical differentiation routine.
void set_reevals(const std::vector< ReevaluationFunction > &reevals)
Register functions that updates the shared data computed for a system rollout The updated data is use...
void set_disturbance(const Scalar disturbance)
Modify the disturbance constant used by the numerical differentiation routine.
virtual void calc(const boost::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
virtual void calc(const boost::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the constraint value.
virtual void calcDiff(const boost::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the Jacobian of the constraint.
const boost::shared_ptr< Base > & get_model() const
Return the original constraint model.
ConstraintModelNumDiffTpl(const boost::shared_ptr< Base > &model)
Initialize the numdiff constraint model.
MatrixXs Gx
Jacobian of the inequality constraint.
MatrixXs Hx
Jacobian of the equality constraint.
MatrixXs Hu
Jacobian of the equality constraint.
DataCollectorAbstract * shared
Shared data.
MatrixXs Gu
Jacobian of the inequality constraint.
std::vector< boost::shared_ptr< Base > > data_u
The temporary data associated with the control variation.
Scalar x_norm
Norm of the state vector.
boost::shared_ptr< Base > data_0
The data at the approximation point.
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.
VectorXs dx
State disturbance.