9 #ifndef CROCODDYL_CORE_STATE_BASE_HPP_ 10 #define CROCODDYL_CORE_STATE_BASE_HPP_ 16 #include "crocoddyl/core/fwd.hpp" 17 #include "crocoddyl/core/mathbase.hpp" 18 #include "crocoddyl/core/utils/exception.hpp" 22 enum Jcomponent { both = 0, first = 1, second = 2 };
23 enum AssignmentOp { setto, addto, rmfrom };
25 inline bool is_a_Jcomponent(Jcomponent firstsecond) {
26 return (firstsecond == first || firstsecond == second || firstsecond == both);
29 inline bool is_a_AssignmentOp(AssignmentOp op) {
return (op == setto || op == addto || op == rmfrom); }
42 template <
typename _Scalar>
43 class StateAbstractTpl {
45 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
47 typedef _Scalar Scalar;
48 typedef MathBaseTpl<Scalar> MathBase;
49 typedef typename MathBase::VectorXs VectorXs;
50 typedef typename MathBase::MatrixXs MatrixXs;
65 virtual VectorXs
zero()
const = 0;
70 virtual VectorXs
rand()
const = 0;
87 virtual void diff(
const Eigen::Ref<const VectorXs>& x0,
const Eigen::Ref<const VectorXs>& x1,
88 Eigen::Ref<VectorXs> dxout)
const = 0;
105 virtual void integrate(
const Eigen::Ref<const VectorXs>& x,
const Eigen::Ref<const VectorXs>& dx,
106 Eigen::Ref<VectorXs> xout)
const = 0;
142 virtual void Jdiff(
const Eigen::Ref<const VectorXs>& x0,
const Eigen::Ref<const VectorXs>& x1,
143 Eigen::Ref<MatrixXs> Jfirst, Eigen::Ref<MatrixXs> Jsecond,
144 const Jcomponent firstsecond = both)
const = 0;
178 virtual void Jintegrate(
const Eigen::Ref<const VectorXs>& x,
const Eigen::Ref<const VectorXs>& dx,
179 Eigen::Ref<MatrixXs> Jfirst, Eigen::Ref<MatrixXs> Jsecond,
180 const Jcomponent firstsecond = both,
const AssignmentOp op = setto)
const = 0;
194 virtual void JintegrateTransport(
const Eigen::Ref<const VectorXs>& x,
const Eigen::Ref<const VectorXs>& dx,
195 Eigen::Ref<MatrixXs> Jin,
const Jcomponent firstsecond)
const = 0;
204 VectorXs
diff_dx(
const Eigen::Ref<const VectorXs>& x0,
const Eigen::Ref<const VectorXs>& x1);
213 VectorXs
integrate_x(
const Eigen::Ref<const VectorXs>& x,
const Eigen::Ref<const VectorXs>& dx);
222 std::vector<MatrixXs>
Jdiff_Js(
const Eigen::Ref<const VectorXs>& x0,
const Eigen::Ref<const VectorXs>& x1,
223 const Jcomponent firstsecond = both);
232 std::vector<MatrixXs>
Jintegrate_Js(
const Eigen::Ref<const VectorXs>& x,
const Eigen::Ref<const VectorXs>& dx,
233 const Jcomponent firstsecond = both);
238 const std::size_t&
get_nx()
const;
243 const std::size_t&
get_ndx()
const;
248 const std::size_t&
get_nq()
const;
253 const std::size_t&
get_nv()
const;
258 const VectorXs&
get_lb()
const;
263 const VectorXs&
get_ub()
const;
273 void set_lb(
const VectorXs& lb);
278 void set_ub(
const VectorXs& ub);
281 void update_has_limits();
297 #include "crocoddyl/core/state-base.hxx" 299 #endif // CROCODDYL_CORE_STATE_BASE_HPP_ const std::size_t & get_ndx() const
Return the dimension of the tangent space of the state manifold.
void set_lb(const VectorXs &lb)
Modify the state lower bound.
void set_ub(const VectorXs &ub)
Modify the state upper bound.
VectorXs lb_
Lower state limits.
virtual void diff(const Eigen::Ref< const VectorXs > &x0, const Eigen::Ref< const VectorXs > &x1, Eigen::Ref< VectorXs > dxout) const =0
Compute the state manifold differentiation.
VectorXs ub_
Upper state limits.
virtual void Jintegrate(const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &dx, Eigen::Ref< MatrixXs > Jfirst, Eigen::Ref< MatrixXs > Jsecond, const Jcomponent firstsecond=both, const AssignmentOp op=setto) const =0
Compute the Jacobian of the state manifold integration.
const VectorXs & get_lb() const
Return the state lower bound.
virtual VectorXs zero() const =0
Generate a zero reference state.
std::vector< MatrixXs > Jintegrate_Js(const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &dx, const Jcomponent firstsecond=both)
std::vector< MatrixXs > Jdiff_Js(const Eigen::Ref< const VectorXs > &x0, const Eigen::Ref< const VectorXs > &x1, const Jcomponent firstsecond=both)
bool has_limits_
Indicates whether any of the state limits is finite.
StateAbstractTpl(const std::size_t &nx, const std::size_t &ndx)
Initialize the state dimensions.
bool const & get_has_limits() const
Indicate if the state has defined limits.
const std::size_t & get_nx() const
Return the dimension of the state tuple.
virtual void Jdiff(const Eigen::Ref< const VectorXs > &x0, const Eigen::Ref< const VectorXs > &x1, Eigen::Ref< MatrixXs > Jfirst, Eigen::Ref< MatrixXs > Jsecond, const Jcomponent firstsecond=both) const =0
Compute the Jacobian of the state manifold differentiation.
VectorXs diff_dx(const Eigen::Ref< const VectorXs > &x0, const Eigen::Ref< const VectorXs > &x1)
std::size_t nx_
State dimension.
virtual void integrate(const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &dx, Eigen::Ref< VectorXs > xout) const =0
Compute the state manifold integration.
std::size_t nv_
Velocity dimension.
VectorXs integrate_x(const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &dx)
virtual void JintegrateTransport(const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &dx, Eigen::Ref< MatrixXs > Jin, const Jcomponent firstsecond) const =0
Parallel transport from x + dx to x.
std::size_t ndx_
State rate dimension.
std::size_t nq_
Configuration dimension.
const VectorXs & get_ub() const
Return the state upper bound.
virtual VectorXs rand() const =0
Generate a random reference state.
const std::size_t & get_nv() const
Return the dimension of tangent space of the configuration manifold.
const std::size_t & get_nq() const
Return the dimension of the configuration tuple.