Skip to content

Instantly share code, notes, and snippets.

@pavel-kirienko
Created November 6, 2017 20:53
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 pavel-kirienko/d4a59581af26aa359bc86d5d7ed6d3e0 to your computer and use it in GitHub Desktop.
Save pavel-kirienko/d4a59581af26aa359bc86d5d7ed6d3e0 to your computer and use it in GitHub Desktop.
A simple snippet for the UAVCAN GUI Tool (v0.9) that sweeps an ESC RPM setpoint from zero to maximum and then back
def run():
rpm_setpoint = 0
going_down = False
step = 2
def update():
nonlocal rpm_setpoint
nonlocal going_down
rpm_setpoint += (-step if going_down else step)
broadcast(uavcan.equipment.esc.RPMCommand(rpm=[rpm_setpoint]))
if going_down:
if rpm_setpoint > step:
defer(0.01, update)
else:
if rpm_setpoint >= 5000:
going_down = True
defer(0.01, update)
update()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment