crocoddyl  1.6.0
Contact RObot COntrol by Differential DYnamic programming Library (Crocoddyl)
CostModelContactForceTpl< _Scalar > Class Template Reference

Define a contact force cost function. More...

#include <crocoddyl/multibody/costs/contact-force.hpp>

Inheritance diagram for CostModelContactForceTpl< _Scalar >:
Collaboration diagram for CostModelContactForceTpl< _Scalar >:

Public Types

typedef ActivationModelAbstractTpl< Scalar > ActivationModelAbstract
 
typedef CostModelAbstractTpl< Scalar > Base
 
typedef CostDataAbstractTpl< Scalar > CostDataAbstract
 
typedef CostDataContactForceTpl< Scalar > Data
 
typedef DataCollectorAbstractTpl< Scalar > DataCollectorAbstract
 
typedef FrameForceTpl< Scalar > FrameForce
 
typedef MathBaseTpl< Scalar > MathBase
 
typedef MathBase::MatrixXs MatrixXs
 
typedef StateMultibodyTpl< Scalar > StateMultibody
 
typedef MathBase::VectorXs VectorXs
 
- Public Types inherited from CostModelAbstractTpl< _Scalar >
typedef ActivationModelAbstractTpl< Scalar > ActivationModelAbstract
 
typedef ActivationModelQuadTpl< Scalar > ActivationModelQuad
 
typedef CostDataAbstractTpl< Scalar > CostDataAbstract
 
typedef DataCollectorAbstractTpl< Scalar > DataCollectorAbstract
 
typedef MathBaseTpl< Scalar > MathBase
 
typedef MathBase::MatrixXs MatrixXs
 
typedef StateAbstractTpl< Scalar > StateAbstract
 
typedef MathBase::VectorXs VectorXs
 

Public Member Functions

 CostModelContactForceTpl (boost::shared_ptr< StateMultibody > state, boost::shared_ptr< ActivationModelAbstract > activation, const FrameForce &fref, const std::size_t &nu)
 Initialize the contact force cost model. More...
 
 CostModelContactForceTpl (boost::shared_ptr< StateMultibody > state, boost::shared_ptr< ActivationModelAbstract > activation, const FrameForce &fref)
 Initialize the contact force cost model. More...
 
 CostModelContactForceTpl (boost::shared_ptr< StateMultibody > state, const FrameForce &fref, const std::size_t &nr, const std::size_t &nu)
 Initialize the contact force cost model. More...
 
 CostModelContactForceTpl (boost::shared_ptr< StateMultibody > state, const FrameForce &fref, const std::size_t &nr)
 Initialize the contact force cost model. More...
 
 CostModelContactForceTpl (boost::shared_ptr< StateMultibody > state, const FrameForce &fref)
 Initialize the contact force cost model. More...
 
virtual void calc (const boost::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
 Compute the contact force cost. More...
 
virtual void calcDiff (const boost::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
 Compute the derivatives of the contact force cost. More...
 
virtual boost::shared_ptr< CostDataAbstractcreateData (DataCollectorAbstract *const data)
 Create the contact force cost data. More...
 
 DEPRECATED ("Use set_reference<FrameForceTpl<Scalar> >()", void set_fref(const FrameForce &fref))
 
 DEPRECATED ("Use get_reference<FrameForceTpl<Scalar> >()", const FrameForce &get_fref() const)
 
- Public Member Functions inherited from CostModelAbstractTpl< _Scalar >
 CostModelAbstractTpl (boost::shared_ptr< StateAbstract > state, boost::shared_ptr< ActivationModelAbstract > activation, const std::size_t &nu)
 Initialize the cost model. More...
 
 CostModelAbstractTpl (boost::shared_ptr< StateAbstract > state, boost::shared_ptr< ActivationModelAbstract > activation)
 
 CostModelAbstractTpl (boost::shared_ptr< StateAbstract > state, const std::size_t &nr, const std::size_t &nu)
 
 CostModelAbstractTpl (boost::shared_ptr< StateAbstract > state, const std::size_t &nr)
 
virtual void calc (const boost::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)=0
 Compute the cost value and its residual vector. More...
 
void calc (const boost::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 
virtual void calcDiff (const boost::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)=0
 Compute the Jacobian and Hessian of cost and its residual vector. More...
 
void calcDiff (const boost::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 
const boost::shared_ptr< ActivationModelAbstract > & get_activation () const
 Return the activation model.
 
const std::size_t & get_nu () const
 Return the dimension of the control input.
 
template<class ReferenceType >
ReferenceType get_reference () const
 Return the cost reference.
 
const boost::shared_ptr< StateAbstract > & get_state () const
 Return the state.
 
template<class ReferenceType >
void set_reference (ReferenceType ref)
 Modify the cost reference.
 

Public Attributes

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar
 
- Public Attributes inherited from CostModelAbstractTpl< _Scalar >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar
 

Protected Member Functions

virtual void get_referenceImpl (const std::type_info &ti, void *pv) const
 Modify the reference spatial contact force \(\boldsymbol{\lambda}^*\).
 
virtual void set_referenceImpl (const std::type_info &ti, const void *pv)
 Return the reference spatial contact force \(\boldsymbol{\lambda}^*\).
 

Protected Attributes

FrameForce fref_
 Reference spatial contact force \(\boldsymbol{\lambda}^*\).
 
- Protected Attributes inherited from CostModelAbstractTpl< _Scalar >
boost::shared_ptr< ActivationModelAbstractactivation_
 Activation model.
 
std::size_t nu_
 Control dimension.
 
boost::shared_ptr< StateAbstractstate_
 State description.
 
VectorXs unone_
 No control vector.
 

Detailed Description

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

Define a contact force cost function.

This cost function defines a residual vector \(\mathbf{r}=\boldsymbol{\lambda}-\boldsymbol{\lambda}^*\), where \(\boldsymbol{\lambda}, \boldsymbol{\lambda}^*\) are the current and reference spatial forces, respetively. The current spatial forces \(\boldsymbol{\lambda}\in\mathbb{R}^{nc}\)is computed by DifferentialActionModelContactFwdDynamicsTpl, with nc as the dimension of the contact.

Both cost and residual derivatives are computed analytically, where th force vector \(\boldsymbol{\lambda}\) and its derivatives \(\left(\frac{\partial\boldsymbol{\lambda}}{\partial\mathbf{x}}, \frac{\partial\boldsymbol{\lambda}}{\partial\mathbf{u}}\right)\) are computed by DifferentialActionModelContactFwdDynamicsTpl. These values are stored in a shared data (i.e. DataCollectorContactTpl). Note that this cost function cannot be used with other action models. For the computation of the cost Hessian, we use the Gauss-Newton approximation, e.g. \(\mathbf{l_{xu}} = \mathbf{l_{x}}^T \mathbf{l_{u}} \).

See also
DifferentialActionModelContactFwdDynamicsTpl, DataCollectorContactTpl, ActivationModelAbstractTpl

Definition at line 44 of file contact-force.hpp.

Constructor & Destructor Documentation

◆ CostModelContactForceTpl() [1/5]

CostModelContactForceTpl ( boost::shared_ptr< StateMultibody state,
boost::shared_ptr< ActivationModelAbstract activation,
const FrameForce fref,
const std::size_t &  nu 
)

Initialize the contact force cost model.

Note that the nr, defined in the activation model, has to be lower / equals than 6.

Parameters
[in]stateMultibody state
[in]activationActivation model
[in]frefReference spatial contact force \(\boldsymbol{\lambda}^*\)
[in]nuDimension of control vector

◆ CostModelContactForceTpl() [2/5]

CostModelContactForceTpl ( boost::shared_ptr< StateMultibody state,
boost::shared_ptr< ActivationModelAbstract activation,
const FrameForce fref 
)

Initialize the contact force cost model.

The default nu is obtained from StateAbstractTpl::get_nv(). Note that the nr, defined in the activation model, has to be lower / equals than 6.

Parameters
[in]stateMultibody state
[in]activationActivation model
[in]frefReference spatial contact force \(\boldsymbol{\lambda}^*\)

◆ CostModelContactForceTpl() [3/5]

CostModelContactForceTpl ( boost::shared_ptr< StateMultibody state,
const FrameForce fref,
const std::size_t &  nr,
const std::size_t &  nu 
)

Initialize the contact force cost model.

We use ActivationModelQuadTpl as a default activation model (i.e. \(a=\frac{1}{2}\|\mathbf{r}\|^2\)). Note that the nr, defined in the activation model, has to be lower / equals than 6.

Parameters
[in]stateMultibody state
[in]frefReference spatial contact force \(\boldsymbol{\lambda}^*\)
[in]nrDimension of residual vector
[in]nuDimension of control vector

◆ CostModelContactForceTpl() [4/5]

CostModelContactForceTpl ( boost::shared_ptr< StateMultibody state,
const FrameForce fref,
const std::size_t &  nr 
)

Initialize the contact force cost model.

We use ActivationModelQuadTpl as a default activation model (i.e. \(a=\frac{1}{2}\|\mathbf{r}\|^2\)), and nu is obtained from StateAbstractTpl::get_nv(). Note that the nr, defined in the activation model, has to be lower / equals than 6.

Parameters
[in]stateMultibody state
[in]frefReference spatial contact force \(\boldsymbol{\lambda}^*\)
[in]nrDimension of residual vector

◆ CostModelContactForceTpl() [5/5]

CostModelContactForceTpl ( boost::shared_ptr< StateMultibody state,
const FrameForce fref 
)

Initialize the contact force cost model.

We use ActivationModelQuadTpl as a default activation model (i.e. \(a=\frac{1}{2}\|\mathbf{r}\|^2\)), and nr and nu are equals to 6 and StateAbstractTpl::get_nv(), respectively.

Parameters
[in]stateMultibody state
[in]frefReference spatial contact force \(\boldsymbol{\lambda}^*\)

Member Function Documentation

◆ calc()

virtual void calc ( const boost::shared_ptr< CostDataAbstract > &  data,
const Eigen::Ref< const VectorXs > &  x,
const Eigen::Ref< const VectorXs > &  u 
)
virtual

Compute the contact force cost.

The force vector is computed by DifferentialActionModelContactFwdDynamicsTpl and stored in DataCollectorContactTpl.

Parameters
[in]dataContact force data
[in]xState point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
[in]uControl input \(\mathbf{u}\in\mathbb{R}^{nu}\)

◆ calcDiff()

virtual void calcDiff ( const boost::shared_ptr< CostDataAbstract > &  data,
const Eigen::Ref< const VectorXs > &  x,
const Eigen::Ref< const VectorXs > &  u 
)
virtual

Compute the derivatives of the contact force cost.

The force derivatives are computed by DifferentialActionModelContactFwdDynamicsTpl and stored in DataCollectorContactTpl.

Parameters
[in]dataContact force data
[in]xState point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
[in]uControl input \(\mathbf{u}\in\mathbb{R}^{nu}\)

◆ createData()

virtual boost::shared_ptr<CostDataAbstract> createData ( DataCollectorAbstract *const  data)
virtual

Create the contact force cost data.

Parameters
[in]datashared data (it should be of type DataCollectorContactTpl)
Returns
the cost data.

Reimplemented from CostModelAbstractTpl< _Scalar >.


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