_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q231000
HorizonFrame.adjustHeadingPointer
train
def adjustHeadingPointer(self): '''Adjust the value of the heading pointer.''' self.headingText.set_text(str(self.heading)) self.headingText.set_size(self.fontSize)
python
{ "resource": "" }
q231001
HorizonFrame.createNorthPointer
train
def createNorthPointer(self): '''Creates the north pointer relative to current heading.''' self.headingNorthTri = patches.RegularPolygon((0.0,0.80),3,0.05,color='k',zorder=4) self.axes.add_patch(self.headingNorthTri) self.headingNorthText = self.axes.text(0.0,0.675,'N',color='k',size=sel...
python
{ "resource": "" }
q231002
HorizonFrame.adjustNorthPointer
train
def adjustNorthPointer(self): '''Adjust the position and orientation of the north pointer.''' self.headingNorthText.set_size(self.fontSize) headingRotate = mpl.transforms.Affine2D().rotate_deg_around(0.0,0.0,self.heading)+self.axes.transData self.headingNorthText.set_transform(h...
python
{ "resource": "" }
q231003
HorizonFrame.createRPYText
train
def createRPYText(self): '''Creates the text for roll, pitch and yaw.''' self.rollText = self.axes.text(self.leftPos+(self.vertSize/10.0),-0.97+(2*self.vertSize)-(self.vertSize/10.0),'Roll: %.2f' % self.roll,color='w',size=self.fontSize) self.pitchText = self.axes.text(self.leftPos+(self.vertS...
python
{ "resource": "" }
q231004
HorizonFrame.updateRPYLocations
train
def updateRPYLocations(self): '''Update the locations of roll, pitch, yaw text.''' # Locations self.rollText.set_position((self.leftPos+(self.vertSize/10.0),-0.97+(2*self.vertSize)-(self.vertSize/10.0))) self.pitchText.set_position((self.leftPos+(self.vertSize/10.0),-0.97+self.vertSize-(...
python
{ "resource": "" }
q231005
HorizonFrame.updateRPYText
train
def updateRPYText(self): 'Updates the displayed Roll, Pitch, Yaw Text' self.rollText.set_text('Roll: %.2f' % self.roll) self.pitchText.set_text('Pitch: %.2f' % self.pitch) self.yawText.set_text('Yaw: %.2f' % self.yaw)
python
{ "resource": "" }
q231006
HorizonFrame.createCenterPointMarker
train
def createCenterPointMarker(self): '''Creates the center pointer in the middle of the screen.''' self.axes.add_patch(patches.Rectangle((-0.75,-self.thick),0.5,2.0*self.thick,facecolor='orange',zorder=3)) self.axes.add_patch(patches.Rectangle((0.25,-self.thick),0.5,2.0*self.thick,facecolor='orang...
python
{ "resource": "" }
q231007
HorizonFrame.createHorizonPolygons
train
def createHorizonPolygons(self): '''Creates the two polygons to show the sky and ground.''' # Sky Polygon vertsTop = [[-1,0],[-1,1],[1,1],[1,0],[-1,0]] self.topPolygon = Polygon(vertsTop,facecolor='dodgerblue',edgecolor='none') self.axes.add_patch(self.topPolygon) # Groun...
python
{ "resource": "" }
q231008
HorizonFrame.calcHorizonPoints
train
def calcHorizonPoints(self): '''Updates the verticies of the patches for the ground and sky.''' ydiff = math.tan(math.radians(-self.roll))*float(self.ratio) pitchdiff = self.dist10deg*(self.pitch/10.0) # Sky Polygon vertsTop = [(-self.ratio,ydiff-pitchdiff),(-self.ratio,1),(self....
python
{ "resource": "" }
q231009
HorizonFrame.createPitchMarkers
train
def createPitchMarkers(self): '''Creates the rectangle patches for the pitch indicators.''' self.pitchPatches = [] # Major Lines (multiple of 10 deg) for i in [-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9]: width = self.calcPitchMarkerWidth(i) currPatch = patche...
python
{ "resource": "" }
q231010
HorizonFrame.adjustPitchmarkers
train
def adjustPitchmarkers(self): '''Adjusts the location and orientation of pitch markers.''' pitchdiff = self.dist10deg*(self.pitch/10.0) rollRotate = mpl.transforms.Affine2D().rotate_deg_around(0.0,-pitchdiff,self.roll)+self.axes.transData j=0 for i in [-9,-8,-7,-6,-5,-4,-3,-2,-1,...
python
{ "resource": "" }
q231011
HorizonFrame.createAARText
train
def createAARText(self): '''Creates the text for airspeed, altitude and climb rate.''' self.airspeedText = self.axes.text(self.rightPos-(self.vertSize/10.0),-0.97+(2*self.vertSize)-(self.vertSize/10.0),'AS: %.1f m/s' % self.airspeed,color='w',size=self.fontSize,ha='right') self.altitudeText = ...
python
{ "resource": "" }
q231012
HorizonFrame.updateAARLocations
train
def updateAARLocations(self): '''Update the locations of airspeed, altitude and Climb rate.''' # Locations self.airspeedText.set_position((self.rightPos-(self.vertSize/10.0),-0.97+(2*self.vertSize)-(self.vertSize/10.0))) self.altitudeText.set_position((self.rightPos-(self.vertSize/10.0),...
python
{ "resource": "" }
q231013
HorizonFrame.updateAARText
train
def updateAARText(self): 'Updates the displayed airspeed, altitude, climb rate Text' self.airspeedText.set_text('AR: %.1f m/s' % self.airspeed) self.altitudeText.set_text('ALT: %.1f m ' % self.relAlt) self.climbRateText.set_text('CR: %.1f m/s' % self.climbRate)
python
{ "resource": "" }
q231014
HorizonFrame.createBatteryBar
train
def createBatteryBar(self): '''Creates the bar to display current battery percentage.''' self.batOutRec = patches.Rectangle((self.rightPos-(1.3+self.rOffset)*self.batWidth,1.0-(0.1+1.0+(2*0.075))*self.batHeight),self.batWidth*1.3,self.batHeight*1.15,facecolor='darkgrey',edgecolor='none') self.ba...
python
{ "resource": "" }
q231015
HorizonFrame.updateBatteryBar
train
def updateBatteryBar(self): '''Updates the position and values of the battery bar.''' # Bar self.batOutRec.set_xy((self.rightPos-(1.3+self.rOffset)*self.batWidth,1.0-(0.1+1.0+(2*0.075))*self.batHeight)) self.batInRec.set_xy((self.rightPos-(self.rOffset+1+0.15)*self.batWidth,1.0-(0.1+1+0....
python
{ "resource": "" }
q231016
HorizonFrame.createStateText
train
def createStateText(self): '''Creates the mode and arm state text.''' self.modeText = self.axes.text(self.leftPos+(self.vertSize/10.0),0.97,'UNKNOWN',color='grey',size=1.5*self.fontSize,ha='left',va='top') self.modeText.set_path_effects([PathEffects.withStroke(linewidth=self.fontSize/10.0,foregr...
python
{ "resource": "" }
q231017
HorizonFrame.updateStateText
train
def updateStateText(self): '''Updates the mode and colours red or green depending on arm state.''' self.modeText.set_position((self.leftPos+(self.vertSize/10.0),0.97)) self.modeText.set_text(self.mode) self.modeText.set_size(1.5*self.fontSize) if self.armed: self.mode...
python
{ "resource": "" }
q231018
HorizonFrame.createWPText
train
def createWPText(self): '''Creates the text for the current and final waypoint, and the distance to the new waypoint.''' self.wpText = self.axes.text(self.leftPos+(1.5*self.vertSize/10.0),0.97-(1.5*self.vertSize)+(0.5*self.vertSize/10.0),'0/0\n(0 m, 0 s)',color='w',size=self.fontSize,ha='left',v...
python
{ "resource": "" }
q231019
HorizonFrame.updateWPText
train
def updateWPText(self): '''Updates the current waypoint and distance to it.''' self.wpText.set_position((self.leftPos+(1.5*self.vertSize/10.0),0.97-(1.5*self.vertSize)+(0.5*self.vertSize/10.0))) self.wpText.set_size(self.fontSize) if type(self.nextWPTime) is str: self.wpText...
python
{ "resource": "" }
q231020
HorizonFrame.createWPPointer
train
def createWPPointer(self): '''Creates the waypoint pointer relative to current heading.''' self.headingWPTri = patches.RegularPolygon((0.0,0.55),3,0.05,facecolor='lime',zorder=4,ec='k') self.axes.add_patch(self.headingWPTri) self.headingWPText = self.axes.text(0.0,0.45,'1',color='lime',s...
python
{ "resource": "" }
q231021
HorizonFrame.adjustWPPointer
train
def adjustWPPointer(self): '''Adjust the position and orientation of the waypoint pointer.''' self.headingWPText.set_size(self.fontSize) headingRotate = mpl.transforms.Affine2D().rotate_deg_around(0.0,0.0,-self.wpBearing+self.heading)+self.axes.transData self.headingWPText.set_t...
python
{ "resource": "" }
q231022
HorizonFrame.createAltHistoryPlot
train
def createAltHistoryPlot(self): '''Creates the altitude history plot.''' self.altHistRect = patches.Rectangle((self.leftPos+(self.vertSize/10.0),-0.25),0.5,0.5,facecolor='grey',edgecolor='none',alpha=0.4,zorder=4) self.axes.add_patch(self.altHistRect) self.altPlot, = self.axes.plot([self...
python
{ "resource": "" }
q231023
HorizonFrame.updateAltHistory
train
def updateAltHistory(self): '''Updates the altitude history plot.''' self.altHist.append(self.relAlt) self.timeHist.append(self.relAltTime) # Delete entries older than x seconds histLim = 10 currentTime = time.time() point = 0 for i in range(0,len...
python
{ "resource": "" }
q231024
HorizonFrame.on_idle
train
def on_idle(self, event): '''To adjust text and positions on rescaling the window when resized.''' # Check for resize self.checkReszie() if self.resized: # Fix Window Scales self.rescaleX() self.calcFontScaling() # Re...
python
{ "resource": "" }
q231025
HorizonFrame.on_timer
train
def on_timer(self, event): '''Main Loop.''' state = self.state self.loopStartTime = time.time() if state.close_event.wait(0.001): self.timer.Stop() self.Destroy() return # Check for resizing self.checkReszie() if self.r...
python
{ "resource": "" }
q231026
HorizonFrame.on_KeyPress
train
def on_KeyPress(self,event): '''To adjust the distance between pitch markers.''' if event.GetKeyCode() == wx.WXK_UP: self.dist10deg += 0.1 print('Dist per 10 deg: %.1f' % self.dist10deg) elif event.GetKeyCode() == wx.WXK_DOWN: self.dist10deg -= 0.1 ...
python
{ "resource": "" }
q231027
FenceModule.fenceloader
train
def fenceloader(self): '''fence loader by sysid''' if not self.target_system in self.fenceloader_by_sysid: self.fenceloader_by_sysid[self.target_system] = mavwp.MAVFenceLoader() return self.fenceloader_by_sysid[self.target_system]
python
{ "resource": "" }
q231028
FenceModule.mavlink_packet
train
def mavlink_packet(self, m): '''handle and incoming mavlink packet''' if m.get_type() == "FENCE_STATUS": self.last_fence_breach = m.breach_time self.last_fence_status = m.breach_status elif m.get_type() in ['SYS_STATUS']: bits = mavutil.mavlink.MAV_SYS_STATUS_...
python
{ "resource": "" }
q231029
FenceModule.load_fence
train
def load_fence(self, filename): '''load fence points from a file''' try: self.fenceloader.target_system = self.target_system self.fenceloader.target_component = self.target_component self.fenceloader.load(filename.strip('"')) except Exception as msg: ...
python
{ "resource": "" }
q231030
FenceModule.list_fence
train
def list_fence(self, filename): '''list fence points, optionally saving to a file''' self.fenceloader.clear() count = self.get_mav_param('FENCE_TOTAL', 0) if count == 0: print("No geo-fence points") return for i in range(int(count)): p = self.f...
python
{ "resource": "" }
q231031
MPImage.poll
train
def poll(self): '''check for events, returning one event''' if self.out_queue.qsize() <= 0: return None evt = self.out_queue.get() while isinstance(evt, win_layout.WinLayout): win_layout.set_layout(evt, self.set_layout) if self.out_queue.qsize() == 0: ...
python
{ "resource": "" }
q231032
MPSlipMapFrame.find_object
train
def find_object(self, key, layers): '''find an object to be modified''' state = self.state if layers is None or layers == '': layers = state.layers.keys() for layer in layers: if key in state.layers[layer]: return state.layers[layer][key] ...
python
{ "resource": "" }
q231033
MPSlipMapFrame.add_object
train
def add_object(self, obj): '''add an object to a layer''' state = self.state if not obj.layer in state.layers: # its a new layer state.layers[obj.layer] = {} state.layers[obj.layer][obj.key] = obj state.need_redraw = True if (not self.legend_checkb...
python
{ "resource": "" }
q231034
MPSlipMapPanel.set_ground_width
train
def set_ground_width(self, ground_width): '''set ground width of view''' state = self.state state.ground_width = ground_width state.panel.re_center(state.width/2, state.height/2, state.lat, state.lon)
python
{ "resource": "" }
q231035
MPSlipMapPanel.show_popup
train
def show_popup(self, selected, pos): '''show popup menu for an object''' state = self.state if selected.popup_menu is not None: import copy popup_menu = selected.popup_menu if state.default_popup is not None and state.default_popup.combine: pop...
python
{ "resource": "" }
q231036
cmd_watch
train
def cmd_watch(args): '''watch a mavlink packet pattern''' if len(args) == 0: mpstate.status.watch = None return mpstate.status.watch = args print("Watching %s" % mpstate.status.watch)
python
{ "resource": "" }
q231037
load_module
train
def load_module(modname, quiet=False, **kwargs): '''load a module''' modpaths = ['MAVProxy.modules.mavproxy_%s' % modname, modname] for (m,pm) in mpstate.modules: if m.name == modname and not modname in mpstate.multi_instance: if not quiet: print("module %s already loaded...
python
{ "resource": "" }
q231038
process_mavlink
train
def process_mavlink(slave): '''process packets from MAVLink slaves, forwarding to the master''' try: buf = slave.recv() except socket.error: return try: global mavversion if slave.first_byte and mavversion is None: slave.auto_mavlink_version(buf) msgs ...
python
{ "resource": "" }
q231039
log_writer
train
def log_writer(): '''log writing thread''' while True: mpstate.logfile_raw.write(bytearray(mpstate.logqueue_raw.get())) timeout = time.time() + 10 while not mpstate.logqueue_raw.empty() and time.time() < timeout: mpstate.logfile_raw.write(mpstate.logqueue_raw.get()) w...
python
{ "resource": "" }
q231040
main_loop
train
def main_loop(): '''main processing loop''' global screensaver_cookie if not mpstate.status.setup_mode and not opts.nowait: for master in mpstate.mav_master: if master.linknum != 0: break print("Waiting for heartbeat from %s" % master.address) se...
python
{ "resource": "" }
q231041
set_mav_version
train
def set_mav_version(mav10, mav20, autoProtocol, mavversionArg): '''Set the Mavlink version based on commandline options''' # if(mav10 == True or mav20 == True or autoProtocol == True): # print("Warning: Using deprecated --mav10, --mav20 or --auto-protocol options. Use --mavversion instead") #sanity c...
python
{ "resource": "" }
q231042
MPState.mav_param
train
def mav_param(self): '''map mav_param onto the current target system parameters''' compid = self.settings.target_component if compid == 0: compid = 1 sysid = (self.settings.target_system, compid) if not sysid in self.mav_param_by_sysid: self.mav_param_by_s...
python
{ "resource": "" }
q231043
get_wx_window_layout
train
def get_wx_window_layout(wx_window): '''get a WinLayout for a wx window''' dsize = wx.DisplaySize() pos = wx_window.GetPosition() size = wx_window.GetSize() name = wx_window.GetTitle() return WinLayout(name, pos, size, dsize)
python
{ "resource": "" }
q231044
set_wx_window_layout
train
def set_wx_window_layout(wx_window, layout): '''set a WinLayout for a wx window''' try: wx_window.SetSize(layout.size) wx_window.SetPosition(layout.pos) except Exception as ex: print(ex)
python
{ "resource": "" }
q231045
set_layout
train
def set_layout(wlayout, callback): '''set window layout''' global display_size global window_list global loaded_layout global pending_load global vehiclename #if not wlayout.name in window_list: # print("layout %s" % wlayout) if not wlayout.name in window_list and loaded_layout is...
python
{ "resource": "" }
q231046
layout_filename
train
def layout_filename(fallback): '''get location of layout file''' global display_size global vehiclename (dw,dh) = display_size if 'HOME' in os.environ: dirname = os.path.join(os.environ['HOME'], ".mavproxy") if not os.path.exists(dirname): try: os.mkdir(di...
python
{ "resource": "" }
q231047
save_layout
train
def save_layout(vehname): '''save window layout''' global display_size global window_list global vehiclename if display_size is None: print("No layouts to save") return vehiclename = vehname fname = layout_filename(False) if fname is None: print("No file to save l...
python
{ "resource": "" }
q231048
load_layout
train
def load_layout(vehname): '''load window layout''' global display_size global window_list global loaded_layout global pending_load global vehiclename if display_size is None: pending_load = True return vehiclename = vehname fname = layout_filename(True) if fname i...
python
{ "resource": "" }
q231049
TabbedDialog.on_apply
train
def on_apply(self, event): '''called on apply''' for label in self.setting_map.keys(): setting = self.setting_map[label] ctrl = self.controls[label] value = ctrl.GetValue() if str(value) != str(setting.value): oldvalue = setting.value ...
python
{ "resource": "" }
q231050
TabbedDialog.on_save
train
def on_save(self, event): '''called on save button''' dlg = wx.FileDialog(None, self.settings.get_title(), '', "", '*.*', wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) if dlg.ShowModal() == wx.ID_OK: self.settings.save(dlg.GetPath())
python
{ "resource": "" }
q231051
TabbedDialog.on_load
train
def on_load(self, event): '''called on load button''' dlg = wx.FileDialog(None, self.settings.get_title(), '', "", '*.*', wx.FD_OPEN) if dlg.ShowModal() == wx.ID_OK: self.settings.load(dlg.GetPath()) # update the controls with new values for label in self.setting_map....
python
{ "resource": "" }
q231052
TabbedDialog.add_text
train
def add_text(self, setting, width=300, height=100, multiline=False): '''add a text input line''' tab = self.panel(setting.tab) if multiline: ctrl = wx.TextCtrl(tab, -1, "", size=(width,height), style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER) else: ctrl = wx.TextCtrl(ta...
python
{ "resource": "" }
q231053
TabbedDialog.add_choice
train
def add_choice(self, setting, choices): '''add a choice input line''' tab = self.panel(setting.tab) default = setting.value if default is None: default = choices[0] ctrl = wx.ComboBox(tab, -1, choices=choices, value = str(default), ...
python
{ "resource": "" }
q231054
TabbedDialog.add_intspin
train
def add_intspin(self, setting): '''add a spin control''' tab = self.panel(setting.tab) default = setting.value (minv, maxv) = setting.range ctrl = wx.SpinCtrl(tab, -1, initial = default, min = minv, ...
python
{ "resource": "" }
q231055
TabbedDialog.add_floatspin
train
def add_floatspin(self, setting): '''add a floating point spin control''' from wx.lib.agw.floatspin import FloatSpin tab = self.panel(setting.tab) default = setting.value (minv, maxv) = setting.range ctrl = FloatSpin(tab, -1, value = default, ...
python
{ "resource": "" }
q231056
RendererAgg.draw_path
train
def draw_path(self, gc, path, transform, rgbFace=None): """ Draw the path """ nmax = rcParams['agg.path.chunksize'] # here at least for testing npts = path.vertices.shape[0] if (nmax > 100 and npts > nmax and path.should_simplify and rgbFace is None and gc.get...
python
{ "resource": "" }
q231057
RendererAgg.draw_mathtext
train
def draw_mathtext(self, gc, x, y, s, prop, angle): """ Draw the math text using matplotlib.mathtext """ if __debug__: verbose.report('RendererAgg.draw_mathtext', 'debug-annoying') ox, oy, width, height, descent, font_image, used_characters = \...
python
{ "resource": "" }
q231058
RendererAgg.draw_text
train
def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): """ Render the text """ if __debug__: verbose.report('RendererAgg.draw_text', 'debug-annoying') if ismath: return self.draw_mathtext(gc, x, y, s, prop, angle) flags = get_hinting_flag()...
python
{ "resource": "" }
q231059
RendererAgg._get_agg_font
train
def _get_agg_font(self, prop): """ Get the font for text instance t, cacheing for efficiency """ if __debug__: verbose.report('RendererAgg._get_agg_font', 'debug-annoying') key = hash(prop) font = RendererAgg._fontd.get(key) ...
python
{ "resource": "" }
q231060
FigureCanvasAgg.draw
train
def draw(self): """ Draw the figure using the renderer """ if __debug__: verbose.report('FigureCanvasAgg.draw', 'debug-annoying') self.renderer = self.get_renderer(cleared=True) # acquire a lock on the shared font cache RendererAgg.lock.acquire() try: ...
python
{ "resource": "" }
q231061
ConsoleModule.vehicle_type_string
train
def vehicle_type_string(self, hb): '''return vehicle type string from a heartbeat''' if hb.type == mavutil.mavlink.MAV_TYPE_FIXED_WING: return 'Plane' if hb.type == mavutil.mavlink.MAV_TYPE_GROUND_ROVER: return 'Rover' if hb.type == mavutil.mavlink.MAV_TYPE_SURFAC...
python
{ "resource": "" }
q231062
ConsoleModule.update_vehicle_menu
train
def update_vehicle_menu(self): '''update menu for new vehicles''' self.vehicle_menu.items = [] for s in sorted(self.vehicle_list): clist = self.module('param').get_component_id_list(s) if len(clist) == 1: name = 'SysID %u: %s' % (s, self.vehicle_name_by_sy...
python
{ "resource": "" }
q231063
ConsoleModule.add_new_vehicle
train
def add_new_vehicle(self, hb): '''add a new vehicle''' if hb.type == mavutil.mavlink.MAV_TYPE_GCS: return sysid = hb.get_srcSystem() self.vehicle_list.append(sysid) self.vehicle_name_by_sysid[sysid] = self.vehicle_type_string(hb) self.update_vehicle_menu()
python
{ "resource": "" }
q231064
SpeechModule.say_espeak
train
def say_espeak(self, text, priority='important'): '''speak some text using espeak''' from espeak import espeak if self.settings.speech_voice: espeak.set_voice(self.settings.speech_voice) espeak.synth(text)
python
{ "resource": "" }
q231065
CmdlongModule.cmd_long
train
def cmd_long(self, args): '''execute supplied command long''' if len(args) < 1: print("Usage: long <command> [arg1] [arg2]...") return command = None if args[0].isdigit(): command = int(args[0]) else: try: command = ...
python
{ "resource": "" }
q231066
CmdlongModule.cmd_command_int
train
def cmd_command_int(self, args): '''execute supplied command_int''' if len(args) != 11: print("num args{0}".format(len(args))) print("Usage: command_int frame command current autocontinue param1 param2 param3 param4 x y z") print("e.g. command_int GLOBAL_RELATIVE_ALT ...
python
{ "resource": "" }
q231067
SensorsModule.cmd_sensors
train
def cmd_sensors(self, args): '''show key sensors''' gps_heading = self.status.msgs['GPS_RAW_INT'].cog * 0.01 self.console.writeln("heading: %u/%u alt: %u/%u r/p: %u/%u speed: %u/%u thr: %u" % ( self.status.msgs['VFR_HUD'].heading, gps_heading, self.status...
python
{ "resource": "" }
q231068
cmd_reverse_lookup
train
def cmd_reverse_lookup(command_name): '''returns 0 if key not found''' for key, value in miss_cmds.items(): if (value.upper() == command_name.upper()): return key return 0
python
{ "resource": "" }
q231069
make_column_label
train
def make_column_label(command_name, description, default): '''try to work out a reasonable column name from parameter description''' for (pattern, label) in description_map: if fnmatch.fnmatch(description, pattern): return label return default
python
{ "resource": "" }
q231070
get_column_labels
train
def get_column_labels(command_name): '''return dictionary of column labels if available''' cmd = cmd_reverse_lookup(command_name) if cmd == 0: return {} labels = {} enum = mavutil.mavlink.enums['MAV_CMD'][cmd] for col in enum.param.keys(): labels[col] = make_column_label(command_...
python
{ "resource": "" }
q231071
TrackerModule.find_connection
train
def find_connection(self): '''find an antenna tracker connection if possible''' if self.connection is not None: return self.connection for m in self.mpstate.mav_master: if 'HEARTBEAT' in m.messages: if m.messages['HEARTBEAT'].type == mavutil.mavlink.MAV_TY...
python
{ "resource": "" }
q231072
TrackerModule.cmd_tracker
train
def cmd_tracker(self, args): '''tracker command parser''' usage = "usage: tracker <start|set|arm|disarm|level|param|mode|position> [options]" if len(args) == 0: print(usage) return if args[0] == "start": self.cmd_tracker_start() elif args[0] ==...
python
{ "resource": "" }
q231073
TrackerModule.cmd_tracker_position
train
def cmd_tracker_position(self, args): '''tracker manual positioning commands''' connection = self.find_connection() if not connection: print("No antenna tracker found") return positions = [0, 0, 0, 0, 0] # x, y, z, r, buttons. only position[0] (yaw) and position[1...
python
{ "resource": "" }
q231074
TrackerModule.cmd_tracker_calpress
train
def cmd_tracker_calpress(self, args): '''calibrate barometer on tracker''' connection = self.find_connection() if not connection: print("No antenna tracker found") return connection.calibrate_pressure()
python
{ "resource": "" }
q231075
TrackerModule.mavlink_packet
train
def mavlink_packet(self, m): '''handle an incoming mavlink packet from the master vehicle. Relay it to the tracker if it is a GLOBAL_POSITION_INT''' if m.get_type() in ['GLOBAL_POSITION_INT', 'SCALED_PRESSURE']: connection = self.find_connection() if not connection: ...
python
{ "resource": "" }
q231076
GraphModule.cmd_legend
train
def cmd_legend(self, args): '''setup legend for graphs''' if len(args) == 0: for leg in self.legend.keys(): print("%s -> %s" % (leg, self.legend[leg])) elif len(args) == 1: leg = args[0] if leg in self.legend: print("Removing le...
python
{ "resource": "" }
q231077
GimbalModule.cmd_gimbal_mode
train
def cmd_gimbal_mode(self, args): '''control gimbal mode''' if len(args) != 1: print("usage: gimbal mode <GPS|MAVLink>") return if args[0].upper() == 'GPS': mode = mavutil.mavlink.MAV_MOUNT_MODE_GPS_POINT elif args[0].upper() == 'MAVLINK': m...
python
{ "resource": "" }
q231078
GimbalModule.cmd_gimbal_roi
train
def cmd_gimbal_roi(self, args): '''control roi position''' latlon = None try: latlon = self.module('map').click_position except Exception: print("No map available") return if latlon is None: print("No map click position available") ...
python
{ "resource": "" }
q231079
GimbalModule.cmd_gimbal_roi_vel
train
def cmd_gimbal_roi_vel(self, args): '''control roi position and velocity''' if len(args) != 0 and len(args) != 3 and len(args) != 6: print("usage: gimbal roivel [VEL_NORTH VEL_EAST VEL_DOWN] [ACC_NORTH ACC_EASY ACC_DOWN]") return latlon = None vel = [0,0,0] ...
python
{ "resource": "" }
q231080
GimbalModule.cmd_gimbal_rate
train
def cmd_gimbal_rate(self, args): '''control gimbal rate''' if len(args) != 3: print("usage: gimbal rate ROLL PITCH YAW") return (roll, pitch, yaw) = (float(args[0]), float(args[1]), float(args[2])) self.master.mav.gimbal_control_send(self.target_system, ...
python
{ "resource": "" }
q231081
GimbalModule.cmd_gimbal_point
train
def cmd_gimbal_point(self, args): '''control gimbal pointing''' if len(args) != 3: print("usage: gimbal point ROLL PITCH YAW") return (roll, pitch, yaw) = (float(args[0]), float(args[1]), float(args[2])) self.master.mav.mount_control_send(self.target_system, ...
python
{ "resource": "" }
q231082
GimbalModule.cmd_gimbal_status
train
def cmd_gimbal_status(self, args): '''show gimbal status''' master = self.master if 'GIMBAL_REPORT' in master.messages: print(master.messages['GIMBAL_REPORT']) else: print("No GIMBAL_REPORT messages")
python
{ "resource": "" }
q231083
SlipFlightModeLegend.draw
train
def draw(self, img, pixmapper, bounds): '''draw legend on the image''' if self._img is None: self._img = self.draw_legend() w = self._img.shape[1] h = self._img.shape[0] px = 5 py = 5 img[py:py+h,px:px+w] = self._img
python
{ "resource": "" }
q231084
SlipThumbnail.draw
train
def draw(self, img, pixmapper, bounds): '''draw the thumbnail on the image''' if self.hidden: return thumb = self.img() (px,py) = pixmapper(self.latlon) # find top left (w, h) = image_shape(thumb) px -= w//2 py -= h//2 (px, py, sx, sy...
python
{ "resource": "" }
q231085
TerrainModule.cmd_terrain
train
def cmd_terrain(self, args): '''terrain command parser''' usage = "usage: terrain <set|status|check>" if len(args) == 0: print(usage) return if args[0] == "status": print("blocks_sent: %u requests_received: %u" % ( self.blocks_sent, ...
python
{ "resource": "" }
q231086
TerrainModule.cmd_terrain_check
train
def cmd_terrain_check(self, args): '''check a piece of terrain data''' if len(args) >= 2: latlon = (float(args[0]), float(args[1])) else: try: latlon = self.module('map').click_position except Exception: print("No map available"...
python
{ "resource": "" }
q231087
TerrainModule.idle_task
train
def idle_task(self): '''called when idle''' if self.current_request is None: return if time.time() - self.last_send_time < 0.2: # limit to 5 per second return self.send_terrain_data()
python
{ "resource": "" }
q231088
ModeModule.unknown_command
train
def unknown_command(self, args): '''handle mode switch by mode name as command''' mode_mapping = self.master.mode_mapping() mode = args[0].upper() if mode in mode_mapping: self.master.set_mode(mode_mapping[mode]) return True return False
python
{ "resource": "" }
q231089
ModeModule.cmd_guided
train
def cmd_guided(self, args): '''set GUIDED target''' if len(args) != 1 and len(args) != 3: print("Usage: guided ALTITUDE | guided LAT LON ALTITUDE") return if len(args) == 3: latitude = float(args[0]) longitude = float(args[1]) altitude...
python
{ "resource": "" }
q231090
HILModule.check_sim_in
train
def check_sim_in(self): '''check for FDM packets from runsim''' try: pkt = self.sim_in.recv(17*8 + 4) except socket.error as e: if not e.errno in [ errno.EAGAIN, errno.EWOULDBLOCK ]: raise return if len(pkt) != 17*8 + 4: # w...
python
{ "resource": "" }
q231091
HILModule.check_sim_out
train
def check_sim_out(self): '''check if we should send new servos to flightgear''' now = time.time() if now - self.last_sim_send_time < 0.02 or self.rc_channels_scaled is None: return self.last_sim_send_time = now servos = [] for ch in range(1,9): se...
python
{ "resource": "" }
q231092
HILModule.check_apm_out
train
def check_apm_out(self): '''check if we should send new data to the APM''' now = time.time() if now - self.last_apm_send_time < 0.02: return self.last_apm_send_time = now if self.hil_state_msg is not None: self.master.mav.send(self.hil_state_msg)
python
{ "resource": "" }
q231093
HILModule.convert_body_frame
train
def convert_body_frame(self, phi, theta, phiDot, thetaDot, psiDot): '''convert a set of roll rates from earth frame to body frame''' p = phiDot - psiDot*math.sin(theta) q = math.cos(phi)*thetaDot + math.sin(phi)*psiDot*math.cos(theta) r = math.cos(phi)*psiDot*math.cos(theta) - math.sin(p...
python
{ "resource": "" }
q231094
MPSettings.append
train
def append(self, v): '''add a new setting''' if isinstance(v, MPSetting): setting = v else: (name,type,default) = v label = name tab = None if len(v) > 3: label = v[3] if len(v) > 4: tab = v[4...
python
{ "resource": "" }
q231095
MPSettings.get
train
def get(self, name): '''get a setting''' if not name in self._vars: raise AttributeError setting = self._vars[name] return setting.value
python
{ "resource": "" }
q231096
MPSettings.command
train
def command(self, args): '''control options from cmdline''' if len(args) == 0: self.show_all() return if getattr(self, args[0], [None]) == [None]: print("Unknown setting '%s'" % args[0]) return if len(args) == 1: self.show(args[...
python
{ "resource": "" }
q231097
ArmModule.all_checks_enabled
train
def all_checks_enabled(self): ''' returns true if the UAV is skipping any arming checks''' arming_mask = int(self.get_mav_param("ARMING_CHECK",0)) if arming_mask == 1: return True for bit in arming_masks.values(): if not arming_mask & bit and bit != 1: ...
python
{ "resource": "" }
q231098
ParamState.handle_px4_param_value
train
def handle_px4_param_value(self, m): '''special handling for the px4 style of PARAM_VALUE''' if m.param_type == mavutil.mavlink.MAV_PARAM_TYPE_REAL32: # already right type return m.param_value is_px4_params = False if m.get_srcComponent() in [mavutil.mavlink.MAV_C...
python
{ "resource": "" }
q231099
ParamState.param_help_download
train
def param_help_download(self): '''download XML files for parameters''' files = [] for vehicle in ['APMrover2', 'ArduCopter', 'ArduPlane', 'ArduSub', 'AntennaTracker']: url = 'http://autotest.ardupilot.org/Parameters/%s/apm.pdef.xml' % vehicle path = mp_util.dot_mavproxy("...
python
{ "resource": "" }