Skip to content

Instantly share code, notes, and snippets.

@bvanderveen
Created December 16, 2015 05:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bvanderveen/c25f537c4bd8a4f32327 to your computer and use it in GitHub Desktop.
Save bvanderveen/c25f537c4bd8a4f32327 to your computer and use it in GitHub Desktop.
controller/simulator workbench

Some notions on making a simulator/control loop bench

With apologies to ML:

iteration :: setpoint -> system-state -> system-state
iteration sp sys = let 
    control-output = control (sp, sys.control-state, sys.dynamic-state)
    control-state' = fst control-output
    control-signal = snd control-output
    dynamic-state' = plant (control-signal, sys.dynamic-state) in
    (control-state', dynamic-state')

control :: (setpoint, control-state, dynamic-state) -> (control-state, control-signal)
control = <the controller>

plant :: (control-signal, dynamic-state) -> dynamic-state
plant = <the physics simulator>

type system-state =
    (control-state, dynamic-state)
  • setpoint is more or less a bunch of constants.
  • control-state is accumulated controller integrals etc
  • dynamic-state is positions, velocities, forces, orientation, angular velocities, torques, etc
  • control-signal is all the effector outputs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment