INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
handle an incoming mavlink packet
def mavlink_packet(self, msg): '''handle an incoming mavlink packet''' type = msg.get_type() master = self.master # add some status fields if type in [ 'RC_CHANNELS_RAW' ]: rc6 = msg.chan6_raw if rc6 > 1500: ign_colour = 'green' ...
check starter settings
def valid_starter_settings(self): '''check starter settings''' if self.gasheli_settings.ignition_chan <= 0 or self.gasheli_settings.ignition_chan > 8: print("Invalid ignition channel %d" % self.gasheli_settings.ignition_chan) return False if self.gasheli_settings.starter_...
run periodic tasks
def idle_task(self): '''run periodic tasks''' if self.starting_motor: if self.gasheli_settings.ignition_disable_time > 0: elapsed = time.time() - self.motor_t1 if elapsed >= self.gasheli_settings.ignition_disable_time: self.module('rc').set...
start motor
def start_motor(self): '''start motor''' if not self.valid_starter_settings(): return self.motor_t1 = time.time() self.stopping_motor = False if self.gasheli_settings.ignition_disable_time > 0: self.old_override = self.module('rc').get_override_chan(self....
stop motor
def stop_motor(self): '''stop motor''' if not self.valid_starter_settings(): return self.motor_t1 = time.time() self.starting_motor = False self.stopping_motor = True self.old_override = self.module('rc').get_override_chan(self.gasheli_settings.ignition_chan-1...
gas help commands
def cmd_gasheli(self, args): '''gas help commands''' usage = "Usage: gasheli <start|stop|set>" if len(args) < 1: print(usage) return if args[0] == "start": self.start_motor() elif args[0] == "stop": self.stop_motor() elif ar...
per-sysid wploader
def wploader(self): '''per-sysid wploader''' if self.target_system not in self.wploader_by_sysid: self.wploader_by_sysid[self.target_system] = mavwp.MAVWPLoader() return self.wploader_by_sysid[self.target_system]
send some more WP requests
def send_wp_requests(self, wps=None): '''send some more WP requests''' if wps is None: wps = self.missing_wps_to_request() tnow = time.time() for seq in wps: #print("REQUESTING %u/%u (%u)" % (seq, self.wploader.expected_count, i)) self.wp_requested[seq...
show status of wp download
def wp_status(self): '''show status of wp download''' try: print("Have %u of %u waypoints" % (self.wploader.count()+len(self.wp_received), self.wploader.expected_count)) except Exception: print("Have %u waypoints" % (self.wploader.count()+len(self.wp_received)))
show slope of waypoints
def wp_slope(self): '''show slope of waypoints''' last_w = None for i in range(1, self.wploader.count()): w = self.wploader.wp(i) if w.command not in [mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, mavutil.mavlink.MAV_CMD_NAV_LAND]: continue if last_w i...
handle an incoming mavlink packet
def mavlink_packet(self, m): '''handle an incoming mavlink packet''' mtype = m.get_type() if mtype in ['WAYPOINT_COUNT','MISSION_COUNT']: self.wploader.expected_count = m.count if self.wp_op is None: #self.console.error("No waypoint load started") ...
handle missing waypoints
def idle_task(self): '''handle missing waypoints''' if self.wp_period.trigger(): # cope with packet loss fetching mission if self.master is not None and self.master.time_since('MISSION_ITEM') >= 2 and self.wploader.count() < getattr(self.wploader,'expected_count',0): ...
save waypoints to a file
def save_waypoints(self, filename): '''save waypoints to a file''' try: #need to remove the leading and trailing quotes in filename self.wploader.save(filename.strip('"')) except Exception as msg: print("Failed to save %s - %s" % (filename, msg)) r...
save waypoints to a file in a human readable CSV file
def save_waypoints_csv(self, filename): '''save waypoints to a file in a human readable CSV file''' try: #need to remove the leading and trailing quotes in filename self.wploader.savecsv(filename.strip('"')) except Exception as msg: print("Failed to save %s - ...
get home location
def get_home(self): '''get home location''' if 'HOME_POSITION' in self.master.messages: h = self.master.messages['HOME_POSITION'] return mavutil.mavlink.MAVLink_mission_item_message(self.target_system, self.target_co...
add a square flight exclusion zone
def nofly_add(self): '''add a square flight exclusion zone''' try: latlon = self.module('map').click_position except Exception: print("No position chosen") return loader = self.wploader (center_lat, center_lon) = latlon points = [] ...
handle wp change target alt of multiple waypoints
def cmd_wp_changealt(self, args): '''handle wp change target alt of multiple waypoints''' if len(args) < 2: print("usage: wp changealt WPNUM NEWALT <NUMWP>") return idx = int(args[0]) if idx < 1 or idx > self.wploader.count(): print("Invalid wp number ...
fix up jumps when we add/remove rows
def fix_jumps(self, idx, delta): '''fix up jumps when we add/remove rows''' numrows = self.wploader.count() for row in range(numrows): wp = self.wploader.wp(row) jump_cmds = [mavutil.mavlink.MAV_CMD_DO_JUMP] if hasattr(mavutil.mavlink, "MAV_CMD_DO_CONDITION_JU...
handle wp remove
def cmd_wp_remove(self, args): '''handle wp remove''' if len(args) != 1: print("usage: wp remove WPNUM") return idx = int(args[0]) if idx < 0 or idx >= self.wploader.count(): print("Invalid wp number %u" % idx) return wp = self.wplo...
handle wp undo
def cmd_wp_undo(self): '''handle wp undo''' if self.undo_wp_idx == -1 or self.undo_wp is None: print("No undo information") return wp = self.undo_wp if self.undo_type == 'move': wp.target_system = self.target_system wp.target_component =...
waypoint commands
def cmd_wp(self, args): '''waypoint commands''' usage = "usage: wp <editor|list|load|update|save|set|clear|loop|remove|move|movemulti|changealt>" if len(args) < 1: print(usage) return if args[0] == "load": if len(args) != 2: print("usa...
turn a list of values into a CSV line
def csv_line(self, line): '''turn a list of values into a CSV line''' self.csv_sep = "," return self.csv_sep.join(['"' + str(x) + '"' for x in line])
save waypoints to a file in human-readable CSV file
def savecsv(self, filename): '''save waypoints to a file in human-readable CSV file''' f = open(filename, mode='w') headers = ["Seq", "Frame", "Cmd", "P1", "P2", "P3", "P4", "X", "Y", "Z"] print(self.csv_line(headers)) f.write(self.csv_line(headers) + "\n") for w in self....
Print a list of available joysticks
def list_joysticks(): '''Print a list of available joysticks''' print('Available joysticks:') print() for jid in range(pygame.joystick.get_count()): j = pygame.joystick.Joystick(jid) print('({}) {}'.format(jid, j.get_name()))
Allow user to select a joystick from a menu
def select_joystick(): '''Allow user to select a joystick from a menu''' list_joysticks() while True: print('Select a joystick (L to list, Q to quit)'), choice = sys.stdin.readline().strip() if choice.lower() == 'l': list_joysticks() elif choice.lower() == 'q':...
Search for a wxPython installation that matches version. If one is found then sys.path is modified so that version will be imported with a 'import wx', otherwise a VersionError exception is raised. This function should only be called once at the beginning of the application before wxPython is imported...
def select(versions, optionsRequired=False): """ Search for a wxPython installation that matches version. If one is found then sys.path is modified so that version will be imported with a 'import wx', otherwise a VersionError exception is raised. This function should only be called once at the beg...
Checks to see if the default version of wxPython is greater-than or equal to `minVersion`. If not then it will try to find an installed version that is >= minVersion. If none are available then a message is displayed that will inform the user and will offer to open their web browser to the wxPython do...
def ensureMinimal(minVersion, optionsRequired=False): """ Checks to see if the default version of wxPython is greater-than or equal to `minVersion`. If not then it will try to find an installed version that is >= minVersion. If none are available then a message is displayed that will inform the us...
Check if there is a version of wxPython installed that matches one of the versions given. Returns True if so, False if not. This can be used to determine if calling `select` will succeed or not. :param versions: Same as in `select`, either a string or a list of strings specifying the vers...
def checkInstalled(versions, optionsRequired=False): """ Check if there is a version of wxPython installed that matches one of the versions given. Returns True if so, False if not. This can be used to determine if calling `select` will succeed or not. :param versions: Same as in `select`, eit...
Returns a list of strings representing the installed wxPython versions that are found on the system.
def getInstalled(): """ Returns a list of strings representing the installed wxPython versions that are found on the system. """ installed = _find_installed() return [os.path.basename(p.pathname)[3:] for p in installed]
called on menu selection
def menu_callback(m): '''called on menu selection''' if m.returnkey.startswith('# '): cmd = m.returnkey[2:] if m.handler is not None: if m.handler_result is None: return cmd += m.handler_result process_stdin(cmd) elif m.returnkey == 'menuSettin...
construct flightmode menu
def flightmode_menu(): '''construct flightmode menu''' global flightmodes ret = [] idx = 0 for (mode,t1,t2) in flightmodes: modestr = "%s %us" % (mode, (t2-t1)) ret.append(MPMenuCheckbox(modestr, modestr, 'mode-%u' % idx)) idx += 1 mestate.flightmode_selections.append...
setup console menus
def setup_menus(): '''setup console menus''' global TopMenu TopMenu.add(MPMenuSubMenu('Display', items=[MPMenuItem('Map', 'Map', '# map'), MPMenuItem('Save Graph', 'Save', '# save'), MPMenuItem('Reload Graphs', 'R...
load graphs from mavgraphs.xml
def load_graphs(): '''load graphs from mavgraphs.xml''' mestate.graphs = [] gfiles = ['mavgraphs.xml'] if 'HOME' in os.environ: for dirname, dirnames, filenames in os.walk(os.path.join(os.environ['HOME'], ".mavproxy")): for filename in filenames: if filename.lower().e...
graph command
def cmd_graph(args): '''graph command''' usage = "usage: graph <FIELD...>" if len(args) < 1: print(usage) return if args[0][0] == ':': i = int(args[0][1:]) g = mestate.graphs[i] expression = g.expression args = expression.split() mestate.console.wr...
return mapping of flight mode to colours
def flightmode_colours(): '''return mapping of flight mode to colours''' from MAVProxy.modules.lib.grapher import flightmode_colours mapping = {} idx = 0 for (mode,t0,t1) in flightmodes: if not mode in mapping: mapping[mode] = flightmode_colours[idx] idx += 1 ...
map command
def cmd_map(args): '''map command''' import mavflightview #mestate.mlog.reduce_by_flightmodes(mestate.flightmode_selections) #setup and process the map options = mavflightview.mavflightview_options() options.condition = mestate.settings.condition options._flightmodes = mestate.mlog._flightmo...
display fft from log
def cmd_fft(args): '''display fft from log''' from MAVProxy.modules.lib import mav_fft if len(args) > 0: condition = args[0] else: condition = None child = multiproc.Process(target=mav_fft.mavfft_display, args=[mestate.filename,condition]) child.start()
save a graph as XML
def save_graph(graphdef): '''save a graph as XML''' if graphdef.filename is None: if 'HOME' in os.environ: dname = os.path.join(os.environ['HOME'], '.mavproxy') if os.path.exists(dname): mp_util.mkdir_p(dname) graphdef.filename = os.path.join(dname...
callback from save thread
def save_callback(operation, graphdef): '''callback from save thread''' if operation == 'test': for e in graphdef.expressions: if expression_ok(e, msgs): graphdef.expression = e pipe_graph_input.send('graph ' + graphdef.expression) return ...
process for saving a graph
def save_process(MAVExpLastGraph, child_pipe_console_input, child_pipe_graph_input, statusMsgs): '''process for saving a graph''' from MAVProxy.modules.lib import wx_processguard from MAVProxy.modules.lib.wx_loader import wx from MAVProxy.modules.lib.wxgrapheditor import GraphDialog #This pipe ...
save a graph
def cmd_save(args): '''save a graph''' child = multiproc.Process(target=save_process, args=[mestate.last_graph, mestate.child_pipe_send_console, mestate.child_pipe_send_graph, mestate.status.msgs]) child.start()
show messages
def cmd_messages(args): '''show messages''' if len(args) > 0: wildcard = args[0] if wildcard.find('*') == -1 and wildcard.find('?') == -1: wildcard = "*" + wildcard + "*" else: wildcard = '*' mestate.mlog.rewind() types = set(['MSG','STATUSTEXT']) while True: ...
show parameters
def cmd_devid(args): '''show parameters''' params = mestate.mlog.params k = sorted(params.keys()) for p in k: if p.startswith('COMPASS_DEV_ID'): mp_util.decode_devid(params[p], p) if p.startswith('INS_') and p.endswith('_ID'): mp_util.decode_devid(params[p], p)
callback from menu to load a log file
def cmd_loadfile(args): '''callback from menu to load a log file''' if len(args) != 1: fileargs = " ".join(args) else: fileargs = args[0] if not os.path.exists(fileargs): print("Error loading file ", fileargs); return if os.name == 'nt': #convert slashes in Wi...
load a log file (path given by arg)
def loadfile(args): '''load a log file (path given by arg)''' mestate.console.write("Loading %s...\n" % args) t0 = time.time() mlog = mavutil.mavlink_connection(args, notimestamps=False, zero_time_base=False, progress_callback=p...
handle commands from user
def process_stdin(line): '''handle commands from user''' if line is None: sys.exit(0) line = line.strip() if not line: return args = shlex.split(line) cmd = args[0] if cmd == 'help': k = command_map.keys() k.sort() for cmd in k: (fn, help...
wait for user input
def input_loop(): '''wait for user input''' while mestate.exit != True: try: if mestate.exit != True: line = input(mestate.rl.prompt) except EOFError: mestate.exit = True sys.exit(1) mestate.input_queue.put(line)
main processing loop, display graphs and maps
def main_loop(): '''main processing loop, display graphs and maps''' global grui, last_xlim while True: if mestate is None or mestate.exit: return while not mestate.input_queue.empty(): line = mestate.input_queue.get() cmds = line.split(';') fo...
watch for piped data from save dialog
def pipeRecvConsole(self): '''watch for piped data from save dialog''' try: while True: console_msg = self.parent_pipe_recv_console.recv() if console_msg is not None: self.console.writeln(console_msg) time.sleep(0.1) ...
watch for piped data from save dialog
def pipeRecvGraph(self): '''watch for piped data from save dialog''' try: while True: graph_rec = self.parent_pipe_recv_graph.recv() if graph_rec is not None: mestate.input_queue.put(graph_rec) time.sleep(0.1) except...
handle a mavlink packet
def mavlink_packet(self, m): '''handle a mavlink packet''' mtype = m.get_type() if mtype == "GLOBAL_POSITION_INT": for cam in self.camera_list: cam.boSet_GPS(m) if mtype == "ATTITUDE": for cam in self.camera_list: cam.boSet_Attitude...
called in idle time
def idle_task(self): '''called in idle time''' try: datagram = self.port.recvfrom(self.BUFFER_SIZE) data = json.loads(datagram[0]) except socket.error as e: if e.errno in [ errno.EAGAIN, errno.EWOULDBLOCK ]: return ...
handle port selection
def cmd_port(self, args): 'handle port selection' if len(args) != 1: print("Usage: port <number>") return self.port.close() self.portnum = int(args[0]) self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.port.setsockopt(socke...
substitute variables in a string
def substitute(self, text, subvars={}, checkmissing=None): '''substitute variables in a string''' if checkmissing is None: checkmissing = self.checkmissing while True: idx = text.find(self.start_var_token) if idx == -1: ret...
Actuate on the vehicle through a script. The script is a sequence of commands. Each command is a sequence with the first element as the command name and the remaining values as parameters. The script is executed asynchronously by a timer with a period of 0.1 seconds. At each timer tick,...
def RunScript(self, script): ''' Actuate on the vehicle through a script. The script is a sequence of commands. Each command is a sequence with the first element as the command name and the remaining values as parameters. The script is executed asynchronously by a timer with a p...
called from main select loop in mavproxy when the pppd child sends us some data
def ppp_read(self, ppp_fd): '''called from main select loop in mavproxy when the pppd child sends us some data''' buf = os.read(ppp_fd, 100) if len(buf) == 0: # EOF on the child fd self.stop_ppp_link() return print("ppp packet len=%u" % len(buf...
startup the link
def start_ppp_link(self): '''startup the link''' cmd = ['pppd'] cmd.extend(self.command) (self.pid, self.ppp_fd) = pty.fork() if self.pid == 0: os.execvp("pppd", cmd) raise RuntimeError("pppd exited") if self.ppp_fd == -1: print("Failed...
stop the link
def stop_ppp_link(self): '''stop the link''' if self.ppp_fd == -1: return try: self.mpself.select_extra.pop(self.ppp_fd) os.close(self.ppp_fd) os.waitpid(self.pid, 0) except Exception: pass self.pid = -1 self.ppp...
set ppp parameters and start link
def cmd_ppp(self, args): '''set ppp parameters and start link''' usage = "ppp <command|start|stop>" if len(args) == 0: print(usage) return if args[0] == "command": if len(args) == 1: print("ppp.command=%s" % " ".join(self.command)) ...
handle an incoming mavlink packet
def mavlink_packet(self, m): '''handle an incoming mavlink packet''' if m.get_type() == 'PPP' and self.ppp_fd != -1: print("got ppp mavlink pkt len=%u" % m.length) os.write(self.ppp_fd, m.data[:m.length])
Find a list of modules matching a wildcard pattern
def module_matching(self, name): '''Find a list of modules matching a wildcard pattern''' import fnmatch ret = [] for mname in self.mpstate.public_modules.keys(): if fnmatch.fnmatch(mname, name): ret.append(self.mpstate.public_modules[mname]) return re...
get time, using ATTITUDE.time_boot_ms if in SITL with SIM_SPEEDUP != 1
def get_time(self): '''get time, using ATTITUDE.time_boot_ms if in SITL with SIM_SPEEDUP != 1''' systime = time.time() - self.mpstate.start_time_s if not self.mpstate.is_sitl: return systime try: speedup = int(self.get_mav_param('SIM_SPEEDUP',1)) except Ex...
return a distance as a string
def dist_string(self, val_meters): '''return a distance as a string''' if self.settings.dist_unit == 'nm': return "%.1fnm" % (val_meters * 0.000539957) if self.settings.dist_unit == 'miles': return "%.1fmiles" % (val_meters * 0.000621371) return "%um" % val_meters
return a speed in configured units
def speed_convert_units(self, val_ms): '''return a speed in configured units''' if self.settings.speed_unit == 'knots': return val_ms * 1.94384 elif self.settings.speed_unit == 'mph': return val_ms * 2.23694 return val_ms
set prompt for command line
def set_prompt(self, prompt): '''set prompt for command line''' if prompt and self.settings.vehicle_name: # add in optional vehicle name prompt = self.settings.vehicle_name + ':' + prompt self.mpstate.rl.set_prompt(prompt)
return a link label as a string
def link_label(link): '''return a link label as a string''' if hasattr(link, 'label'): label = link.label else: label = str(link.linknum+1) return label
see if a msg is from our primary vehicle
def is_primary_vehicle(self, msg): '''see if a msg is from our primary vehicle''' sysid = msg.get_srcSystem() if self.target_system == 0 or self.target_system == sysid: return True return False
allocate a colour to be used for a flight mode
def next_flightmode_colour(self): '''allocate a colour to be used for a flight mode''' if self.flightmode_colour_index > len(flightmode_colours): print("Out of colours; reusing") self.flightmode_colour_index = 0 ret = flightmode_colours[self.flightmode_colour_index] ...
return colour to be used for rendering a flight mode background
def flightmode_colour(self, flightmode): '''return colour to be used for rendering a flight mode background''' if flightmode not in self.flightmode_colourmap: self.flightmode_colourmap[flightmode] = self.next_flightmode_colour() return self.flightmode_colourmap[flightmode]
setup plotting ticks on x axis
def setup_xrange(self, xrange): '''setup plotting ticks on x axis''' if self.xaxis: return xrange *= 24 * 60 * 60 interval = 1 intervals = [ 1, 2, 5, 10, 15, 30, 60, 120, 240, 300, 600, 900, 1800, 3600, 7200, 5*3600, 10*3600, 24*3600 ] fo...
called when x limits are changed
def xlim_changed(self, axsubplot): '''called when x limits are changed''' xrange = axsubplot.get_xbound() xlim = axsubplot.get_xlim() self.setup_xrange(xrange[1] - xrange[0]) if self.draw_events == 0: # ignore limit change before first draw event return ...
plot a set of graphs using date for x axis
def plotit(self, x, y, fields, colors=[], title=None): '''plot a set of graphs using date for x axis''' pylab.ion() self.fig = pylab.figure(num=1, figsize=(12,6)) self.ax1 = self.fig.gca() ax2 = None for i in range(0, len(fields)): if len(x[i]) == 0: continue ...
add some data
def add_data(self, t, msg, vars): '''add some data''' mtype = msg.get_type() for i in range(0, len(self.fields)): if mtype not in self.field_types[i]: continue f = self.fields[i] simple = self.simple_field[i] if simple is not None: ...
convert log timestamp to days
def timestamp_to_days(self, timestamp): '''convert log timestamp to days''' if self.tday_base is None: try: self.tday_base = matplotlib.dates.date2num(datetime.datetime.fromtimestamp(timestamp+self.timeshift)) self.tday_basetime = timestamp except ...
process one file
def process_mav(self, mlog, flightmode_selections): '''process one file''' self.vars = {} idx = 0 all_false = True for s in flightmode_selections: if s: all_false = False # pre-calc right/left axes self.num_fields = len(self.fields) ...
handle xlim change requests from queue
def xlim_change_check(self, idx): '''handle xlim change requests from queue''' if not self.xlim_pipe[1].poll(): return xlim = self.xlim_pipe[1].recv() if xlim is None: return #print("recv: ", self.graph_num, xlim) if self.ax1 is not None and xlim !...
process and display graph
def process(self, flightmode_selections, _flightmodes, block=True): '''process and display graph''' self.msg_types = set() self.multiplier = [] self.field_types = [] self.xlim = None self.flightmode_list = _flightmodes # work out msg types we are interested in ...
show graph
def show(self, lenmavlist, block=True, xlim_pipe=None): '''show graph''' if xlim_pipe is not None: xlim_pipe[0].close() self.xlim_pipe = xlim_pipe if self.labels is not None: labels = self.labels.split(',') if len(labels) != len(fields)*lenmavlist: ...
control behaviour of the module
def cmd_ublox(self, args): '''control behaviour of the module''' if len(args) == 0: print(self.usage()) elif args[0] == "status": print(self.cmd_status()) elif args[0] == "set": self.ublox_settings.command(args[1:]) elif args[0] == "reset": ...
attempts to cold-reboot (factory-reboot) gps module
def cmd_ublox_reset(self, args): '''attempts to cold-reboot (factory-reboot) gps module''' print("Sending uBlox reset") msg = struct.pack("<HBB", 0xFFFF, 0x0, 0) self.master.mav.gps_inject_data_send( self.target_system, self.target_component, len(msg),...
called rapidly by mavproxy
def idle_task(self): '''called rapidly by mavproxy''' if self.fix_type >= 3: # don't do anything if we have a fix return if self.mpstate.status.armed: # do not upload data over telemetry link if we are armed # perhaps we should just limit rate inst...
handle mavlink packets
def mavlink_packet(self, m): '''handle mavlink packets''' # can't use status.msgs as we need this filtered to our target system if (self.settings.target_system != 0 and self.settings.target_system != m.get_srcSystem()): return if m.get_type() == 'GPS_RAW_INT': ...
reboot autopilot
def cmd_reboot(self, args): '''reboot autopilot''' if len(args) > 0 and args[0] == 'bootloader': self.master.reboot_autopilot(True) else: self.master.reboot_autopilot()
lockup autopilot for watchdog testing
def cmd_lockup_autopilot(self, args): '''lockup autopilot for watchdog testing''' if len(args) > 0 and args[0] == 'IREALLYMEANIT': print("Sending lockup command") self.master.mav.command_long_send(self.settings.target_system, self.settings.target_component, ...
get home position
def cmd_gethome(self, args): '''get home position''' self.master.mav.command_long_send(self.settings.target_system, 0, mavutil.mavlink.MAV_CMD_GET_HOME_POSITION, 0, 0, 0, 0, 0, 0...
send LED pattern as override
def cmd_led(self, args): '''send LED pattern as override''' if len(args) < 3: print("Usage: led RED GREEN BLUE <RATE>") return pattern = [0] * 24 pattern[0] = int(args[0]) pattern[1] = int(args[1]) pattern[2] = int(args[2]) if len(...
send LED pattern as override, using OreoLED conventions
def cmd_oreoled(self, args): '''send LED pattern as override, using OreoLED conventions''' if len(args) < 4: print("Usage: oreoled LEDNUM RED GREEN BLUE <RATE>") return lednum = int(args[0]) pattern = [0] * 24 pattern[0] = ord('R') pattern[1] = ord...
flash bootloader
def cmd_flashbootloader(self, args): '''flash bootloader''' self.master.mav.command_long_send(self.settings.target_system, 0, mavutil.mavlink.MAV_CMD_FLASH_BOOTLOADER, 0, 0, ...
send PLAY_TUNE message
def cmd_playtune(self, args): '''send PLAY_TUNE message''' if len(args) < 1: print("Usage: playtune TUNE") return tune = args[0] str1 = tune[0:30] str2 = tune[30:] if sys.version_info.major >= 3 and not isinstance(str1, bytes): str1 = b...
decode device IDs from parameters
def cmd_devid(self, args): '''decode device IDs from parameters''' for p in self.mav_param.keys(): if p.startswith('COMPASS_DEV_ID'): mp_util.decode_devid(self.mav_param[p], p) if p.startswith('INS_') and p.endswith('_ID'): mp_util.decode_devid(sel...
add to the default popup menu
def add_menu(self, menu): '''add to the default popup menu''' from MAVProxy.modules.mavproxy_map import mp_slipmap self.default_popup.add(menu) self.map.add_object(mp_slipmap.SlipDefaultPopup(self.default_popup, combine=True))
map commands
def cmd_map(self, args): '''map commands''' from MAVProxy.modules.mavproxy_map import mp_slipmap if len(args) < 1: print("usage: map <icon|set>") elif args[0] == "icon": if len(args) < 3: print("Usage: map icon <lat> <lon> <icon>") else...
return a tuple describing the colour a waypoint should appear on the map
def colour_for_wp(self, wp_num): '''return a tuple describing the colour a waypoint should appear on the map''' wp = self.module('wp').wploader.wp(wp_num) command = wp.command return self._colour_for_wp_command.get(command, (0,255,0))
return the label the waypoint which should appear on the map
def label_for_waypoint(self, wp_num): '''return the label the waypoint which should appear on the map''' wp = self.module('wp').wploader.wp(wp_num) command = wp.command if command not in self._label_suffix_for_wp_command: return str(wp_num) return str(wp_num) + "(" + ...
display the waypoints
def display_waypoints(self): '''display the waypoints''' from MAVProxy.modules.mavproxy_map import mp_slipmap self.mission_list = self.module('wp').wploader.view_list() polygons = self.module('wp').wploader.polygon_list() self.map.add_object(mp_slipmap.SlipClearLayer('Mission')) ...
remove a mission nofly polygon
def remove_mission_nofly(self, key, selection_index): '''remove a mission nofly polygon''' if not self.validate_nofly(): print("NoFly invalid") return print("NoFly valid") idx = self.selection_index_to_idx(key, selection_index) wploader = self.module('wp'...
handle a popup menu event from the map
def handle_menu_event(self, obj): '''handle a popup menu event from the map''' menuitem = obj.menuitem if menuitem.returnkey.startswith('# '): cmd = menuitem.returnkey[2:] if menuitem.handler is not None: if menuitem.handler_result is None: ...
called when an event happens on the slipmap
def map_callback(self, obj): '''called when an event happens on the slipmap''' from MAVProxy.modules.mavproxy_map import mp_slipmap if isinstance(obj, mp_slipmap.SlipMenuEvent): self.handle_menu_event(obj) return if not isinstance(obj, mp_slipmap.SlipMouseEvent): ...
unload module
def unload(self): '''unload module''' super(MapModule, self).unload() self.map.close() if self.instance == 1: self.mpstate.map = None self.mpstate.map_functions = {}
end line drawing
def drawing_end(self): '''end line drawing''' from MAVProxy.modules.mavproxy_map import mp_slipmap if self.draw_callback is None: return self.draw_callback(self.draw_line) self.draw_callback = None self.map.add_object(mp_slipmap.SlipDefaultPopup(self.default_p...