Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mavproxy_misc.py: factor out a _cmd_changealt #1484

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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