Skip to content

Commit

Permalink
mavproxy_misc.py: factor out a _cmd_changealt
Browse files Browse the repository at this point in the history
for use by the relative-alt and abs-alt variants
  • Loading branch information
peterbarker committed Nov 10, 2024
1 parent af699dd commit dca711d
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions MAVProxy/modules/mavproxy_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,35 +284,31 @@ def cmd_time(self, args):
return
print("%s (%s)\n" % (time.ctime(tusec * 1.0e-6), time.ctime()))

def _cmd_changealt(self, alt, frame):
self.master.mav.mission_item_send(self.settings.target_system,
self.settings.target_component,
0,
frame,
mavutil.mavlink.MAV_CMD_NAV_WAYPOINT,
3, 1, 0, 0, 0, 0,
0, 0, alt)
print("Sent change altitude command for %.1f meters" % alt)

def cmd_changealt(self, args):
'''change target altitude'''
if len(args) < 1:
print("usage: changealt <relaltitude>")
return
relalt = float(args[0])
self.master.mav.mission_item_send(self.settings.target_system,
self.settings.target_component,
0,
3,
mavutil.mavlink.MAV_CMD_NAV_WAYPOINT,
3, 1, 0, 0, 0, 0,
0, 0, relalt)
print("Sent change altitude command for %.1f meters" % relalt)
self._cmd_changealt(relalt, mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT)

def cmd_changealt_abs(self, args):
'''change target altitude'''
if len(args) < 1:
print("usage: changealt_abs <absaltitude>")
return
absalt = float(args[0])
self.master.mav.mission_item_send(self.settings.target_system,
self.settings.target_component,
0,
0,
mavutil.mavlink.MAV_CMD_NAV_WAYPOINT,
3, 1, 0, 0, 0, 0,
0, 0, absalt)
print("Sent change altitude command for %.1f meters" % absalt)
self._cmd_changealt(absalt, mavutil.mavlink.MAV_FRAME_GLOBAL)

def cmd_land(self, args):
'''auto land commands'''
Expand Down

0 comments on commit dca711d

Please sign in to comment.