Crocoddyl
Loading...
Searching...
No Matches
StateAbstractTpl< _Scalar > Class Template Referenceabstract

Abstract class for the state representation. More...

#include <state-base.hpp>

Inheritance diagram for StateAbstractTpl< _Scalar >:
StateBaseStateMultibodyTpl< _Scalar >StateNumDiffTpl< _Scalar >StateVectorTpl< _Scalar >

Public Types

typedef MathBaseTpl< Scalar > MathBase
typedef MathBase::MatrixXs MatrixXs
typedef MathBase::VectorXs VectorXs

Public Member Functions

 StateAbstractTpl (const std::size_t nx, const std::size_t ndx)
 Initialize the state dimensions.
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 diff_dx (const Eigen::Ref< const VectorXs > &x0, const Eigen::Ref< const VectorXs > &x1)
 Compute the state manifold differentiation.
bool get_has_limits () const
 Indicate if the state has defined limits.
const VectorXs & get_lb () const
 Return the state lower bound.
std::size_t get_ndx () const
 Return the dimension of the tangent space of the state manifold.
std::size_t get_nq () const
 Return the dimension of the configuration tuple.
std::size_t get_nv () const
 Return the dimension of tangent space of the configuration manifold.
std::size_t get_nx () const
 Return the dimension of the state tuple.
const VectorXs & get_ub () const
 Return 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.
VectorXs integrate_x (const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &dx)
 Compute the state manifold integration.
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)
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::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.
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.
virtual void print (std::ostream &os) const
 Print relevant information of the state model.
virtual VectorXs rand () const =0
 Generate a random state.
void set_lb (const VectorXs &lb)
 Modify the state lower bound.
void set_ub (const VectorXs &ub)
 Modify the state upper bound.
virtual VectorXs zero () const =0
 Generate a zero state.

Public Attributes

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar

Protected Member Functions

void update_has_limits ()

Protected Attributes

bool has_limits_
 Indicates whether any of the state limits is finite.
VectorXs lb_
 Lower state limits.
std::size_t ndx_
 State rate dimension.
std::size_t nq_
 Configuration dimension.
std::size_t nv_
 Velocity dimension.
std::size_t nx_
 State dimension.
VectorXs ub_
 Upper state limits.

Friends

template<class Scalar>
std::ostream & operator<< (std::ostream &os, const ActionModelAbstractTpl< Scalar > &model)
 Print information on the state model.

Detailed Description

template<typename _Scalar>
class crocoddyl::StateAbstractTpl< _Scalar >

Abstract class for the state representation.

A state is represented by its operators: difference, integrates, transport and their derivatives. The difference operator returns the value of $\mathbf{x}_{1}\ominus\mathbf{x}_{0}$ operation. Instead the integrate operator returns the value of $\mathbf{x}\oplus\delta\mathbf{x}$. These operators are used to compared two points on the state manifold $\mathcal{M}$ or to advance the state given a tangential velocity ( $T_\mathbf{x} \mathcal{M}$). Therefore the points $\mathbf{x}$, $\mathbf{x}_{0}$ and $\mathbf{x}_{1}$ belong to the manifold $\mathcal{M}$; and $\delta\mathbf{x}$ or $\mathbf{x}_{1}\ominus\mathbf{x}_{0}$ lie on its tangential space.

See also
diff(), integrate(), Jdiff(), Jintegrate() and JintegrateTransport()

Definition at line 48 of file state-base.hpp.

Member Typedef Documentation

◆ MathBase

template<typename _Scalar>
typedef MathBaseTpl<Scalar> MathBase

Definition at line 53 of file state-base.hpp.

◆ VectorXs

template<typename _Scalar>
typedef MathBase::VectorXs VectorXs

Definition at line 54 of file state-base.hpp.

◆ MatrixXs

template<typename _Scalar>
typedef MathBase::MatrixXs MatrixXs

Definition at line 55 of file state-base.hpp.

Constructor & Destructor Documentation

◆ StateAbstractTpl()

template<typename _Scalar>
StateAbstractTpl(const std::size_tnx,
const std::size_tndx )

Initialize the state dimensions.

Parameters
[in]nxDimension of state configuration tuple
[in]ndxDimension of state tangent vector

Member Function Documentation

◆ zero()

◆ rand()

◆ diff()

template<typename _Scalar>
virtual void diff(const Eigen::Ref< const VectorXs > &x0,
const Eigen::Ref< const VectorXs > &x1,
Eigen::Ref< VectorXs >dxout ) const
pure virtual

Compute the state manifold differentiation.

The state differentiation is defined as:

\begin{equation*}  \delta\mathbf{x} = \mathbf{x}_{1} \ominus \mathbf{x}_{0},
\end{equation*}

where $\mathbf{x}_{1}$, $\mathbf{x}_{0}$ are the current and previous state which lie in a manifold $\mathcal{M}$, and $\delta\mathbf{x} \in T_\mathbf{x} \mathcal{M}$ is the rate of change in the state in the tangent space of the manifold.

Parameters
[in]x0Previous state point (size nx)
[in]x1Current state point (size nx)
[out]dxoutDifference between the current and previous state points (size ndx)

Implemented in StateMultibodyTpl< _Scalar >, StateMultibodyTpl< double >, StateMultibodyTpl< Scalar >, StateNumDiffTpl< _Scalar >, StateNumDiffTpl< double >, StateVectorTpl< _Scalar >, StateVectorTpl< double >, and StateVectorTpl< Scalar >.

◆ integrate()

template<typename _Scalar>
virtual void integrate(const Eigen::Ref< const VectorXs > &x,
const Eigen::Ref< const VectorXs > &dx,
Eigen::Ref< VectorXs >xout ) const
pure virtual

Compute the state manifold integration.

The state integration is defined as:

\begin{equation*}  \mathbf{x}_{next} = \mathbf{x} \oplus \delta\mathbf{x},
\end{equation*}

where $\mathbf{x}$, $\mathbf{x}_{next}$ are the current and next state which lie in a manifold $\mathcal{M}$, and $\delta\mathbf{x}
\in T_\mathbf{x} \mathcal{M}$ is the rate of change in the state in the tangent space of the manifold.

Parameters
[in]xState point (size nx)
[in]dxVelocity vector (size ndx)
[out]xoutNext state point (size nx)

Implemented in StateMultibodyTpl< _Scalar >, StateMultibodyTpl< double >, StateMultibodyTpl< Scalar >, StateNumDiffTpl< _Scalar >, StateNumDiffTpl< double >, StateVectorTpl< _Scalar >, StateVectorTpl< double >, and StateVectorTpl< Scalar >.

◆ Jdiff()

template<typename _Scalar>
virtual void Jdiff(const Eigen::Ref< const VectorXs > &x0,
const Eigen::Ref< const VectorXs > &x1,
Eigen::Ref< MatrixXs >Jfirst,
Eigen::Ref< MatrixXs >Jsecond,
const Jcomponentfirstsecond = both ) const
pure virtual

Compute the Jacobian of the state manifold differentiation.

The state differentiation is defined as:

\begin{equation*}  \delta\mathbf{x} = \mathbf{x}_{1} \ominus \mathbf{x}_{0},
\end{equation*}

where $\mathbf{x}_{1}$, $\mathbf{x}_{0}$ are the current and previous state which lie in a manifold $\mathcal{M}$, and $\delta\mathbf{x} \in T_\mathbf{x} \mathcal{M}$ is the rate of change in the state in the tangent space of the manifold.

The Jacobians lie in the tangent space of manifold, i.e. $\mathbb{R}^{\textrm{ndx}\times\textrm{ndx}}$. Note that the state is represented as a tuple of nx values and its dimension is ndx. Calling $\boldsymbol{\Delta}(\mathbf{x}_{0}, \mathbf{x}_{1}) $, the difference function, these Jacobians satisfy the following relationships:

  • $\boldsymbol{\Delta}(\mathbf{x}_{0},\mathbf{x}_{0}\oplus\delta\mathbf{y})
- \boldsymbol{\Delta}(\mathbf{x}_{0},\mathbf{x}_{1}) =
\mathbf{J}_{\mathbf{x}_{1}}\delta\mathbf{y} +
\mathbf{o}(\mathbf{x}_{0})$.
  • $\boldsymbol{\Delta}(\mathbf{x}_{0}\oplus\delta\mathbf{y},\mathbf{x}_{1})
- \boldsymbol{\Delta}(\mathbf{x}_{0},\mathbf{x}_{1}) =
\mathbf{J}_{\mathbf{x}_{0}}\delta\mathbf{y} +
\mathbf{o}(\mathbf{x}_{0})$,

where $\mathbf{J}_{\mathbf{x}_{1}}$ and $\mathbf{J}_{\mathbf{x}_{0}}$ are the Jacobian with respect to the current and previous state, respectively.

Parameters
[in]x0Previous state point (size nx)
[in]x1Current state point (size nx)
[out]JfirstJacobian of the difference operation relative to the previous state point (size ndx $\times$ndx)
[out]JsecondJacobian of the difference operation relative to the current state point (size ndx $\times$ndx)
[in]firstsecondArgument (either x0 and / or x1) with respect to which the differentiation is performed.

Implemented in StateMultibodyTpl< _Scalar >, StateMultibodyTpl< double >, StateMultibodyTpl< Scalar >, StateNumDiffTpl< _Scalar >, StateNumDiffTpl< double >, StateVectorTpl< _Scalar >, StateVectorTpl< double >, and StateVectorTpl< Scalar >.

◆ Jintegrate()

template<typename _Scalar>
virtual void Jintegrate(const Eigen::Ref< const VectorXs > &x,
const Eigen::Ref< const VectorXs > &dx,
Eigen::Ref< MatrixXs >Jfirst,
Eigen::Ref< MatrixXs >Jsecond,
const Jcomponentfirstsecond = both,
const AssignmentOpop = setto ) const
pure virtual

Compute the Jacobian of the state manifold integration.

The state integration is defined as:

\begin{equation*}  \mathbf{x}_{next} = \mathbf{x} \oplus \delta\mathbf{x},
\end{equation*}

where $\mathbf{x}$, $\mathbf{x}_{next}$ are the current and next state which lie in a manifold $\mathcal{M}$, and $\delta\mathbf{x}
\in T_\mathbf{x} \mathcal{M}$ is the rate of change in the state in the tangent space of the manifold.

The Jacobians lie in the tangent space of manifold, i.e. $\mathbb{R}^{\textrm{ndx}\times\textrm{ndx}}$. Note that the state is represented as a tuple of nx values and its dimension is ndx. Calling $ \mathbf{f}(\mathbf{x}, \delta\mathbf{x}) $, the integrate function, these Jacobians satisfy the following relationships:

  • $\mathbf{f}(\mathbf{x}\oplus\delta\mathbf{y},\delta\mathbf{x})\ominus\mathbf{f}(\mathbf{x},\delta\mathbf{x})
= \mathbf{J}_\mathbf{x}\delta\mathbf{y} + \mathbf{o}(\delta\mathbf{x})$.
  • $\mathbf{f}(\mathbf{x},\delta\mathbf{x}+\delta\mathbf{y})\ominus\mathbf{f}(\mathbf{x},\delta\mathbf{x})
= \mathbf{J}_{\delta\mathbf{x}}\delta\mathbf{y} +
\mathbf{o}(\delta\mathbf{x})$,

where $\mathbf{J}_{\delta\mathbf{x}}$ and $\mathbf{J}_{\mathbf{x}}$ are the Jacobian with respect to the state and velocity, respectively.

Parameters
[in]xState point (size nx)
[in]dxVelocity vector (size ndx)
[out]JfirstJacobian of the integration operation relative to the state point (size ndx $\times$ndx)
[out]JsecondJacobian of the integration operation relative to the velocity vector (size ndx $\times$ndx)
[in]firstsecondArgument (either x and / or dx) with respect to which the differentiation is performed
[in]opAssignment operator which sets, adds, or removes the given Jacobian matrix

Implemented in StateMultibodyTpl< _Scalar >, StateMultibodyTpl< double >, StateMultibodyTpl< Scalar >, StateNumDiffTpl< _Scalar >, StateNumDiffTpl< double >, StateVectorTpl< _Scalar >, StateVectorTpl< double >, and StateVectorTpl< Scalar >.

◆ JintegrateTransport()

template<typename _Scalar>
virtual void JintegrateTransport(const Eigen::Ref< const VectorXs > &x,
const Eigen::Ref< const VectorXs > &dx,
Eigen::Ref< MatrixXs >Jin,
const Jcomponentfirstsecond ) const
pure virtual

Parallel transport from integrate(x, dx) to x.

This function performs the parallel transportation of an input matrix whose columns are expressed in the tangent space at $\mathbf{x}\oplus\delta\mathbf{x}$ to the tangent space at $\mathbf{x}$ point.

Parameters
[in]xState point (size nx).
[in]dxVelocity vector (size ndx)
[out]JinInput matrix (number of rows = nv).
[in]firstsecondArgument (either x or dx) with respect to which the differentiation of Jintegrate is performed.

Implemented in StateMultibodyTpl< _Scalar >, StateMultibodyTpl< double >, StateMultibodyTpl< Scalar >, StateNumDiffTpl< _Scalar >, StateNumDiffTpl< double >, StateVectorTpl< _Scalar >, StateVectorTpl< double >, and StateVectorTpl< Scalar >.

◆ diff_dx()

template<typename _Scalar>
VectorXs diff_dx(const Eigen::Ref< const VectorXs > &x0,
const Eigen::Ref< const VectorXs > &x1 )

Compute the state manifold differentiation.

Parameters
[in]x0Previous state point (size nx)
[in]x1Current state point (size nx)
Returns
Difference between the current and previous state points (size ndx)

◆ integrate_x()

template<typename _Scalar>
VectorXs integrate_x(const Eigen::Ref< const VectorXs > &x,
const Eigen::Ref< const VectorXs > &dx )

Compute the state manifold integration.

Parameters
[in]xState point (size nx)
[in]dxVelocity vector (size ndx)
Returns
Next state point (size nx)

◆ Jdiff_Js()

template<typename _Scalar>
std::vector< MatrixXs > Jdiff_Js(const Eigen::Ref< const VectorXs > &x0,
const Eigen::Ref< const VectorXs > &x1,
const Jcomponentfirstsecond = both )

Parameters
[in]x0Previous state point (size nx)
[in]x1Current state point (size nx)
Returns
Jacobians

◆ Jintegrate_Js()

template<typename _Scalar>
std::vector< MatrixXs > Jintegrate_Js(const Eigen::Ref< const VectorXs > &x,
const Eigen::Ref< const VectorXs > &dx,
const Jcomponentfirstsecond = both )

Compute the Jacobian of the state manifold integration.

Parameters
[in]xState point (size nx)
[in]dxVelocity vector (size ndx)
Returns
Jacobians

◆ print()

template<typename _Scalar>
virtual void print(std::ostream &os)const
virtual

Member Data Documentation

◆ Scalar

template<typename _Scalar>
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar

Definition at line 52 of file state-base.hpp.

◆ nx_

template<typename _Scalar>
std::size_t nx_
protected

State dimension.

Definition at line 334 of file state-base.hpp.

◆ ndx_

template<typename _Scalar>
std::size_t ndx_
protected

State rate dimension.

Definition at line 335 of file state-base.hpp.

◆ nq_

template<typename _Scalar>
std::size_t nq_
protected

Configuration dimension.

Definition at line 336 of file state-base.hpp.

◆ nv_

template<typename _Scalar>
std::size_t nv_
protected

Velocity dimension.

Definition at line 337 of file state-base.hpp.

◆ lb_

template<typename _Scalar>
VectorXs lb_
protected

Lower state limits.

Definition at line 338 of file state-base.hpp.

◆ ub_

template<typename _Scalar>
VectorXs ub_
protected

Upper state limits.

Definition at line 339 of file state-base.hpp.

◆ has_limits_

template<typename _Scalar>
bool has_limits_
protected

Indicates whether any of the state limits is finite.

Definition at line 340 of file state-base.hpp.


The documentation for this class was generated from the following files: