INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
camctrlmsg
def cmd_camctrlmsg(self, args): '''camctrlmsg''' print("Sent DIGICAM_CONFIGURE CMD_LONG") self.master.mav.command_long_send( self.settings.target_system, # target_system 0, # target_component mavutil.mavlink.MAV_CMD_DO_DIGICAM_CONFIGURE, # command ...
cammsg
def cmd_cammsg(self, args): '''cammsg''' print("Sent DIGICAM_CONTROL CMD_LONG") self.master.mav.command_long_send( self.settings.target_system, # target_system 0, # target_component mavutil.mavlink.MAV_CMD_DO_DIGICAM_CONTROL, # command 0, # confi...
yaw angle angular_speed angle_mode
def cmd_condition_yaw(self, args): '''yaw angle angular_speed angle_mode''' if ( len(args) != 3): print("Usage: yaw ANGLE ANGULAR_SPEED MODE:[0 absolute / 1 relative]") return if (len(args) == 3): angle = float(args[0]) angular_speed = float(args[...
velocity x-ms y-ms z-ms
def cmd_velocity(self, args): '''velocity x-ms y-ms z-ms''' if (len(args) != 3): print("Usage: velocity x y z (m/s)") return if (len(args) == 3): x_mps = float(args[0]) y_mps = float(args[1]) z_mps = float(args[2]) #print("...
position x-m y-m z-m
def cmd_position(self, args): '''position x-m y-m z-m''' if (len(args) != 3): print("Usage: position x y z (meters)") return if (len(args) == 3): x_m = float(args[0]) y_m = float(args[1]) z_m = float(args[2]) print("x:%f, y...
attitude q0 q1 q2 q3 thrust
def cmd_attitude(self, args): '''attitude q0 q1 q2 q3 thrust''' if len(args) != 5: print("Usage: attitude q0 q1 q2 q3 thrust (0~1)") return if len(args) == 5: q0 = float(args[0]) q1 = float(args[1]) q2 = float(args[2]) q3 =...
posvel mapclick vN vE vD
def cmd_posvel(self, args): '''posvel mapclick vN vE vD''' ignoremask = 511 latlon = None try: latlon = self.module('map').click_position except Exception: pass if latlon is None: print ("set latlon to zeros") latlon = [0, 0...
repaint the image
def on_paint(self, event): '''repaint the image''' dc = wx.AutoBufferedPaintDC(self) dc.DrawBitmap(self._bmp, 0, 0)
set the image to be displayed
def set_image(self, img): '''set the image to be displayed''' self._bmp = wx.BitmapFromImage(img) self.SetMinSize((self._bmp.GetWidth(), self._bmp.GetHeight()))
Generate mavlink message formatters and parsers (C and Python ) using options and args where args are a list of xml files. This function allows python scripts under Windows to control mavgen using the same interface as shell scripts under Unix
def mavgen(opts, args): """Generate mavlink message formatters and parsers (C and Python ) using options and args where args are a list of xml files. This function allows python scripts under Windows to control mavgen using the same interface as shell scripts under Unix""" xml = [] # Enable va...
generate the python code on the fly for a MAVLink dialect
def mavgen_python_dialect(dialect, wire_protocol): '''generate the python code on the fly for a MAVLink dialect''' dialects = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'dialects') mdef = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..', 'message_definitions') if...
work out signal loss times for a log file
def sigloss(logfile): '''work out signal loss times for a log file''' print("Processing log %s" % filename) mlog = mavutil.mavlink_connection(filename, planner_format=args.planner, notimestamps=args.notimestamps, ...
convert a tlog to a .m file
def process_tlog(filename): '''convert a tlog to a .m file''' print("Processing %s" % filename) mlog = mavutil.mavlink_connection(filename, dialect=args.dialect, zero_time_base=True) # first walk the entire file, grabbing all messages into a hash of lists, #and the first message of each type into...
return radius give data point and offsets
def radius(d, offsets, motor_ofs): '''return radius give data point and offsets''' (mag, motor) = d return (mag + offsets + motor*motor_ofs).length()
find best magnetometer offset fit to a log file
def magfit(logfile): '''find best magnetometer offset fit to a log file''' print("Processing log %s" % filename) mlog = mavutil.mavlink_connection(filename, notimestamps=args.notimestamps) data = [] last_t = 0 offsets = Vector3(0,0,0) motor_ofs = Vector3(0,0,0) motor = 0.0 # now ...
generate MVMavlink header and implementation
def generate_mavlink(directory, xml): '''generate MVMavlink header and implementation''' f = open(os.path.join(directory, "MVMavlink.h"), mode='w') t.write(f,''' // // MVMavlink.h // MAVLink communications protocol built from ${basename}.xml // // Created on ${parse_time} by mavgen_objc.py // http://qgr...
generate per-message header and implementation file
def generate_message(directory, m): '''generate per-message header and implementation file''' f = open(os.path.join(directory, 'MVMessage%s.h' % m.name_camel_case), mode='w') t.write(f, ''' // // MVMessage${name_camel_case}.h // MAVLink communications protocol built from ${basename}.xml // // Created by ...
generate a CamelCase string from an underscore_string.
def camel_case_from_underscores(string): """generate a CamelCase string from an underscore_string.""" components = string.split('_') string = '' for component in components: string += component[0].upper() + component[1:] return string
generate a lower-cased camelCase string from an underscore_string. For example: my_variable_name -> myVariableName
def lower_camel_case_from_underscores(string): """generate a lower-cased camelCase string from an underscore_string. For example: my_variable_name -> myVariableName""" components = string.split('_') string = components[0] for component in components[1:]: string += component[0].upper() + comp...
generate files for one XML file
def generate_message_definitions(basename, xml): '''generate files for one XML file''' directory = os.path.join(basename, xml.basename) print("Generating Objective-C implementation in directory %s" % directory) mavparse.mkdir_p(directory) xml.basename_camel_case = camel_case_from_underscores(xml....
generate complete MAVLink Objective-C implemenation
def generate(basename, xml_list): '''generate complete MAVLink Objective-C implemenation''' generate_shared(basename, xml_list) for xml in xml_list: generate_message_definitions(basename, xml)
Translates from JderobotTypes CMDVel to ROS Twist. @param vel: JderobotTypes CMDVel to translate @type img: JdeRobotTypes.CMDVel @return a Twist translated from vel
def cmdvel2Twist(vel): ''' Translates from JderobotTypes CMDVel to ROS Twist. @param vel: JderobotTypes CMDVel to translate @type img: JdeRobotTypes.CMDVel @return a Twist translated from vel ''' tw = TwistStamped() tw.twist.linear.x = vel.vx tw.twist.linear.y = vel.vy tw.tw...
Function to publish cmdvel.
def publish (self): ''' Function to publish cmdvel. ''' self.lock.acquire() tw = cmdvel2Twist(self.vel) self.lock.release() if (self.jdrc.getState() == "flying"): self.pub.publish(tw)
child process - this holds all the GUI elements
def child_task(self): '''child process - this holds all the GUI elements''' mp_util.child_close_fds() import matplotlib import wx_processguard from wx_loader import wx from live_graph_ui import GraphFrame matplotlib.use('WXAgg') app = wx.App(Fals...
add some data to the graph
def add_values(self, values): '''add some data to the graph''' if self.child.is_alive(): self.parent_pipe.send(values)
close the graph
def close(self): '''close the graph''' self.close_graph.set() if self.is_alive(): self.child.join(2)
find best magnetometer offset fit to a log file
def magfit(logfile): '''find best magnetometer offset fit to a log file''' print("Processing log %s" % filename) mlog = mavutil.mavlink_connection(filename, notimestamps=args.notimestamps) flying = False gps_heading = 0.0 data = [] # get the current mag offsets m = mlog.recv_match(typ...
Generate Swift file header with source files list and creation date
def generate_header(outf, filelist, xml): """Generate Swift file header with source files list and creation date""" print("Generating Swift file header") t.write(outf, """ // // MAVLink.swift // MAVLink Micro Air Vehicle Communication Protocol // // Generated from ${FILELIST} on ${PARSE_TIME} by mavgen...
Iterate through all enums and create Swift equivalents
def generate_enums(outf, enums, msgs): """Iterate through all enums and create Swift equivalents""" print("Generating Enums") for enum in enums: t.write(outf, """ ${formatted_description}public enum ${swift_name}: ${raw_value_type}, Enum { ${{entry:${formatted_description}\tcase ${swift_name} = ${...
Search appropirate raw type for enums in messages fields
def get_enum_raw_type(enum, msgs): """Search appropirate raw type for enums in messages fields""" for msg in msgs: for field in msg.fields: if field.enum == enum.name: return swift_types[field.type][0] return "Int"
Generate Swift structs to represent all MAVLink messages
def generate_messages(outf, msgs): """Generate Swift structs to represent all MAVLink messages""" print("Generating Messages") t.write(outf, """ // MARK: MAVLink messages /** Message protocol describes common for all MAVLink messages properties and methods requirements */ public protocol Message: M...
Open and copy static code from specified file
def append_static_code(filename, outf): """Open and copy static code from specified file""" basepath = os.path.dirname(os.path.realpath(__file__)) filepath = os.path.join(basepath, 'swift/%s' % filename) print("Appending content of %s" % filename) with open(filepath) as inf: for l...
Create array for mapping message Ids to proper structs
def generate_message_mappings_array(outf, msgs): """Create array for mapping message Ids to proper structs""" classes = [] for msg in msgs: classes.append("%u: %s.self" % (msg.id, msg.swift_name)) t.write(outf, """ /** Array for mapping message id to proper struct */ private let messageI...
Create array with message lengths to validate known message lengths
def generate_message_lengths_array(outf, msgs): """Create array with message lengths to validate known message lengths""" # form message lengths array lengths = [] for msg in msgs: lengths.append("%u: %u" % (msg.id, msg.wire_length)) t.write(outf, """ /** Message lengths array for kn...
Add array with CRC extra values to detect incompatible XML changes
def generate_message_crc_extra_array(outf, msgs): """Add array with CRC extra values to detect incompatible XML changes""" crcs = [] for msg in msgs: crcs.append("%u: %u" % (msg.id, msg.crc_extra)) t.write(outf, """ /** Message CRSs extra for detection incompatible XML changes */ private...
Generate a CamelCase string from an underscore_string
def camel_case_from_underscores(string): """Generate a CamelCase string from an underscore_string""" components = string.split('_') string = '' for component in components: if component in abbreviations: string += component else: string += component[0].upper() +...
Add camel case swift names for enums an entries, descriptions and sort enums alphabetically
def generate_enums_info(enums, msgs): """Add camel case swift names for enums an entries, descriptions and sort enums alphabetically""" for enum in enums: enum.swift_name = camel_case_from_underscores(enum.name) enum.raw_value_type = get_enum_raw_type(enum, msgs) enum.formatted_descrip...
Add proper formated variable names, initializers and type names to use in templates
def generate_messages_info(msgs): """Add proper formated variable names, initializers and type names to use in templates""" for msg in msgs: msg.swift_name = camel_case_from_underscores(msg.name) msg.formatted_description = "" if msg.description: msg.description = " ".join(...
Generate complete MAVLink Swift implemenation
def generate(basename, xml_list): """Generate complete MAVLink Swift implemenation""" if os.path.isdir(basename): filename = os.path.join(basename, 'MAVLink.swift') else: filename = basename msgs = [] enums = [] filelist = [] for xml in xml_list: msgs.extend(xml.mes...
Updates LaserData.
def update(self): ''' Updates LaserData. ''' if self.hasproxy(): sonarD = SonarData() range = 0 data = self.proxy.getSonarData() sonarD.range = data.range sonarD.maxAngle = data.maxAngle sonarD.minAngle = data.minAn...
Returns last LaserData. @return last JdeRobotTypes LaserData saved
def getSonarData(self): ''' Returns last LaserData. @return last JdeRobotTypes LaserData saved ''' if self.hasproxy(): self.lock.acquire() sonar = self.sonar self.lock.release() return sonar return None
return true if waypoint is a loiter waypoint
def wp_is_loiter(self, i): '''return true if waypoint is a loiter waypoint''' loiter_cmds = [mavutil.mavlink.MAV_CMD_NAV_LOITER_UNLIM, mavutil.mavlink.MAV_CMD_NAV_LOITER_TURNS, mavutil.mavlink.MAV_CMD_NAV_LOITER_TIME, mavutil.mavlink.MAV_CMD_NAV_LOITER_TO_...
add a waypoint
def add(self, w, comment=''): '''add a waypoint''' w = copy.copy(w) if comment: w.comment = comment w.seq = self.count() self.wpoints.append(w) self.last_change = time.time()
insert a waypoint
def insert(self, idx, w, comment=''): '''insert a waypoint''' if idx >= self.count(): self.add(w, comment) return if idx < 0: return w = copy.copy(w) if comment: w.comment = comment w.seq = idx self.wpoints.insert(id...
reindex waypoints
def reindex(self): '''reindex waypoints''' for i in range(self.count()): w = self.wpoints[i] w.seq = i self.last_change = time.time()
add a point via latitude/longitude/altitude
def add_latlonalt(self, lat, lon, altitude, terrain_alt=False): '''add a point via latitude/longitude/altitude''' if terrain_alt: frame = mavutil.mavlink.MAV_FRAME_GLOBAL_TERRAIN_ALT else: frame = mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT p = mavutil.mavlink.M...
set a waypoint
def set(self, w, idx): '''set a waypoint''' w.seq = idx if w.seq == self.count(): return self.add(w) if self.count() <= idx: raise MAVWPError('adding waypoint at idx=%u past end of list (count=%u)' % (idx, self.count())) self.wpoints[idx] = w self....
remove a waypoint
def remove(self, w): '''remove a waypoint''' self.wpoints.remove(w) self.last_change = time.time() self.reindex()
read a version 100 waypoint
def _read_waypoints_v100(self, file): '''read a version 100 waypoint''' cmdmap = { 2 : mavutil.mavlink.MAV_CMD_NAV_TAKEOFF, 3 : mavutil.mavlink.MAV_CMD_NAV_RETURN_TO_LAUNCH, 4 : mavutil.mavlink.MAV_CMD_NAV_LAND, 24: mavutil.mavlink.MAV_CMD_NAV_TAKEOFF, ...
read a version 110 waypoint
def _read_waypoints_v110(self, file): '''read a version 110 waypoint''' comment = '' for line in file: if line.startswith('#'): comment = line[1:].lstrip() continue line = line.strip() if not line: continue ...
load waypoints from a file. returns number of waypoints loaded
def load(self, filename): '''load waypoints from a file. returns number of waypoints loaded''' f = open(filename, mode='r') version_line = f.readline().strip() if version_line == "QGC WPL 100": readfn = self._read_waypoints_v100 elif version_line == "QGC WPL 1...
save waypoints to a file
def save(self, filename): '''save waypoints to a file''' f = open(filename, mode='w') f.write("QGC WPL 110\n") for w in self.wpoints: if getattr(w, 'comment', None): f.write("# %s\n" % w.comment) f.write("%u\t%u\t%u\t%u\t%f\t%f\t%f\t%f\t%f\t%f\t%f\...
see if cmd is a MAV_CMD with a latitide/longitude. We check if it has Latitude and Longitude params in the right indexes
def is_location_command(self, cmd): '''see if cmd is a MAV_CMD with a latitide/longitude. We check if it has Latitude and Longitude params in the right indexes''' mav_cmd = mavutil.mavlink.enums['MAV_CMD'] if not cmd in mav_cmd: return False if not mav_cmd[cmd].param....
return a list waypoint indexes in view order
def view_indexes(self, done=None): '''return a list waypoint indexes in view order''' ret = [] if done is None: done = set() idx = 0 # find first point not done yet while idx < self.count(): if not idx in done: break id...
return a polygon for the waypoints
def polygon(self, done=None): '''return a polygon for the waypoints''' indexes = self.view_indexes(done) points = [] for idx in indexes: w = self.wp(idx) points.append((w.x, w.y)) return points
return a list of polygons for the waypoints
def polygon_list(self): '''return a list of polygons for the waypoints''' done = set() ret = [] while len(done) != self.count(): p = self.polygon(done) if len(p) > 0: ret.append(p) return ret
return a list of polygon indexes lists for the waypoints
def view_list(self): '''return a list of polygon indexes lists for the waypoints''' done = set() ret = [] while len(done) != self.count(): p = self.view_indexes(done) if len(p) > 0: ret.append(p) return ret
reset counters and indexes
def reindex(self): '''reset counters and indexes''' for i in range(self.rally_count()): self.rally_points[i].count = self.rally_count() self.rally_points[i].idx = i self.last_change = time.time()
add rallypoint to end of list
def append_rally_point(self, p): '''add rallypoint to end of list''' if (self.rally_count() > 9): print("Can't have more than 10 rally points, not adding.") return self.rally_points.append(p) self.reindex()
add a point via latitude/longitude
def create_and_append_rally_point(self, lat, lon, alt, break_alt, land_dir, flags): '''add a point via latitude/longitude''' p = mavutil.mavlink.MAVLink_rally_point_message(self.target_system, self.target_component, self.rally_count(), 0, lat, lon,...
remove a rally point
def remove(self, i): '''remove a rally point''' if i < 1 or i > self.rally_count(): print("Invalid rally point number %u" % i) self.rally_points.pop(i-1) self.reindex()
move a rally point
def move(self, i, lat, lng, change_time=True): '''move a rally point''' if i < 1 or i > self.rally_count(): print("Invalid rally point number %u" % i) self.rally_points[i-1].lat = int(lat*1e7) self.rally_points[i-1].lng = int(lng*1e7) if change_time: self....
set rally point altitude(s)
def set_alt(self, i, alt, break_alt=None, change_time=True): '''set rally point altitude(s)''' if i < 1 or i > self.rally_count(): print("Inavlid rally point number %u" % i) return self.rally_points[i-1].alt = int(alt) if (break_alt != None): self.rall...
load rally and rally_land points from a file. returns number of points loaded
def load(self, filename): '''load rally and rally_land points from a file. returns number of points loaded''' f = open(filename, mode='r') self.clear() for line in f: if line.startswith('#'): continue line = line.strip() if not...
save fence points to a file
def save(self, filename): '''save fence points to a file''' f = open(filename, mode='w') for p in self.rally_points: f.write("RALLY %f\t%f\t%f\t%f\t%f\t%d\n" % (p.lat * 1e-7, p.lng * 1e-7, p.alt, p.break_alt, p.land_dir, p.flags...
reindex waypoints
def reindex(self): '''reindex waypoints''' for i in range(self.count()): w = self.points[i] w.idx = i w.count = self.count() w.target_system = self.target_system w.target_component = self.target_component self.last_change = time.time()
add a point via latitude/longitude
def add_latlon(self, lat, lon): '''add a point via latitude/longitude''' p = mavutil.mavlink.MAVLink_fence_point_message(self.target_system, self.target_component, self.count(), 0, lat, lon) self.add(p)
load points from a file. returns number of points loaded
def load(self, filename): '''load points from a file. returns number of points loaded''' f = open(filename, mode='r') self.clear() for line in f: if line.startswith('#'): continue line = line.strip() if not line: ...
save fence points to a file
def save(self, filename): '''save fence points to a file''' f = open(filename, mode='w') for p in self.points: f.write("%f\t%f\n" % (p.lat, p.lng)) f.close()
move a fence point
def move(self, i, lat, lng, change_time=True): '''move a fence point''' if i < 0 or i >= self.count(): print("Invalid fence point number %u" % i) self.points[i].lat = lat self.points[i].lng = lng # ensure we close the polygon if i == 1: self.po...
remove a fence point
def remove(self, i, change_time=True): '''remove a fence point''' if i < 0 or i >= self.count(): print("Invalid fence point number %u" % i) self.points.pop(i) # ensure we close the polygon if i == 1: self.points[self.count()-1].lat = self.points[1].la...
return a polygon for the fence
def polygon(self): '''return a polygon for the fence''' points = [] for fp in self.points[1:]: points.append((fp.lat, fp.lng)) return points
add some command input to be processed
def add_input(cmd, immediate=False): '''add some command input to be processed''' if immediate: process_stdin(cmd) else: mpstate.input_queue.put(cmd)
set a parameter
def param_set(name, value, retries=3): '''set a parameter''' name = name.upper() return mpstate.mav_param.mavset(mpstate.master(), name, value, retries=retries)
show status
def cmd_status(args): '''show status''' if len(args) == 0: mpstate.status.show(sys.stdout, pattern=None) else: for pattern in args: mpstate.status.show(sys.stdout, pattern=pattern)
unload a module
def unload_module(modname): '''unload a module''' for (m,pm) in mpstate.modules: if m.name == modname: if hasattr(m, 'unload'): m.unload() mpstate.modules.remove((m,pm)) print("Unloaded module %s" % modname) return True print("Unable to...
alias commands
def cmd_alias(args): '''alias commands''' usage = "usage: alias <add|remove|list>" if len(args) < 1 or args[0] == "list": if len(args) >= 2: wildcard = args[1].upper() else: wildcard = '*' for a in sorted(mpstate.aliases.keys()): if fnmatch.fnmatch...
Clear out cached entries from _zip_directory_cache. See http://www.digi.com/wiki/developer/index.php/Error_messages
def clear_zipimport_cache(): """Clear out cached entries from _zip_directory_cache. See http://www.digi.com/wiki/developer/index.php/Error_messages""" import sys, zipimport syspath_backup = list(sys.path) zipimport._zip_directory_cache.clear() # load back items onto sys.path sys.path = sysp...
Given a package name like 'foo.bar.quux', imports the package and returns the desired module.
def import_package(name): """Given a package name like 'foo.bar.quux', imports the package and returns the desired module.""" import zipimport try: mod = __import__(name) except ImportError: clear_zipimport_cache() mod = __import__(name) components = name.split('.') ...
handle commands from user
def process_stdin(line): '''handle commands from user''' if line is None: sys.exit(0) # allow for modules to override input handling if mpstate.functions.input_handler is not None: mpstate.functions.input_handler(line) return line = line.strip() if mpstate.status.se...
process packets from the MAVLink master
def process_master(m): '''process packets from the MAVLink master''' try: s = m.recv(16*1024) except Exception: time.sleep(0.1) return # prevent a dead serial port from causing the CPU to spin. The user hitting enter will # cause it to try and reconnect if len(s) == 0: ...
open log files
def open_telemetry_logs(logpath_telem, logpath_telem_raw): '''open log files''' if opts.append_log or opts.continue_mode: mode = 'a' else: mode = 'w' mpstate.logfile = open(logpath_telem, mode=mode) mpstate.logfile_raw = open(logpath_telem_raw, mode=mode) print("Log Directory: %s...
set mavlink stream rates
def set_stream_rates(): '''set mavlink stream rates''' if (not msg_period.trigger() and mpstate.status.last_streamrate1 == mpstate.settings.streamrate and mpstate.status.last_streamrate2 == mpstate.settings.streamrate2): return mpstate.status.last_streamrate1 = mpstate.settings.strea...
check status of master links
def check_link_status(): '''check status of master links''' tnow = time.time() if mpstate.status.last_message != 0 and tnow > mpstate.status.last_message + 5: say("no link") mpstate.status.heartbeat_error = True for master in mpstate.mav_master: if not master.linkerror and (tnow ...
run periodic checks
def periodic_tasks(): '''run periodic checks''' if mpstate.status.setup_mode: return if (mpstate.settings.compdebug & 2) != 0: return if mpstate.settings.heartbeat != 0: heartbeat_period.frequency = mpstate.settings.heartbeat if heartbeat_period.trigger() and mpstate.setti...
wait for user input
def input_loop(): '''wait for user input''' global operation_takeoff global time_init_operation_takeoff global time_end_operation_takeoff while mpstate.status.exit != True: try: if mpstate.status.exit != True: if mpstate.udp.bound(): line = mp...
write status to status.txt
def show(self, f, pattern=None): '''write status to status.txt''' if pattern is None: f.write('Counters: ') for c in self.counters: f.write('%s:%s ' % (c, self.counters[c])) f.write('\n') f.write('MAV Errors: %u\n' % self.mav_error) ...
run a script file
def run_script(scriptfile): '''run a script file''' try: f = open(scriptfile, mode='r') except Exception: return mpstate.console.writeln("Running script %s" % scriptfile) for line in f: line = line.strip() if line == "" or line.startswith('#'): continue ...
write status to status.txt
def write(self): '''write status to status.txt''' f = open('status.txt', mode='w') self.show(f) f.close()
return the currently chosen mavlink master object
def master(self): '''return the currently chosen mavlink master object''' if len(self.mav_master) == 0: return None if self.settings.link > len(self.mav_master): self.settings.link = 1 # try to use one with no link error if not self.mav_master[self.setti...
display fft for raw ACC data in logfile
def fft(logfile): '''display fft for raw ACC data in logfile''' print("Processing log %s" % filename) mlog = mavutil.mavlink_connection(filename) data = {'ACC1.rate' : 1000, 'ACC2.rate' : 1600, 'ACC3.rate' : 1000, 'GYR1.rate' : 1000, 'GYR2.rate' : 800, ...
called on idle
def idle_task(self): '''called on idle''' if self.module('console') is not None and not self.menu_added_console: self.menu_added_console = True self.module('console').add_menu(self.menu)
help commands
def cmd_help(self, args): '''help commands''' if len(args) < 1: self.print_usage() return if args[0] == "about": print("MAVProxy Version " + self.version + "\nOS: " + self.host + "\nPython " + self.pythonversion) elif args[0] == "site": p...
generate complete MAVLink CSharp implemenation
def generate(basename, xml): '''generate complete MAVLink CSharp implemenation''' structsfilename = basename + '.generated.cs' msgs = [] enums = [] filelist = [] for x in xml: msgs.extend(x.message) enums.extend(x.enum) filelist.append(os.path.basename(x.filename)) ...
Loads the stylesheet. Takes care of importing the rc module. :param pyside: True to load the pyside rc file, False to load the PyQt rc file :return the stylesheet string
def load_stylesheet(pyside=True): """ Loads the stylesheet. Takes care of importing the rc module. :param pyside: True to load the pyside rc file, False to load the PyQt rc file :return the stylesheet string """ # Smart import of the rc file if pyside: import qdarkstyle.pyside_styl...
Loads the stylesheet for use in a pyqt5 application. :param pyside: True to load the pyside rc file, False to load the PyQt rc file :return the stylesheet string
def load_stylesheet_pyqt5(): """ Loads the stylesheet for use in a pyqt5 application. :param pyside: True to load the pyside rc file, False to load the PyQt rc file :return the stylesheet string """ # Smart import of the rc file import qdarkstyle.pyqt5_style_rc # Load the stylesheet c...
optionally call a handler function
def call_handler(self): '''optionally call a handler function''' if self.handler is None: return call = getattr(self.handler, 'call', None) if call is not None: self.handler_result = call()
append this menu item to a menu
def _append(self, menu): '''append this menu item to a menu''' menu.Append(self.id(), self.name, self.description)
find the selected menu item
def find_selected(self, event): '''find the selected menu item''' if event.GetId() == self.id(): self.checked = event.IsChecked() return self return None
append this menu item to a menu
def _append(self, menu): '''append this menu item to a menu''' menu.AppendCheckItem(self.id(), self.name, self.description) menu.Check(self.id(), self.checked)