# Saving control inputs in RigidBodyDynamics

**URL:** <https://discourse.julialang.org/t/saving-control-inputs-in-rigidbodydynamics/108446>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 6, 2024, 10:30pm UTC](https://discourse.julialang.org/t/saving-control-inputs-in-rigidbodydynamics/108446 "2024-01-06T22:30:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GlenHenshaw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/glenhenshaw/32/5269_2.png) [@GlenHenshaw](https://discourse.julialang.org/u/GlenHenshaw)\
**Post date:** [January 6, 2024, 10:30pm UTC](https://discourse.julialang.org/t/saving-control-inputs-in-rigidbodydynamics/108446/1 "2024-01-06T22:30:01Z")

</div>

Is there a generally accepted way to store the control inputs during a simulation in RigidBodyDynamics?

```
ts, qs, vs = simulate(state, 15., control!; Δt = Δt);

```

I’d like to capture what is calculated by `control!` at each time step. `control!`'s function prototype looks like

```
function control!(control_inputs, t, state::MechanismState)

```

where `control_inputs` is calculated and modified inside `control!`. `simulate` uses `control_inputs` but then throws the values away and only returns the resulting motion of the system. I need to save `control_inputs`.

I can store into a global (or something) inside `control!`, but `simulate` uses a Runge–Kutta integrator, which gets called at intermediate time steps, so I end up with a vector 4x bigger than what I want.
