OCS2 Manual  v1.0.0
OCS2 Documentation
ocs2::ConstraintBase< STATE_DIM, INPUT_DIM > Class Template Reference

#include <ConstraintBase.h>

Detailed Description

template<size_t STATE_DIM, size_t INPUT_DIM>
class ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >

Base class for the constraints and its Derivatives. The linearized constraints are defined as:
Here we consider three types of constraints:

  • state-input constraints, $ g_1(x,u,t) = 0$,
  • state-only constraints, $ g_2(x,t) = 0$.
  • inequality constraint, $ h(x,u,t) \geq 0$

    $ x $, $ u $, and $ t $ are state, input, and vector of event times respectively.

  • Linearized state-input constraints: $ C(t) \delta x + D(t) \delta u + e(t) = 0 $
  • Linearized only-state constraints: $ F(t) \delta x + h(t) = 0 $
  • Linearized only-state final constraints: $ F_f(t) \delta x + h_f(t) = 0 $
  • Quadratic approximation of each inequality constraint: $ h_{0,i}(t) + h_{x,i}(t) \delta x + h_{u,i}(t) \delta u $
    $ \qquad + 0.5 \delta x H_{xx,i}(t) \delta x + \delta u H_{ux,i}(t) \delta x + 0.5 \delta u H_{uu,i}(t) \delta u \geq 0 \quad \forall i $
Template Parameters
STATE_DIMDimension of the state space.
INPUT_DIMDimension of the control input space.
Inheritance diagram for ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >:
ocs2::ConstraintBaseAD< STATE_DIM, INPUT_DIM > ocs2::LinearConstraint< STATE_DIM, INPUT_DIM >

Public Types

using Ptr = std::shared_ptr< ConstraintBase< STATE_DIM, INPUT_DIM > >
 
using ConstPtr = std::shared_ptr< const ConstraintBase< STATE_DIM, INPUT_DIM > >
 
using DIMENSIONS = Dimensions< STATE_DIM, INPUT_DIM >
 
using scalar_t = typename DIMENSIONS::scalar_t
 
using scalar_array_t = typename DIMENSIONS::scalar_array_t
 
using state_vector_t = typename DIMENSIONS::state_vector_t
 
using state_vector_array_t = typename DIMENSIONS::state_vector_array_t
 
using input_vector_t = typename DIMENSIONS::input_vector_t
 
using input_vector_array_t = typename DIMENSIONS::input_vector_array_t
 
using state_matrix_t = typename DIMENSIONS::state_matrix_t
 
using state_matrix_array_t = typename DIMENSIONS::state_matrix_array_t
 
using input_matrix_t = typename DIMENSIONS::input_matrix_t
 
using input_matrix_array_t = typename DIMENSIONS::input_matrix_array_t
 
using state_input_matrix_t = typename DIMENSIONS::state_input_matrix_t
 
using input_state_matrix_t = typename DIMENSIONS::input_state_matrix_t
 
using input_state_matrix_array_t = typename DIMENSIONS::input_state_matrix_array_t
 
using constraint1_vector_t = typename DIMENSIONS::constraint1_vector_t
 
using constraint1_vector_array_t = typename DIMENSIONS::constraint1_vector_array_t
 
using constraint2_vector_t = typename DIMENSIONS::constraint2_vector_t
 
using constraint2_vector_array_t = typename DIMENSIONS::constraint2_vector_array_t
 
using constraint1_state_matrix_t = typename DIMENSIONS::constraint1_state_matrix_t
 
using constraint1_input_matrix_t = typename DIMENSIONS::constraint1_input_matrix_t
 
using constraint2_state_matrix_t = typename DIMENSIONS::constraint2_state_matrix_t
 

Public Member Functions

 ConstraintBase ()=default
 
 ConstraintBase (const ConstraintBase &rhs)=default
 
virtual ~ConstraintBase ()=default
 
virtual void setCurrentStateAndControl (const scalar_t &t, const state_vector_t &x, const input_vector_t &u)
 
virtual ConstraintBase< STATE_DIM, INPUT_DIM > * clone () const
 
virtual void getConstraint1 (constraint1_vector_t &e)
 
virtual size_t numStateInputConstraint (const scalar_t &time)
 
virtual void getConstraint2 (constraint2_vector_t &h)
 
virtual size_t numStateOnlyConstraint (const scalar_t &time)
 
virtual void getInequalityConstraint (scalar_array_t &h)
 
virtual size_t numInequalityConstraint (const scalar_t &time)
 
virtual void getFinalConstraint2 (constraint2_vector_t &h_f)
 
virtual size_t numStateOnlyFinalConstraint (const scalar_t &time)
 
virtual void getConstraint1DerivativesState (constraint1_state_matrix_t &C)
 
virtual void getConstraint1DerivativesControl (constraint1_input_matrix_t &D)
 
virtual void getConstraint1DerivativesEventTimes (constraint1_vector_array_t &g1DevArray)
 
virtual void getConstraint2DerivativesState (constraint2_state_matrix_t &F)
 
virtual void getInequalityConstraintDerivativesState (state_vector_array_t &dhdx)
 
virtual void getInequalityConstraintDerivativesInput (input_vector_array_t &dhdu)
 
virtual void getInequalityConstraintSecondDerivativesState (state_matrix_array_t &ddhdxdx)
 
virtual void getInequalityConstraintSecondDerivativesInput (input_matrix_array_t &ddhdudu)
 
virtual void getInequalityConstraintDerivativesInputState (input_state_matrix_array_t &ddhdudx)
 
virtual void getFinalConstraint2DerivativesState (constraint2_state_matrix_t &F_f)
 

Protected Attributes

scalar_t t_
 
state_vector_t x_
 
input_vector_t u_
 

Member Typedef Documentation

◆ ConstPtr

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::ConstPtr = std::shared_ptr<const ConstraintBase<STATE_DIM, INPUT_DIM> >

◆ constraint1_input_matrix_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::constraint1_input_matrix_t = typename DIMENSIONS::constraint1_input_matrix_t

◆ constraint1_state_matrix_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::constraint1_state_matrix_t = typename DIMENSIONS::constraint1_state_matrix_t

◆ constraint1_vector_array_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::constraint1_vector_array_t = typename DIMENSIONS::constraint1_vector_array_t

◆ constraint1_vector_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::constraint1_vector_t = typename DIMENSIONS::constraint1_vector_t

◆ constraint2_state_matrix_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::constraint2_state_matrix_t = typename DIMENSIONS::constraint2_state_matrix_t

◆ constraint2_vector_array_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::constraint2_vector_array_t = typename DIMENSIONS::constraint2_vector_array_t

◆ constraint2_vector_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::constraint2_vector_t = typename DIMENSIONS::constraint2_vector_t

◆ DIMENSIONS

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::DIMENSIONS = Dimensions<STATE_DIM, INPUT_DIM>

◆ input_matrix_array_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::input_matrix_array_t = typename DIMENSIONS::input_matrix_array_t

◆ input_matrix_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::input_matrix_t = typename DIMENSIONS::input_matrix_t

◆ input_state_matrix_array_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::input_state_matrix_array_t = typename DIMENSIONS::input_state_matrix_array_t

◆ input_state_matrix_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::input_state_matrix_t = typename DIMENSIONS::input_state_matrix_t

◆ input_vector_array_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::input_vector_array_t = typename DIMENSIONS::input_vector_array_t

◆ input_vector_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::input_vector_t = typename DIMENSIONS::input_vector_t

◆ Ptr

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::Ptr = std::shared_ptr<ConstraintBase<STATE_DIM, INPUT_DIM> >

◆ scalar_array_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::scalar_array_t = typename DIMENSIONS::scalar_array_t

◆ scalar_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::scalar_t = typename DIMENSIONS::scalar_t

◆ state_input_matrix_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::state_input_matrix_t = typename DIMENSIONS::state_input_matrix_t

◆ state_matrix_array_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::state_matrix_array_t = typename DIMENSIONS::state_matrix_array_t

◆ state_matrix_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::state_matrix_t = typename DIMENSIONS::state_matrix_t

◆ state_vector_array_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::state_vector_array_t = typename DIMENSIONS::state_vector_array_t

◆ state_vector_t

template<size_t STATE_DIM, size_t INPUT_DIM>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::state_vector_t = typename DIMENSIONS::state_vector_t

Constructor & Destructor Documentation

◆ ConstraintBase() [1/2]

template<size_t STATE_DIM, size_t INPUT_DIM>
ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::ConstraintBase ( )
default

Default constructor

◆ ConstraintBase() [2/2]

template<size_t STATE_DIM, size_t INPUT_DIM>
ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::ConstraintBase ( const ConstraintBase< STATE_DIM, INPUT_DIM > &  rhs)
default

Default copy constructor

◆ ~ConstraintBase()

template<size_t STATE_DIM, size_t INPUT_DIM>
virtual ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::~ConstraintBase ( )
virtualdefault

Default destructor

Member Function Documentation

◆ clone()

◆ getConstraint1()

template<size_t STATE_DIM, size_t INPUT_DIM>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::getConstraint1 ( constraint1_vector_t e)
inlinevirtual

◆ getConstraint1DerivativesControl()

template<size_t STATE_DIM, size_t INPUT_DIM>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::getConstraint1DerivativesControl ( constraint1_input_matrix_t D)
inlinevirtual

◆ getConstraint1DerivativesEventTimes()

template<size_t STATE_DIM, size_t INPUT_DIM>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::getConstraint1DerivativesEventTimes ( constraint1_vector_array_t g1DevArray)
inlinevirtual

calculate and retrieve the the derivative of the state-input constraints w.r.t. event times. g1DevArray[i] is a vector of dimension MAX_CONSTRAINT1_DIM_ which is the partial derivative of state-input equality constraints with respect to i'th event time.

Note that only nc1 top rows of g1DevArray[i] are valid where nc1 is the number of active state-input constraints at the current time.

If the constraints are not a function of event times either set the array size to zero (as the default) implementation or set it to an array of zero vector with a size equal to number event times.

Parameters
[out]g1DevArrayan array of nc1-by-1 vector.

◆ getConstraint1DerivativesState()

template<size_t STATE_DIM, size_t INPUT_DIM>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::getConstraint1DerivativesState ( constraint1_state_matrix_t C)
inlinevirtual

◆ getConstraint2()

template<size_t STATE_DIM, size_t INPUT_DIM>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::getConstraint2 ( constraint2_vector_t h)
inlinevirtual

◆ getConstraint2DerivativesState()

template<size_t STATE_DIM, size_t INPUT_DIM>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::getConstraint2DerivativesState ( constraint2_state_matrix_t F)
inlinevirtual

◆ getFinalConstraint2()

template<size_t STATE_DIM, size_t INPUT_DIM>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::getFinalConstraint2 ( constraint2_vector_t h_f)
inlinevirtual

Compute the final state-only equality constraints.

Parameters
[out]h_fThe final state-only (in)equality constraints value.

Reimplemented in ocs2::LinearConstraint< STATE_DIM, INPUT_DIM >, ocs2::LoopshapingConstraint< FULL_STATE_DIM, FULL_INPUT_DIM, SYSTEM_STATE_DIM, SYSTEM_INPUT_DIM, FILTER_STATE_DIM, FILTER_INPUT_DIM >, and ocs2::ConstraintBaseAD< STATE_DIM, INPUT_DIM >.

◆ getFinalConstraint2DerivativesState()

template<size_t STATE_DIM, size_t INPUT_DIM>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::getFinalConstraint2DerivativesState ( constraint2_state_matrix_t F_f)
inlinevirtual

The F matrix at a given operating point for the linearized terminal state-only constraints, $ F_f(t) \delta x + h_f(t) = 0 $.

Parameters
[out]F_f$ F_f(t) $ matrix.

Reimplemented in ocs2::LinearConstraint< STATE_DIM, INPUT_DIM >, ocs2::LoopshapingConstraint< FULL_STATE_DIM, FULL_INPUT_DIM, SYSTEM_STATE_DIM, SYSTEM_INPUT_DIM, FILTER_STATE_DIM, FILTER_INPUT_DIM >, and ocs2::ConstraintBaseAD< STATE_DIM, INPUT_DIM >.

◆ getInequalityConstraint()

template<size_t STATE_DIM, size_t INPUT_DIM>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::getInequalityConstraint ( scalar_array_t h)
inlinevirtual

◆ getInequalityConstraintDerivativesInput()

◆ getInequalityConstraintDerivativesInputState()

template<size_t STATE_DIM, size_t INPUT_DIM>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::getInequalityConstraintDerivativesInputState ( input_state_matrix_array_t ddhdudx)
inlinevirtual

◆ getInequalityConstraintDerivativesState()

◆ getInequalityConstraintSecondDerivativesInput()

◆ getInequalityConstraintSecondDerivativesState()

◆ numInequalityConstraint()

template<size_t STATE_DIM, size_t INPUT_DIM>
virtual size_t ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::numInequalityConstraint ( const scalar_t time)
inlinevirtual

Get the number of inequality constraints.

Parameters
[in]timetime.
Returns
number of inequality constraints.

Reimplemented in ocs2::LinearConstraint< STATE_DIM, INPUT_DIM >, and ocs2::LoopshapingConstraint< FULL_STATE_DIM, FULL_INPUT_DIM, SYSTEM_STATE_DIM, SYSTEM_INPUT_DIM, FILTER_STATE_DIM, FILTER_INPUT_DIM >.

◆ numStateInputConstraint()

template<size_t STATE_DIM, size_t INPUT_DIM>
virtual size_t ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::numStateInputConstraint ( const scalar_t time)
inlinevirtual

◆ numStateOnlyConstraint()

template<size_t STATE_DIM, size_t INPUT_DIM>
virtual size_t ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::numStateOnlyConstraint ( const scalar_t time)
inlinevirtual

Get the number of state-only active equality constraints.

Parameters
[in]timetime.
Returns
number of state-only active (in)equality constraints.

Reimplemented in ocs2::LinearConstraint< STATE_DIM, INPUT_DIM >, and ocs2::LoopshapingConstraint< FULL_STATE_DIM, FULL_INPUT_DIM, SYSTEM_STATE_DIM, SYSTEM_INPUT_DIM, FILTER_STATE_DIM, FILTER_INPUT_DIM >.

◆ numStateOnlyFinalConstraint()

template<size_t STATE_DIM, size_t INPUT_DIM>
virtual size_t ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::numStateOnlyFinalConstraint ( const scalar_t time)
inlinevirtual

Get the number of final state-only active (in)equality constraints.

Parameters
[in]timetime.
Returns
number of final state-only active equality constraints.

Reimplemented in ocs2::LinearConstraint< STATE_DIM, INPUT_DIM >, and ocs2::LoopshapingConstraint< FULL_STATE_DIM, FULL_INPUT_DIM, SYSTEM_STATE_DIM, SYSTEM_INPUT_DIM, FILTER_STATE_DIM, FILTER_INPUT_DIM >.

◆ setCurrentStateAndControl()

template<size_t STATE_DIM, size_t INPUT_DIM>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::setCurrentStateAndControl ( const scalar_t t,
const state_vector_t x,
const input_vector_t u 
)
inlinevirtual

Sets the current time, state, and control input.

Parameters
[in]tCurrent time.
[in]xCurrent state.
[in]uCurrent input.

Reimplemented in ocs2::EXP2_constraint, ocs2::ConstraintBaseAD< STATE_DIM, INPUT_DIM >, and ocs2::LoopshapingConstraint< FULL_STATE_DIM, FULL_INPUT_DIM, SYSTEM_STATE_DIM, SYSTEM_INPUT_DIM, FILTER_STATE_DIM, FILTER_INPUT_DIM >.

Member Data Documentation

◆ t_

template<size_t STATE_DIM, size_t INPUT_DIM>
scalar_t ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::t_
protected

◆ u_

template<size_t STATE_DIM, size_t INPUT_DIM>
input_vector_t ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::u_
protected

◆ x_

template<size_t STATE_DIM, size_t INPUT_DIM>
state_vector_t ocs2::ConstraintBase< STATE_DIM, INPUT_DIM >::x_
protected

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