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
35 typedef _Scalar Scalar;
42 typedef boost::function<void(
const VectorXs&,
const VectorXs&)>
60 virtual void calc(
const std::shared_ptr<ConstraintDataAbstract>& data,
61 const Eigen::Ref<const VectorXs>& x,
62 const Eigen::Ref<const VectorXs>& u)
override;
69 virtual void calc(
const std::shared_ptr<ConstraintDataAbstract>& data,
70 const Eigen::Ref<const VectorXs>& x)
override;
75 virtual void calcDiff(
const std::shared_ptr<ConstraintDataAbstract>& data,
76 const Eigen::Ref<const VectorXs>& x,
77 const Eigen::Ref<const VectorXs>& u)
override;
84 virtual void calcDiff(
const std::shared_ptr<ConstraintDataAbstract>& data,
85 const Eigen::Ref<const VectorXs>& x)
override;
90 virtual std::shared_ptr<ConstraintDataAbstract>
createData(
102 template <
typename NewScalar>
129 void set_reevals(
const std::vector<ReevaluationFunction>& reevals);
145 void assertStableStateFD(
const Eigen::Ref<const VectorXs>& );
147 std::shared_ptr<Base> model_;
151 std::vector<ReevaluationFunction>
155 template <
typename _Scalar>
157 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
159 typedef _Scalar Scalar;
166 template <
template <
typename Scalar>
class Model>
169 :
Base(model, shared_data),
170 dx(model->get_state()->get_ndx()),
171 xp(model->get_state()->get_nx()),
173 up(model->get_nu()) {
179 const std::size_t& ndx = model->get_model()->get_state()->get_ndx();
180 const std::size_t& nu = model->get_model()->get_nu();
181 data_0 = model->get_model()->createData(shared_data);
182 for (std::size_t i = 0; i < ndx; ++i) {
183 data_x.push_back(model->get_model()->createData(shared_data));
185 for (std::size_t i = 0; i < nu; ++i) {
186 data_u.push_back(model->get_model()->createData(shared_data));
210 std::vector<std::shared_ptr<Base> >
212 std::vector<std::shared_ptr<Base> >
221 #include "crocoddyl/core/numdiff/constraint.hxx"
Abstract class for constraint models.
std::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.
const std::shared_ptr< Base > & get_model() const
Return the original constraint model.
ConstraintModelNumDiffTpl< NewScalar > cast() const
Cast the constraint numdiff model to a different scalar type.
virtual void calc(const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u) override
Compute the constraint value.
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 ~ConstraintModelNumDiffTpl()=default
Initialize the numdiff constraint model.
virtual void calcDiff(const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x) override
ConstraintModelNumDiffTpl(const std::shared_ptr< Base > &model)
Initialize the numdiff constraint model.
virtual std::shared_ptr< ConstraintDataAbstract > createData(DataCollectorAbstract *const data) override
Create the constraint data.
virtual void calcDiff(const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u) override
Compute the Jacobian of the constraint.
virtual void calc(const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x) override
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.
Scalar x_norm
Norm of the state vector.
std::vector< std::shared_ptr< Base > > data_x
The temporary data associated with the state variation.
Scalar uh_jac
Disturbance value used for computing .
std::vector< std::shared_ptr< Base > > data_u
The temporary data associated with the control variation.
Scalar xh_jac
Disturbance value used for computing .
VectorXs du
Control disturbance.
std::shared_ptr< Base > data_0
The data at the approximation point.
VectorXs dx
State disturbance.