10 #ifndef CROCODDYL_CORE_STATE_BASE_HPP_
11 #define CROCODDYL_CORE_STATE_BASE_HPP_
13 #include "crocoddyl/core/fwd.hpp"
17 enum Jcomponent { both = 0, first = 1, second = 2 };
19 inline bool is_a_Jcomponent(Jcomponent firstsecond) {
20 return (firstsecond == first || firstsecond == second || firstsecond == both);
47 template <
typename _Scalar>
50 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
52 typedef _Scalar Scalar;
54 typedef typename MathBase::VectorXs VectorXs;
55 typedef typename MathBase::MatrixXs MatrixXs;
70 virtual VectorXs
zero()
const = 0;
75 virtual VectorXs
rand()
const = 0;
94 virtual void diff(
const Eigen::Ref<const VectorXs>& x0,
95 const Eigen::Ref<const VectorXs>& x1,
96 Eigen::Ref<VectorXs> dxout)
const = 0;
114 virtual void integrate(
const Eigen::Ref<const VectorXs>& x,
115 const Eigen::Ref<const VectorXs>& dx,
116 Eigen::Ref<VectorXs> xout)
const = 0;
159 virtual void Jdiff(
const Eigen::Ref<const VectorXs>& x0,
160 const Eigen::Ref<const VectorXs>& x1,
161 Eigen::Ref<MatrixXs> Jfirst, Eigen::Ref<MatrixXs> Jsecond,
162 const Jcomponent firstsecond = both)
const = 0;
204 const Eigen::Ref<const VectorXs>& dx,
205 Eigen::Ref<MatrixXs> Jfirst,
206 Eigen::Ref<MatrixXs> Jsecond,
207 const Jcomponent firstsecond = both,
208 const AssignmentOp op = setto)
const = 0;
225 const Eigen::Ref<const VectorXs>& dx,
226 Eigen::Ref<MatrixXs> Jin,
227 const Jcomponent firstsecond)
const = 0;
237 VectorXs
diff_dx(
const Eigen::Ref<const VectorXs>& x0,
238 const Eigen::Ref<const VectorXs>& x1);
248 const Eigen::Ref<const VectorXs>& dx);
257 std::vector<MatrixXs>
Jdiff_Js(
const Eigen::Ref<const VectorXs>& x0,
258 const Eigen::Ref<const VectorXs>& x1,
259 const Jcomponent firstsecond = both);
269 const Eigen::Ref<const VectorXs>& dx,
270 const Jcomponent firstsecond = both);
275 template <
class Scalar>
284 virtual void print(std::ostream& os)
const;
332 void update_has_limits();
348 #include "crocoddyl/core/state-base.hxx"
Abstract class for action model.
Abstract class for the state representation.
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.
std::vector< MatrixXs > Jdiff_Js(const Eigen::Ref< const VectorXs > &x0, const Eigen::Ref< const VectorXs > &x1, const Jcomponent firstsecond=both)
std::vector< MatrixXs > Jintegrate_Js(const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &dx, const Jcomponent firstsecond=both)
Compute the Jacobian of the state manifold integration.
VectorXs diff_dx(const Eigen::Ref< const VectorXs > &x0, const Eigen::Ref< const VectorXs > &x1)
Compute the state manifold differentiation.
virtual VectorXs rand() const =0
Generate a random state.
std::size_t nv_
Velocity dimension.
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 integrate(x, dx) to x.
std::size_t get_nq() const
Return the dimension of the configuration tuple.
virtual void print(std::ostream &os) const
Print relevant information of the state model.
std::size_t get_ndx() const
Return the dimension of the tangent space of the state manifold.
std::size_t get_nv() const
Return the dimension of tangent space of the configuration manifold.
const VectorXs & get_lb() const
Return the state lower bound.
std::size_t nx_
State dimension.
VectorXs integrate_x(const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &dx)
Compute the state manifold integration.
const VectorXs & get_ub() const
Return the state upper bound.
bool has_limits_
Indicates whether any of the state limits is finite.
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.
virtual VectorXs zero() const =0
Generate a zero state.
StateAbstractTpl(const std::size_t nx, const std::size_t ndx)
Initialize the state dimensions.
std::size_t nq_
Configuration dimension.
bool get_has_limits() const
Indicate if the state has defined limits.
VectorXs lb_
Lower state limits.
void set_ub(const VectorXs &ub)
Modify the state upper bound.
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.
friend std::ostream & operator<<(std::ostream &os, const ActionModelAbstractTpl< Scalar > &model)
Print information on the state model.
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.
std::size_t get_nx() const
Return the dimension of the state tuple.
void set_lb(const VectorXs &lb)
Modify the state lower bound.
std::size_t ndx_
State rate dimension.