Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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