Created
November 6, 2017 20:53
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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