Dynamics API

RobotDynamics.dynamicsFunction
ẋ = dynamics(model, z::AbstractKnotPoint)
ẋ = dynamics(model, x, u, [t=0])

Compute the continuous dynamics of a forced dynamical given the states x, controls u and time t (optional).

source
RobotDynamics.jacobian!Function
jacobian!(∇f, model, z::AbstractKnotPoint, [cache])

Compute the n × (n + m) Jacobian ∇f of the continuous-time dynamics. Only accepts an AbstractKnotPoint as input in order to avoid potential allocations associated with concatenation.

This method can use either ForwardDiff or FiniteDiff, based on the result of RobotDynamics.diffmethod(model). When using FiniteDiff, the cache should be passed in for best performance. The cache can be generated using either of the following:

RobotDynamics.gen_cache(model)
FiniteDiff.JacobianCache(model)
source
RobotDynamics.jvp!Function
jvp!(grad, model, z, λ, [cache])

Compute the Jacobian-transpose vector product, ∇f'λ. Can use either ForwardDiff or FiniteDiff.

source
RobotDynamics.discrete_dynamicsFunction
x′ = discrete_dynamics(model, model, z)  # uses RK3 as the default integration scheme
x′ = discrete_dynamics(Q, model, x, u, t, dt)
x′ = discrete_dynamics(Q, model, z::KnotPoint)

Compute the discretized dynamics of model using explicit integration scheme Q<:QuadratureRule.

The default integration scheme is stored in TrajectoryOptimization.DEFAULT_Q

source
RobotDynamics.discrete_jacobian!Function
discrete_jacobian!(Q, ∇f, model, z::AbstractKnotPoint)

Compute the n × (n+m) discrete dynamics Jacobian ∇f of model using explicit integration scheme Q<:QuadratureRule.

This method can use either ForwardDiff or FiniteDiff, based on the result of RobotDynamics.diffmethod(model). When using FiniteDiff, the cache should be passed in for best performance. The cache can be generated using either of the following:

RobotDynamics.gen_cache(model)
FiniteDiff.JacobianCache(model)

When using FiniteDiff, the coloring vector for sparse Jacobians can be calculated and stored in the cache. To compute this automatically, use

FiniteDiff.JacobianCache(model, colored=true, [sparsity=sparsity])

where sparsity is a sparse matrix with the non-zero entries of the discrete Jacobian. If left out, it will be computed using detect_sparsity(DEFAULT_Q, model).

source
RobotDynamics.discrete_jvp!Function
discrete_jvp!(Q, grad, model, z, λ, [cache])

Calculated the discrete Jacobian-vector product, ∇f'λ. Can use either ForwardDiff or FiniteDiff. The cache for FiniteDiff can be generated using either of the following

RobotDynamics.gen_grad_cache(model)
FiniteDiff.GradientCache(model)
source
RobotDynamics.∇discrete_jacobian!Function
∇discrete_jacobian!(Q, ∇²f, model, z, b)

Evaluate the Jacobian of the Jacobian-transpose vector product: ∇f'b, for the discrete dynamics. The output ∇²f is of size (n+m,n+m), and b is of size (n,). This is needed, for example, when computing the Hessian of the Lagrangian when computing a full Newton step.

source