Continuous Dynamics
This page provides the API for continuous dynamics models.
Continuous Dynamics type
RobotDynamics.ContinuousDynamics
— TypeContinuousDynamics
A dynamics model of the form:
where $x$ is the n
-dimensional state vector and $u$ is the m
-dimensional control vector. The following methods should be defined on any model:
state_dim(model)
control_dim(model)
The output dimension output_dim
is automatically defined to be equal to the state dimension.
Defining the dynamics
To define the dynamics using out-of-place (returning an SVector) evaluation, the user must define one of the following:
dynamics(model, z::AbstractKnotPoint)
dynamics(model, x, u, t)
dynamics(model, x, u)
The user shouldn't assume that the inputs are static arrays, although for best computational performance these methods should be called by passing in static arrays.
To define the dynamics using in-place evaluation, the user must define one of the following:
dynamics!(model, xdot, z::AbstractKnotPoint)
dynamics!(model, xdot, x, u, t)
dynamics!(model, xdot, x, u)
A user-defined Jacobian can be provided by defining one of the following methods
jacobian!(model, J, xdot, z::AbstractKnotPoint)
jacobian!(model, J, xdot, x, u, t)
jacobian!(model, J, xdot, x, u)
Non-Euclidean state vectors
By default, all elements of the state vector are assume to be in Euclidean space. This assumption can be relaxed by defining a few extra functions. For non-Euclidean state vectors, the Euclidean difference between two states, or the error state, is no longer computed using pure subtraction. We can define a custom function for taking the differences between 2 states vectors based on the type of the state vector.
We can query the type of the state vector using statevectortype(model)
, which returns a StateVectorType
trait (by default, EuclideanState
). After defining a new StateVectorType
and the following methods (described in more detail in the documentation for StateVectorType
):
state_diff!
errstate_dim
state_diff_jacobian!
∇state_diff_jacobian!
We can use dynamics with non-Euclidean state vectors. The most commonly encounter case of this is when using 3D rotations. Support for states with 3D rotations is provided by the RotationState
StateVectorType
.
Methods on continuous dynamics types
RobotDynamics.dynamics
— Functiondynamics(model, z::AbstractKnotPoint)
dynamics(model, x, u, t)
dynamics(model, x, u)
Evaluate the continuous time dynamics, returning the output $\dot{x}$. For best performance, the output should usually be a StaticArrays.SVector
. This method is called when using the StaticReturn
FunctionSignature
.
Calling evaluate
on a ContinuousDynamics
model will call this function.
RobotDynamics.dynamics!
— Functiondynamics!(model, xdot, z::AbstractKnotPoint)
dynamics!(model, xdot, x, u, t)
dynamics!(model, xdot, x, u)
Evaluate the continuous time dynamics, storing the output in xdot
. This method is called when using the InPlace
FunctionSignature
.
Calling evaluate!
on a ContinuousDynamics
model will call this function.
dynamics!(sig, model, xdot, z::AbstractKnotPoint)
Evaluate the continuous time dynamics, storing the output in xdot
, using the FunctionSignature
sig
to determine which method to call.