iDynTree::optimalcontrol::DynamicalSystem class

DynamicalSystem base class.

It defines a continuos time dynamical system, i.e. $ \dot{x} = f(t,x,u) $ Inherit publicly from this class in order to define your custiom dynamical system.

Derived classes

class LinearSystem
class MultiBodySystem

Constructors, destructors, conversion operators

DynamicalSystem() deleted
DynamicalSystem(size_t stateSpaceSize, size_t controlSpaceSize)
Default constructor.
DynamicalSystem(const DynamicalSystem& other) deleted
~DynamicalSystem() virtual

Public functions

auto stateSpaceSize() const -> size_t
Returns the state space dimension.
auto controlSpaceSize() const -> size_t
Returns the control space dimension.
auto dynamics(const VectorDynSize& state, double time, VectorDynSize& stateDynamics) -> bool pure virtual
Computes the system dynamics.
auto setControlInput(const VectorDynSize& control) -> bool virtual
Set the control input to the dynamical system.
auto controlInput() const -> const VectorDynSize& virtual
Access the control input.
auto controlInput(unsigned int index) const -> double virtual
Access the control input.
auto initialState() const -> const VectorDynSize& virtual
Access the initial state.
auto initialState(unsigned int index) const -> double virtual
Access the initial state.
auto setInitialState(const VectorDynSize& state) -> bool virtual
Set the initial state to the dynamical system.
auto dynamicsStateFirstDerivative(const VectorDynSize& state, double time, MatrixDynSize& dynamicsDerivative) -> bool virtual
Compute the partial derivative of the state dynamics wrt the state.
auto dynamicsControlFirstDerivative(const VectorDynSize& state, double time, MatrixDynSize& dynamicsDerivative) -> bool virtual
Compute the partial derivative of the state dynamics wrt the control.
auto dynamicsStateFirstDerivativeSparsity(iDynTree::optimalcontrol::SparsityStructure& stateSparsity) -> bool virtual
Returns the set of nonzeros elements in terms of row and colun index, in the state jacobian.
auto dynamicsControlFirstDerivativeSparsity(iDynTree::optimalcontrol::SparsityStructure& controlSparsity) -> bool virtual
Returns the set of nonzeros elements in terms of row and colun index, in the control jacobian.
auto dynamicsSecondPartialDerivativeWRTState(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& lambda, iDynTree::MatrixDynSize& partialDerivative) -> bool virtual
Evaluate the dynamics second partial derivative wrt the state variables.
auto dynamicsSecondPartialDerivativeWRTControl(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& lambda, iDynTree::MatrixDynSize& partialDerivative) -> bool virtual
Evaluate the dynamics second partial derivative wrt the control.
auto dynamicsSecondPartialDerivativeWRTStateControl(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& lambda, iDynTree::MatrixDynSize& partialDerivative) -> bool virtual
Evaluate the dynamics second partial derivative wrt the state and control.
auto dynamicsSecondPartialDerivativeWRTStateSparsity(iDynTree::optimalcontrol::SparsityStructure& stateSparsity) -> bool virtual
Returns the set of nonzeros elements in terms of row and colun index, in the state hessian.
auto dynamicsSecondPartialDerivativeWRTStateControlSparsity(iDynTree::optimalcontrol::SparsityStructure& stateControlSparsity) -> bool virtual
Returns the set of nonzeros elements in terms of row and colun index, in the mixed hessian.
auto dynamicsSecondPartialDerivativeWRTControlSparsity(iDynTree::optimalcontrol::SparsityStructure& controlSparsity) -> bool virtual
Returns the set of nonzeros elements in terms of row and colun index, in the control hessian.

Function documentation

iDynTree::optimalcontrol::DynamicalSystem::DynamicalSystem(size_t stateSpaceSize, size_t controlSpaceSize)

Default constructor.

Parameters
stateSpaceSize in Dimension of the state space.
controlSpaceSize in Dimension of the control space.

bool iDynTree::optimalcontrol::DynamicalSystem::dynamics(const VectorDynSize& state, double time, VectorDynSize& stateDynamics) pure virtual

Computes the system dynamics.

Parameters
state in The state point in which the dynamics is computed.
time in The time at which the dynamics is computed.
stateDynamics out The value of the state derivative.
Returns True if successfull.

It return $ f(t,x) $ . Notice that here the dependency from the control input is removed, so that basically we are assuming an autonomous system. If the system is controlled, the control input will be set separately with the method setControlInput. This was necessary since the Integrator class needs an autonomous system to be integrated. See ControlledDynamicalSystem class in case you want to join a DynamicalSystem with a Controller.

bool iDynTree::optimalcontrol::DynamicalSystem::setControlInput(const VectorDynSize& control) virtual

Set the control input to the dynamical system.

Parameters
control in The control input value.
Returns True if successful, false otherwise (for example if size do not match).

In principle, there is no need to override this method. This value is stored in an internal buffer which can be accessed through the method controlInput().

const VectorDynSize& iDynTree::optimalcontrol::DynamicalSystem::controlInput() const virtual

Access the control input.

Returns Const reference to the control input buffer.

In principle, there is no need to override this method. This has to be set with the method setControlInput().

double iDynTree::optimalcontrol::DynamicalSystem::controlInput(unsigned int index) const virtual

Access the control input.

Parameters
index in Index at which accessing the control input buffer.
Returns Value corresponding to the specified index.

In principle, there is no need to override this method. This has to be set with the method setControlInput().

const VectorDynSize& iDynTree::optimalcontrol::DynamicalSystem::initialState() const virtual

Access the initial state.

Returns Const reference to the initial state buffer.

In principle, there is no need to override this method. This has to be set with the method setInitialState().

double iDynTree::optimalcontrol::DynamicalSystem::initialState(unsigned int index) const virtual

Access the initial state.

Parameters
index in Index at which accessing the initial state buffer.
Returns Value corresponding to the specified index.

In principle, there is no need to override this method. This has to be set with the method setInitialState().

bool iDynTree::optimalcontrol::DynamicalSystem::setInitialState(const VectorDynSize& state) virtual

Set the initial state to the dynamical system.

Parameters
state in The initial state value.
Returns True if successful, false otherwise (for example if size do not match).

In principle, there is no need to override this method. This value is stored in an internal buffer which can be accessed through the method initialState().

bool iDynTree::optimalcontrol::DynamicalSystem::dynamicsStateFirstDerivative(const VectorDynSize& state, double time, MatrixDynSize& dynamicsDerivative) virtual

Compute the partial derivative of the state dynamics wrt the state.

Parameters
state in The state value at which computing the partial derivative.
time in The time at which computing the partial derivative.
dynamicsDerivative out The output derivative. It has to be a square matrix with dimension equal to the state size.
Returns True if successful, false otherwise (or if not implemented).

Namely it computes, $ \frac{\partial f(t,x,u)}{\partial x}$ . By default it return false;

bool iDynTree::optimalcontrol::DynamicalSystem::dynamicsControlFirstDerivative(const VectorDynSize& state, double time, MatrixDynSize& dynamicsDerivative) virtual

Compute the partial derivative of the state dynamics wrt the control.

Parameters
state in The state value at which computing the partial derivative.
time in The time at which computing the partial derivative.
dynamicsDerivative out The output derivative. It has to be a matrix with number of rows equal to the state size and number of columns equal to the control size.
Returns True if successful, false otherwise (or if not implemented).

Namely it computes, $ \frac{\partial f(t,x,u)}{\partial u}$ . By default it return false;

bool iDynTree::optimalcontrol::DynamicalSystem::dynamicsStateFirstDerivativeSparsity(iDynTree::optimalcontrol::SparsityStructure& stateSparsity) virtual

Returns the set of nonzeros elements in terms of row and colun index, in the state jacobian.

Parameters
stateSparsity Sparsity structure of the partial derivative of the jacobian wrt state variables.
Returns true if the sparsity is available. False otherwise.

bool iDynTree::optimalcontrol::DynamicalSystem::dynamicsControlFirstDerivativeSparsity(iDynTree::optimalcontrol::SparsityStructure& controlSparsity) virtual

Returns the set of nonzeros elements in terms of row and colun index, in the control jacobian.

Parameters
controlSparsity Sparsity structure of the partial derivative of the jacobian wrt state variables.
Returns true if the sparsity is available. False otherwise.

bool iDynTree::optimalcontrol::DynamicalSystem::dynamicsSecondPartialDerivativeWRTState(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& lambda, iDynTree::MatrixDynSize& partialDerivative) virtual

Evaluate the dynamics second partial derivative wrt the state variables.

Parameters
time in The time at which the partial derivative is computed.
state in The state value at which the partial derivative is computed.
lambda in The associated lagrange multipliers
partialDerivative out The output partial derivative.
Returns True if successfull, false otherwise (or if not implemented).

It is the result of $\frac{\partial^2 f(t, x, u)}{\partial x^2}$

bool iDynTree::optimalcontrol::DynamicalSystem::dynamicsSecondPartialDerivativeWRTControl(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& lambda, iDynTree::MatrixDynSize& partialDerivative) virtual

Evaluate the dynamics second partial derivative wrt the control.

Parameters
time in The time at which the partial derivative is computed.
state in The state value at which the partial derivative is computed.
lambda in The associated lagrange multipliers
partialDerivative out The output partial derivative.
Returns True if successfull, false otherwise (or if not implemented).

It is the result of $\frac{\partial^2 f(t, x, u)}{\partial u^2}$

bool iDynTree::optimalcontrol::DynamicalSystem::dynamicsSecondPartialDerivativeWRTStateControl(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& lambda, iDynTree::MatrixDynSize& partialDerivative) virtual

Evaluate the dynamics second partial derivative wrt the state and control.

Parameters
time in The time at which the partial derivative is computed.
state in The state value at which the partial derivative is computed.
lambda in The associated lagrange multipliers
partialDerivative out The output partial derivative.
Returns True if successfull, false otherwise (or if not implemented).

It is the result of $\frac{\partial^2 f(t, x, u)}{\partial x \partial u}$ , thus it has number of rows equals to the number of states and number of cols equal to the number of control inputs.

bool iDynTree::optimalcontrol::DynamicalSystem::dynamicsSecondPartialDerivativeWRTStateSparsity(iDynTree::optimalcontrol::SparsityStructure& stateSparsity) virtual

Returns the set of nonzeros elements in terms of row and colun index, in the state hessian.

Parameters
stateSparsity out Sparsity structure of the partial derivative of the jacobian wrt state variables.
Returns true if the sparsity is available. False otherwise.

bool iDynTree::optimalcontrol::DynamicalSystem::dynamicsSecondPartialDerivativeWRTStateControlSparsity(iDynTree::optimalcontrol::SparsityStructure& stateControlSparsity) virtual

Returns the set of nonzeros elements in terms of row and colun index, in the mixed hessian.

Parameters
stateControlSparsity out Sparsity structure of the partial derivative of the jacobian wrt state and control variables.
Returns true if the sparsity is available. False otherwise.

bool iDynTree::optimalcontrol::DynamicalSystem::dynamicsSecondPartialDerivativeWRTControlSparsity(iDynTree::optimalcontrol::SparsityStructure& controlSparsity) virtual

Returns the set of nonzeros elements in terms of row and colun index, in the control hessian.

Parameters
controlSparsity out Sparsity structure of the partial derivative of the jacobian wrt control variables.
Returns true if the sparsity is available. False otherwise.