Simulation

Simulation

Index

Basic simulation

simulate(state0, final_time)
simulate(state0, final_time, control!; Δt)

Basic Mechanism simulation: integrate the state from time $0$ to final_time starting from the initial state state0. Return a Vector of times, as well as Vectors of configuration vectors and velocity vectors at these times.

Optionally, a function (or other callable) can be passed in as the third argument (control!). control! will be called at each time step of the simulation and allows you to specify joint torques given the time and the state of the Mechanism. It should look like this:

function control!(torques::AbstractVector, t, state::MechanismState)
    rand!(torques) # for example
end

The integration time step can be specified using the Δt keyword argument (defaults to 1e-4).

Uses MuntheKaasIntegrator. See RigidBodyDynamics.OdeIntegrators.MuntheKaasIntegrator for a lower level interface with more options.

source

Lower level ODE integration interface

A Lie-group-aware ODE integrator.

MuntheKaasIntegrator is used to properly integrate the dynamics of globally parameterized rigid joints (Duindam, Port-Based Modeling and Control for Efficient Bipedal Walking Robots, 2006, Definition 2.9). Global parameterizations of e.g. $SO(3)$ are needed to avoid singularities, but this leads to the problem that the tangent space no longer has the same dimension as the ambient space of the global parameterization. A Munthe-Kaas integrator solves this problem by converting back and forth between local and global coordinates at every integration time step.

The idea is to do the dynamics and compute the stages of the integration scheme in terms of local coordinates centered around the global parameterization of the configuration at the end of the previous time step (e.g. exponential coordinates), combine the stages into a new set of local coordinates as usual for Runge-Kutta methods, and then convert the local coordinates back to global coordinates.

From Iserles et al., 'Lie-group methods' (2000).

Another useful reference is Park and Chung, 'Geometric Integration on Euclidean Group with Application to Articulated Multibody Systems' (2005).

source
struct ButcherTableau{N, T, L}

A Butcher tableau.

source
abstract OdeResultsSink

Does 'something' with the results of an ODE integration (e.g. storing results, visualizing, etc.). Subtypes must implement:

  • initialize(sink, state): called with the initial state when integration begins.

  • process(sink, t, state): called at every integration time step with the current state and time.

source
type RingBufferStorage{T, Q<:(AbstractArray{T,1} where T), V<:(AbstractArray{T,1} where T)} <: RigidBodyDynamics.OdeIntegrators.OdeResultsSink

An OdeResultsSink that stores the state at each integration time step in a ring buffer.

source
type ExpandingStorage{T, Q<:(AbstractArray{T,1} where T), V<:(AbstractArray{T,1} where T)} <: RigidBodyDynamics.OdeIntegrators.OdeResultsSink

An OdeResultsSink that stores the state at each integration time step in Vectors that may expand.

source
integrate(integrator, final_time, Δt; max_realtime_rate)

Integrate dynamics from the initial state at time $0$ to final_time using step size Δt.

source
runge_kutta_4(scalartype)

Return the Butcher tableau for the standard fourth order Runge-Kutta integrator.

source
step(integrator, t, Δt)

Take a single integration step.

source