idx int64 0 252k | question stringlengths 48 5.28k | target stringlengths 5 1.23k |
|---|---|---|
230,500 | def getActiveAxes ( self ) : active = [ ] for i in range ( len ( self . _axisId ) ) : if self . _menu . IsChecked ( self . _axisId [ i ] ) : active . append ( i ) return active | Return a list of the selected axes . |
230,501 | def updateButtonText ( self , lst ) : axis_txt = '' for e in lst : axis_txt += '%d,' % ( e + 1 ) self . SetLabel ( "Axes: %s" % axis_txt [ : - 1 ] ) | Update the list of selected axes in the menu button |
230,502 | def _create_menu ( self ) : DEBUG_MSG ( "_create_menu()" , 1 , self ) self . _menu = MenuButtonWx ( self ) self . AddControl ( self . _menu ) self . AddSeparator ( ) | Creates the menu - implemented as a button which opens a pop - up menu since wxPython does not allow a menu as a control |
230,503 | def _create_controls ( self , can_kill ) : DEBUG_MSG ( "_create_controls()" , 1 , self ) self . SetToolBitmapSize ( wx . Size ( 16 , 16 ) ) self . AddSimpleTool ( _NTB_X_PAN_LEFT , _load_bitmap ( 'stock_left.xpm' ) , 'Left' , 'Scroll left' ) self . AddSimpleTool ( _NTB_X_PAN_RIGHT , _load_bitmap ( 'stock_right.xpm' ) ,... | Creates the button controls and links them to event handlers |
230,504 | def set_active ( self , ind ) : DEBUG_MSG ( "set_active()" , 1 , self ) self . _ind = ind if ind != None : self . _active = [ self . _axes [ i ] for i in self . _ind ] else : self . _active = [ ] self . _menu . updateButtonText ( ind ) | ind is a list of index numbers for the axes which are to be made active |
230,505 | def getURIWithRedirect ( self , url ) : tries = 0 while tries < 5 : conn = httplib . HTTPConnection ( self . server ) conn . request ( "GET" , url ) r1 = conn . getresponse ( ) if r1 . status in [ 301 , 302 , 303 , 307 ] : location = r1 . getheader ( 'Location' ) if self . debug : print ( "redirect from %s to %s" % ( u... | fetch a URL with redirect handling |
230,506 | def cmd_rc ( self , args ) : if len ( args ) != 2 : print ( "Usage: rc <channel|all> <pwmvalue>" ) return value = int ( args [ 1 ] ) if value > 65535 or value < - 1 : raise ValueError ( "PWM value must be a positive integer between 0 and 65535" ) if value == - 1 : value = 65535 channels = self . override if args [ 0 ] ... | handle RC value override |
230,507 | def complete_variable ( text ) : if text == '' : return list ( rline_mpstate . status . msgs . keys ( ) ) if text . endswith ( ":2" ) : suffix = ":2" text = text [ : - 2 ] else : suffix = '' try : if mavutil . evaluate_expression ( text , rline_mpstate . status . msgs ) is not None : return [ text + suffix ] except Exc... | complete a MAVLink variable or expression |
230,508 | def complete_rule ( rule , cmd ) : global rline_mpstate rule_components = rule . split ( ' ' ) if len ( cmd ) == 0 : return rule_expand ( rule_components [ 0 ] , "" ) for i in range ( len ( cmd ) - 1 ) : if not rule_match ( rule_components [ i ] , cmd [ i ] ) : return [ ] expanded = rule_expand ( rule_components [ len ... | complete using one rule |
230,509 | def createPlotPanel ( self ) : self . figure = Figure ( ) self . axes = self . figure . add_subplot ( 111 ) self . canvas = FigureCanvas ( self , - 1 , self . figure ) self . canvas . SetSize ( wx . Size ( 300 , 300 ) ) self . axes . axis ( 'off' ) self . figure . subplots_adjust ( left = 0 , right = 1 , top = 1 , bott... | Creates the figure and axes for the plotting panel . |
230,510 | def rescaleX ( self ) : self . ratio = self . figure . get_size_inches ( ) [ 0 ] / float ( self . figure . get_size_inches ( ) [ 1 ] ) self . axes . set_xlim ( - self . ratio , self . ratio ) self . axes . set_ylim ( - 1 , 1 ) | Rescales the horizontal axes to make the lengthscales equal . |
230,511 | def calcFontScaling ( self ) : self . ypx = self . figure . get_size_inches ( ) [ 1 ] * self . figure . dpi self . xpx = self . figure . get_size_inches ( ) [ 0 ] * self . figure . dpi self . fontSize = self . vertSize * ( self . ypx / 2.0 ) self . leftPos = self . axes . get_xlim ( ) [ 0 ] self . rightPos = self . axe... | Calculates the current font size and left position for the current window . |
230,512 | def checkReszie ( self ) : if not self . resized : oldypx = self . ypx oldxpx = self . xpx self . ypx = self . figure . get_size_inches ( ) [ 1 ] * self . figure . dpi self . xpx = self . figure . get_size_inches ( ) [ 0 ] * self . figure . dpi if ( oldypx != self . ypx ) or ( oldxpx != self . xpx ) : self . resized = ... | Checks if the window was resized . |
230,513 | def createHeadingPointer ( self ) : self . headingTri = patches . RegularPolygon ( ( 0.0 , 0.80 ) , 3 , 0.05 , color = 'k' , zorder = 4 ) self . axes . add_patch ( self . headingTri ) self . headingText = self . axes . text ( 0.0 , 0.675 , '0' , color = 'k' , size = self . fontSize , horizontalalignment = 'center' , ve... | Creates the pointer for the current heading . |
230,514 | def adjustHeadingPointer ( self ) : self . headingText . set_text ( str ( self . heading ) ) self . headingText . set_size ( self . fontSize ) | Adjust the value of the heading pointer . |
230,515 | def createNorthPointer ( self ) : 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 = self . fontSize , horizontalalignment = ... | Creates the north pointer relative to current heading . |
230,516 | def adjustNorthPointer ( self ) : 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 ( headingRotate ) if ( self . heading > 90 ) and ( self . heading ... | Adjust the position and orientation of the north pointer . |
230,517 | def createRPYText ( self ) : 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 . vertSi... | Creates the text for roll pitch and yaw . |
230,518 | def updateRPYLocations ( self ) : 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 - ( 0.5 * self . vertSize / 10.0... | Update the locations of roll pitch yaw text . |
230,519 | 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 ) | Updates the displayed Roll Pitch Yaw Text |
230,520 | def createCenterPointMarker ( self ) : 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 = 'orange' , zorder = 3 )... | Creates the center pointer in the middle of the screen . |
230,521 | def createHorizonPolygons ( self ) : 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 ) vertsBot = [ [ - 1 , 0 ] , [ - 1 , - 1 ] , [ 1 , - 1 ] , [ 1 , 0 ] , ... | Creates the two polygons to show the sky and ground . |
230,522 | def calcHorizonPoints ( self ) : ydiff = math . tan ( math . radians ( - self . roll ) ) * float ( self . ratio ) pitchdiff = self . dist10deg * ( self . pitch / 10.0 ) vertsTop = [ ( - self . ratio , ydiff - pitchdiff ) , ( - self . ratio , 1 ) , ( self . ratio , 1 ) , ( self . ratio , - ydiff - pitchdiff ) , ( - self... | Updates the verticies of the patches for the ground and sky . |
230,523 | def createPitchMarkers ( self ) : self . pitchPatches = [ ] 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 = patches . Rectangle ( ( - width / 2.0 , self . dist10deg * i - ( self . thick / 2.0 ) ) , width , s... | Creates the rectangle patches for the pitch indicators . |
230,524 | def adjustPitchmarkers ( self ) : 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 , 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8... | Adjusts the location and orientation of pitch markers . |
230,525 | def createAARText ( self ) : 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 = self . axes . text ( sel... | Creates the text for airspeed altitude and climb rate . |
230,526 | def updateAARLocations ( self ) : 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 ) , - 0.97 + self . vertSize - ( 0.5 * self . vertSi... | Update the locations of airspeed altitude and Climb rate . |
230,527 | 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 ) | Updates the displayed airspeed altitude climb rate Text |
230,528 | def createBatteryBar ( self ) : 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 . batInRec = patches .... | Creates the bar to display current battery percentage . |
230,529 | def updateBatteryBar ( self ) : 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.075 ) * self . batH... | Updates the position and values of the battery bar . |
230,530 | def createStateText ( self ) : 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 , foregro... | Creates the mode and arm state text . |
230,531 | def updateStateText ( self ) : 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 . modeText . set_color ( 'red' ) self . modeText . set_path_effects ( [ PathEffe... | Updates the mode and colours red or green depending on arm state . |
230,532 | def createWPText ( self ) : 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' , va = 'top' ) self . wpText . set_path_effects ( [ PathEffect... | Creates the text for the current and final waypoint and the distance to the new waypoint . |
230,533 | def updateWPText ( self ) : 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 . set_text ( '%.f/%.f\n(%.f m, ~ s)' ... | Updates the current waypoint and distance to it . |
230,534 | def createWPPointer ( self ) : 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' , size = self . fontSize , horizontalalig... | Creates the waypoint pointer relative to current heading . |
230,535 | def adjustWPPointer ( self ) : 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_transform ( headingRotate ) angle = self . wpBearing - self . he... | Adjust the position and orientation of the waypoint pointer . |
230,536 | def createAltHistoryPlot ( self ) : 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 . leftP... | Creates the altitude history plot . |
230,537 | def updateAltHistory ( self ) : self . altHist . append ( self . relAlt ) self . timeHist . append ( self . relAltTime ) histLim = 10 currentTime = time . time ( ) point = 0 for i in range ( 0 , len ( self . timeHist ) ) : if ( self . timeHist [ i ] > ( currentTime - 10.0 ) ) : break self . altHist = self . altHist [ i... | Updates the altitude history plot . |
230,538 | def on_idle ( self , event ) : self . checkReszie ( ) if self . resized : self . rescaleX ( ) self . calcFontScaling ( ) self . calcHorizonPoints ( ) self . updateRPYLocations ( ) self . updateAARLocations ( ) self . adjustPitchmarkers ( ) self . adjustHeadingPointer ( ) self . adjustNorthPointer ( ) self . updateBatte... | To adjust text and positions on rescaling the window when resized . |
230,539 | def on_timer ( self , event ) : state = self . state self . loopStartTime = time . time ( ) if state . close_event . wait ( 0.001 ) : self . timer . Stop ( ) self . Destroy ( ) return self . checkReszie ( ) if self . resized : self . on_idle ( 0 ) while state . child_pipe_recv . poll ( ) : objList = state . child_pipe_... | Main Loop . |
230,540 | def on_KeyPress ( self , event ) : 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 if self . dist10deg <= 0 : self . dist10deg = 0.1 print ( 'Dist per 10 deg: %.1f' % self . dis... | To adjust the distance between pitch markers . |
230,541 | def fenceloader ( self ) : 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 ] | fence loader by sysid |
230,542 | def mavlink_packet ( self , m ) : 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_GEOFENCE present = ( ( m . onboard_control_sensors_present & bits ) == b... | handle and incoming mavlink packet |
230,543 | def load_fence ( self , filename ) : try : self . fenceloader . target_system = self . target_system self . fenceloader . target_component = self . target_component self . fenceloader . load ( filename . strip ( '"' ) ) except Exception as msg : print ( "Unable to load %s - %s" % ( filename , msg ) ) return print ( "Lo... | load fence points from a file |
230,544 | def list_fence ( self , filename ) : 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 . fetch_fence_point ( i ) if p is None : return self . fenceloader . add ( p ) if filename is not None... | list fence points optionally saving to a file |
230,545 | def poll ( self ) : 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 : return None evt = self . out_queue . get ( ) return evt | check for events returning one event |
230,546 | def find_object ( self , key , layers ) : 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 ] return None | find an object to be modified |
230,547 | def add_object ( self , obj ) : state = self . state if not obj . layer in state . layers : state . layers [ obj . layer ] = { } state . layers [ obj . layer ] [ obj . key ] = obj state . need_redraw = True if ( not self . legend_checkbox_menuitem_added and isinstance ( obj , SlipFlightModeLegend ) ) : self . add_legen... | add an object to a layer |
230,548 | def set_ground_width ( self , ground_width ) : state = self . state state . ground_width = ground_width state . panel . re_center ( state . width / 2 , state . height / 2 , state . lat , state . lon ) | set ground width of view |
230,549 | def show_popup ( self , selected , pos ) : 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 : popup_menu = copy . deepcopy ( popup_menu ) popup_menu . add ( MPMenuSeparator ( ) ) popup_menu... | show popup menu for an object |
230,550 | def cmd_watch ( args ) : if len ( args ) == 0 : mpstate . status . watch = None return mpstate . status . watch = args print ( "Watching %s" % mpstate . status . watch ) | watch a mavlink packet pattern |
230,551 | def load_module ( modname , quiet = False , ** kwargs ) : 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" % modname ) return True ex = None for m... | load a module |
230,552 | def process_mavlink ( slave ) : 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 = slave . mav . parse_buffer ( buf ) except mavutil . mavlink . MAVError as e : mpstate . console . error ( "Bad MA... | process packets from MAVLink slaves forwarding to the master |
230,553 | def log_writer ( ) : 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 ( ) ) while not mpstate . logqueue .... | log writing thread |
230,554 | def main_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 ) send_heartbeat ( master ) master . wait_heartbeat ( timeout = 0.1 ) set_stream_rat... | main processing loop |
230,555 | def set_mav_version ( mav10 , mav20 , autoProtocol , mavversionArg ) : if ( mav10 == True or mav20 == True ) and autoProtocol == True : print ( "Error: Can't have [--mav10, --mav20] and --auto-protocol both True" ) sys . exit ( 1 ) if mav10 == True and mav20 == True : print ( "Error: Can't have --mav10 and --mav20 both... | Set the Mavlink version based on commandline options |
230,556 | def mav_param ( self ) : 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_sysid [ sysid ] = mavparm . MAVParmDict ( ) return self . mav_param_by_sysid [ sysid ] | map mav_param onto the current target system parameters |
230,557 | def get_wx_window_layout ( wx_window ) : dsize = wx . DisplaySize ( ) pos = wx_window . GetPosition ( ) size = wx_window . GetSize ( ) name = wx_window . GetTitle ( ) return WinLayout ( name , pos , size , dsize ) | get a WinLayout for a wx window |
230,558 | def set_wx_window_layout ( wx_window , layout ) : try : wx_window . SetSize ( layout . size ) wx_window . SetPosition ( layout . pos ) except Exception as ex : print ( ex ) | set a WinLayout for a wx window |
230,559 | def set_layout ( wlayout , callback ) : global display_size global window_list global loaded_layout global pending_load global vehiclename if not wlayout . name in window_list and loaded_layout is not None and wlayout . name in loaded_layout : callback ( loaded_layout [ wlayout . name ] ) window_list [ wlayout . name ]... | set window layout |
230,560 | def layout_filename ( fallback ) : 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 ( dirname ) except Exception : pass elif 'LOCALAPPDATA' in os . e... | get location of layout file |
230,561 | def save_layout ( vehname ) : 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 layout to" ) return layout = { } try : layout = pickle . load ( open... | save window layout |
230,562 | def load_layout ( vehname ) : 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 is None : print ( "No file to load layout from" ) return try : layout = pi... | load window layout |
230,563 | def on_apply ( self , event ) : 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 if not setting . set ( value ) : print ( "Invalid value %s for %s" % (... | called on apply |
230,564 | def on_save ( self , event ) : 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 ( ) ) | called on save button |
230,565 | def on_load ( self , event ) : dlg = wx . FileDialog ( None , self . settings . get_title ( ) , '' , "" , '*.*' , wx . FD_OPEN ) if dlg . ShowModal ( ) == wx . ID_OK : self . settings . load ( dlg . GetPath ( ) ) for label in self . setting_map . keys ( ) : setting = self . setting_map [ label ] ctrl = self . controls ... | called on load button |
230,566 | def add_text ( self , setting , width = 300 , height = 100 , multiline = False ) : 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 ( tab , - 1 , "" , size = ( width , -... | add a text input line |
230,567 | def add_choice ( self , setting , choices ) : 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 ) , style = wx . CB_DROPDOWN | wx . CB_READONLY | wx . CB_SORT ) self . _add_input ( sett... | add a choice input line |
230,568 | def add_intspin ( self , setting ) : tab = self . panel ( setting . tab ) default = setting . value ( minv , maxv ) = setting . range ctrl = wx . SpinCtrl ( tab , - 1 , initial = default , min = minv , max = maxv ) self . _add_input ( setting , ctrl , value = default ) | add a spin control |
230,569 | def add_floatspin ( self , setting ) : 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 , min_val = minv , max_val = maxv , increment = setting . increment ) if setting . forma... | add a floating point spin control |
230,570 | def draw_path ( self , gc , path , transform , rgbFace = None ) : nmax = rcParams [ 'agg.path.chunksize' ] npts = path . vertices . shape [ 0 ] if ( nmax > 100 and npts > nmax and path . should_simplify and rgbFace is None and gc . get_hatch ( ) is None ) : nch = np . ceil ( npts / float ( nmax ) ) chsize = int ( np . ... | Draw the path |
230,571 | def draw_mathtext ( self , gc , x , y , s , prop , angle ) : if __debug__ : verbose . report ( 'RendererAgg.draw_mathtext' , 'debug-annoying' ) ox , oy , width , height , descent , font_image , used_characters = self . mathtext_parser . parse ( s , self . dpi , prop ) xd = descent * np . sin ( np . deg2rad ( angle ) ) ... | Draw the math text using matplotlib . mathtext |
230,572 | def draw_text ( self , gc , x , y , s , prop , angle , ismath = False , mtext = None ) : 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 ( ) font = self . _get_agg_font ( prop ) if font is N... | Render the text |
230,573 | def _get_agg_font ( self , prop ) : if __debug__ : verbose . report ( 'RendererAgg._get_agg_font' , 'debug-annoying' ) key = hash ( prop ) font = RendererAgg . _fontd . get ( key ) if font is None : fname = findfont ( prop ) font = RendererAgg . _fontd . get ( fname ) if font is None : font = FT2Font ( str ( fname ) , ... | Get the font for text instance t cacheing for efficiency |
230,574 | def draw ( self ) : if __debug__ : verbose . report ( 'FigureCanvasAgg.draw' , 'debug-annoying' ) self . renderer = self . get_renderer ( cleared = True ) RendererAgg . lock . acquire ( ) try : self . figure . draw ( self . renderer ) finally : RendererAgg . lock . release ( ) | Draw the figure using the renderer |
230,575 | def vehicle_type_string ( self , hb ) : 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_SURFACE_BOAT : return 'Boat' if hb . type == mavutil . mavlink . MAV_TYPE_SUBMARINE : r... | return vehicle type string from a heartbeat |
230,576 | def update_vehicle_menu ( self ) : 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_sysid [ s ] ) self . vehicle_menu . items . append ( MPMenuItem ( na... | update menu for new vehicles |
230,577 | def add_new_vehicle ( self , hb ) : 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 ( ) | add a new vehicle |
230,578 | def say_espeak ( self , text , priority = 'important' ) : from espeak import espeak if self . settings . speech_voice : espeak . set_voice ( self . settings . speech_voice ) espeak . synth ( text ) | speak some text using espeak |
230,579 | def cmd_long ( self , args ) : if len ( args ) < 1 : print ( "Usage: long <command> [arg1] [arg2]..." ) return command = None if args [ 0 ] . isdigit ( ) : command = int ( args [ 0 ] ) else : try : command = eval ( "mavutil.mavlink." + args [ 0 ] ) except AttributeError as e : try : command = eval ( "mavutil.mavlink.MA... | execute supplied command long |
230,580 | def cmd_command_int ( self , args ) : 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 DO_SET_HOME 0 0 0 0 0 0 -353632120 1491659330 0" ) print ( "e.... | execute supplied command_int |
230,581 | def cmd_sensors ( self , args ) : 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 . altitude , self . gps_alt , math . degrees ( sel... | show key sensors |
230,582 | def cmd_reverse_lookup ( command_name ) : for key , value in miss_cmds . items ( ) : if ( value . upper ( ) == command_name . upper ( ) ) : return key return 0 | returns 0 if key not found |
230,583 | def make_column_label ( command_name , description , default ) : for ( pattern , label ) in description_map : if fnmatch . fnmatch ( description , pattern ) : return label return default | try to work out a reasonable column name from parameter description |
230,584 | def get_column_labels ( command_name ) : 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_name , enum . param [ col ] , "P%u" % col ) return labels | return dictionary of column labels if available |
230,585 | def find_connection ( self ) : 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_TYPE_ANTENNA_TRACKER : return m return None | find an antenna tracker connection if possible |
230,586 | def cmd_tracker ( self , args ) : 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 ] == "set" : self . tracker_settings . command ( args [ 1 : ] ) elif args [ 0 ] == 'ar... | tracker command parser |
230,587 | def cmd_tracker_position ( self , args ) : connection = self . find_connection ( ) if not connection : print ( "No antenna tracker found" ) return positions = [ 0 , 0 , 0 , 0 , 0 ] for i in range ( 0 , 4 ) : if len ( args ) > i : positions [ i ] = int ( args [ i ] ) connection . mav . manual_control_send ( connection .... | tracker manual positioning commands |
230,588 | def cmd_tracker_calpress ( self , args ) : connection = self . find_connection ( ) if not connection : print ( "No antenna tracker found" ) return connection . calibrate_pressure ( ) | calibrate barometer on tracker |
230,589 | def mavlink_packet ( self , m ) : if m . get_type ( ) in [ 'GLOBAL_POSITION_INT' , 'SCALED_PRESSURE' ] : connection = self . find_connection ( ) if not connection : return if m . get_srcSystem ( ) != connection . target_system : connection . mav . send ( m ) | handle an incoming mavlink packet from the master vehicle . Relay it to the tracker if it is a GLOBAL_POSITION_INT |
230,590 | def cmd_legend ( self , args ) : 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 legend %s" % leg ) self . legend . pop ( leg ) elif len ( args ) >= 2 : leg = args [ ... | setup legend for graphs |
230,591 | def cmd_gimbal_mode ( self , args ) : 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' : mode = mavutil . mavlink . MAV_MOUNT_MODE_MAVLINK_TARGETING elif args [ 0 ]... | control gimbal mode |
230,592 | def cmd_gimbal_roi ( self , args ) : 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" ) return self . master . mav . mount_control_send ( self . target_system , self . target_compone... | control roi position |
230,593 | def cmd_gimbal_roi_vel ( self , args ) : 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 ] acc = [ 0 , 0 , 0 ] if ( len ( args ) >= 3 ) : vel [ 0 : 3 ] = args [ 0 : 3 ] ... | control roi position and velocity |
230,594 | def cmd_gimbal_rate ( self , args ) : 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 , mavutil . mavlink . MAV_COMP_ID_GIMBAL , ra... | control gimbal rate |
230,595 | def cmd_gimbal_point ( self , args ) : 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 , self . target_component , pitch * 100 , ro... | control gimbal pointing |
230,596 | def cmd_gimbal_status ( self , args ) : master = self . master if 'GIMBAL_REPORT' in master . messages : print ( master . messages [ 'GIMBAL_REPORT' ] ) else : print ( "No GIMBAL_REPORT messages" ) | show gimbal status |
230,597 | def draw ( self , img , pixmapper , bounds ) : 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 | draw legend on the image |
230,598 | def draw ( self , img , pixmapper , bounds ) : if self . hidden : return thumb = self . img ( ) ( px , py ) = pixmapper ( self . latlon ) ( w , h ) = image_shape ( thumb ) px -= w // 2 py -= h // 2 ( px , py , sx , sy , w , h ) = self . clip ( px , py , w , h , img ) thumb_roi = thumb [ sy : sy + h , sx : sx + w ] img ... | draw the thumbnail on the image |
230,599 | def cmd_terrain ( self , args ) : 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 , self . requests_received ) ) elif args [ 0 ] == "set" : self . terrain_settings . command ( arg... | terrain command parser |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.