Skip to content

Instantly share code, notes, and snippets.

@DaniruKun
Created May 20, 2020 21:02
Show Gist options
  • Save DaniruKun/97cb218758cd1432289a2c6f3a9e14bc to your computer and use it in GitHub Desktop.
Save DaniruKun/97cb218758cd1432289a2c6f3a9e14bc to your computer and use it in GitHub Desktop.
Automatic Docking telemetry update
(defn poll
"Poll telemetry and update the state."
[driv]
(if true
(do
(Thread/sleep poll-interval)
(let [t (System/currentTimeMillis)
dt (* (+ poll-interval (- t (@telem :t))) 0.001)
x (get-x driv)
y (get-y driv)
z (get-z driv)
dx (- x (@telem :x))
dy (- y (@telem :y))
dz (- z (@telem :z))
vx (calc/get-vx dt dx)
vy (calc/get-vy dt dy)
vz (calc/get-vz dt dz)]
(swap! telem assoc
:roll (get-roll-delta driv)
:pitch (get-pitch-delta driv)
:yaw (get-yaw-delta driv)
:roll-rate (get-roll-rate driv)
:pitch-rate (get-pitch-rate driv)
:yaw-rate (get-yaw-rate driv)
:range (get-range driv)
:x x
:y y
:z z
:vx vx
:vy vy
:vz vz
:t (System/currentTimeMillis)))
(recur driv))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment