idx
int64
0
251k
question
stringlengths
53
3.53k
target
stringlengths
5
1.23k
len_question
int64
20
893
len_target
int64
3
238
229,100
def volt_sensor_send ( self , r2Type , voltage , reading2 , force_mavlink1 = False ) : return self . send ( self . volt_sensor_encode ( r2Type , voltage , reading2 ) , force_mavlink1 = force_mavlink1 )
Transmits the readings from the voltage and current sensors
68
10
229,101
def ptz_status_send ( self , zoom , pan , tilt , force_mavlink1 = False ) : return self . send ( self . ptz_status_encode ( zoom , pan , tilt ) , force_mavlink1 = force_mavlink1 )
Transmits the actual Pan Tilt and Zoom values of the camera unit
62
14
229,102
def script_request_send ( self , target_system , target_component , seq , force_mavlink1 = False ) : return self . send ( self . script_request_encode ( target_system , target_component , seq ) , force_mavlink1 = force_mavlink1 )
Request script item with the sequence number seq . The response of the system to this message should be a SCRIPT_ITEM message .
68
27
229,103
def script_count_send ( self , target_system , target_component , count , force_mavlink1 = False ) : return self . send ( self . script_count_encode ( target_system , target_component , count ) , force_mavlink1 = force_mavlink1 )
This message is emitted as response to SCRIPT_REQUEST_LIST by the MAV to get the number of mission scripts .
68
26
229,104
def script_current_send ( self , seq , force_mavlink1 = False ) : return self . send ( self . script_current_encode ( seq ) , force_mavlink1 = force_mavlink1 )
This message informs about the currently active SCRIPT .
52
10
229,105
def generate ( basename , xml_list ) : for idx in range ( len ( xml_list ) ) : xml = xml_list [ idx ] xml . xml_idx = idx generate_one ( basename , xml ) copy_fixed_headers ( basename , xml_list [ 0 ] )
generate complete MAVLink C implemenation
68
11
229,106
def update ( self ) : pos = Pose3d ( ) if self . hasproxy ( ) : pose = self . proxy . getPose3DData ( ) pos . yaw = self . quat2Yaw ( pose . q0 , pose . q1 , pose . q2 , pose . q3 ) pos . pitch = self . quat2Pitch ( pose . q0 , pose . q1 , pose . q2 , pose . q3 ) pos . roll = self . quat2Roll ( pose . q0 , pose . q1 , pose . q2 , pose . q3 ) pos . x = pose . x pos . y = pose . y pos . z = pose . z pos . h = pose . h pos . q = [ pose . q0 , pose . q1 , pose . q2 , pose . q3 ] self . lock . acquire ( ) self . pose = pos self . lock . release ( )
Updates Pose3d .
203
6
229,107
def getPose3d ( self ) : self . lock . acquire ( ) pose = self . pose self . lock . release ( ) return pose
Returns last Pose3d .
31
6
229,108
def quat2Roll ( self , qw , qx , qy , qz ) : rotateXa0 = 2.0 * ( qy * qz + qw * qx ) rotateXa1 = qw * qw - qx * qx - qy * qy + qz * qz rotateX = 0.0 if ( rotateXa0 != 0.0 and rotateXa1 != 0.0 ) : rotateX = atan2 ( rotateXa0 , rotateXa1 ) return rotateX
Translates from Quaternion to Roll .
118
10
229,109
def kill_speech_dispatcher ( self ) : if not 'HOME' in os . environ : return pidpath = os . path . join ( os . environ [ 'HOME' ] , '.speech-dispatcher' , 'pid' , 'speech-dispatcher.pid' ) if os . path . exists ( pidpath ) : try : import signal pid = int ( open ( pidpath ) . read ( ) ) if pid > 1 and os . kill ( pid , 0 ) is None : print ( "Killing speech dispatcher pid %u" % pid ) os . kill ( pid , signal . SIGINT ) time . sleep ( 1 ) except Exception as e : pass
kill speech dispatcher processs
147
5
229,110
def loadFileList ( self ) : try : data = open ( self . filelist_file , 'rb' ) except IOError : '''print "No SRTM cached file list. Creating new one!"''' if self . offline == 0 : self . createFileList ( ) return try : self . filelist = pickle . load ( data ) data . close ( ) if len ( self . filelist ) < self . min_filelist_len : self . filelist = { } if self . offline == 0 : self . createFileList ( ) except : '''print "Unknown error loading cached SRTM file list. Creating new one!"''' if self . offline == 0 : self . createFileList ( )
Load a previously created file list or create a new one if none is available .
156
16
229,111
def _avg ( value1 , value2 , weight ) : if value1 is None : return value2 if value2 is None : return value1 return value2 * weight + value1 * ( 1 - weight )
Returns the weighted average of two values and handles the case where one value is None . If both values are None None is returned .
46
26
229,112
def calcOffset ( self , x , y ) : # Datalayout # X = longitude # Y = latitude # Sample for size 1201x1201 # ( 0/1200) ( 1/1200) ... (1199/1200) (1200/1200) # ( 0/1199) ( 1/1199) ... (1199/1199) (1200/1199) # ... ... ... ... # ( 0/ 1) ( 1/ 1) ... (1199/ 1) (1200/ 1) # ( 0/ 0) ( 1/ 0) ... (1199/ 0) (1200/ 0) # Some offsets: # (0/1200) 0 # (1200/1200) 1200 # (0/1199) 1201 # (1200/1199) 2401 # (0/0) 1201*1200 # (1200/0) 1201*1201-1 return x + self . size * ( self . size - y - 1 )
Calculate offset into data array . Only uses to test correctness of the formula .
210
17
229,113
def getPixelValue ( self , x , y ) : assert x < self . size , "x: %d<%d" % ( x , self . size ) assert y < self . size , "y: %d<%d" % ( y , self . size ) # Same as calcOffset, inlined for performance reasons offset = x + self . size * ( self . size - y - 1 ) #print offset value = self . data [ offset ] if value == - 32768 : return - 1 # -32768 is a special value for areas with no data return value
Get the value of a pixel from the data handling voids in the SRTM data .
124
19
229,114
def getAltitudeFromLatLon ( self , lat , lon ) : # print "-----\nFromLatLon", lon, lat lat -= self . lat lon -= self . lon # print "lon, lat", lon, lat if lat < 0.0 or lat >= 1.0 or lon < 0.0 or lon >= 1.0 : raise WrongTileError ( self . lat , self . lon , self . lat + lat , self . lon + lon ) x = lon * ( self . size - 1 ) y = lat * ( self . size - 1 ) # print "x,y", x, y x_int = int ( x ) x_frac = x - int ( x ) y_int = int ( y ) y_frac = y - int ( y ) # print "frac", x_int, x_frac, y_int, y_frac value00 = self . getPixelValue ( x_int , y_int ) value10 = self . getPixelValue ( x_int + 1 , y_int ) value01 = self . getPixelValue ( x_int , y_int + 1 ) value11 = self . getPixelValue ( x_int + 1 , y_int + 1 ) value1 = self . _avg ( value00 , value10 , x_frac ) value2 = self . _avg ( value01 , value11 , x_frac ) value = self . _avg ( value1 , value2 , y_frac ) # print "%4d %4d | %4d\n%4d %4d | %4d\n-------------\n%4d" % ( # value00, value10, value1, value01, value11, value2, value) return value
Get the altitude of a lat lon pair using the four neighbouring pixels for interpolation .
389
18
229,115
def rewind ( self ) : self . _index = 0 self . percent = 0 self . messages = { } self . _flightmode_index = 0 self . _timestamp = None self . flightmode = None self . params = { }
rewind to start
52
4
229,116
def mavset ( self , mav , name , value , retries = 3 ) : got_ack = False while retries > 0 and not got_ack : retries -= 1 mav . param_set_send ( name . upper ( ) , float ( value ) ) tstart = time . time ( ) while time . time ( ) - tstart < 1 : ack = mav . recv_match ( type = 'PARAM_VALUE' , blocking = False ) if ack == None : time . sleep ( 0.1 ) continue if str ( name ) . upper ( ) == str ( ack . param_id ) . upper ( ) : got_ack = True self . __setitem__ ( name , float ( value ) ) break if not got_ack : print ( "timeout setting %s to %f" % ( name , float ( value ) ) ) return False return True
set a parameter on a mavlink connection
194
9
229,117
def save ( self , filename , wildcard = '*' , verbose = False ) : f = open ( filename , mode = 'w' ) k = list ( self . keys ( ) ) k . sort ( ) count = 0 for p in k : if p and fnmatch . fnmatch ( str ( p ) . upper ( ) , wildcard . upper ( ) ) : f . write ( "%-16.16s %f\n" % ( p , self . __getitem__ ( p ) ) ) count += 1 f . close ( ) if verbose : print ( "Saved %u parameters to %s" % ( count , filename ) )
save parameters to a file
142
5
229,118
def load ( self , filename , wildcard = '*' , mav = None , check = True ) : try : f = open ( filename , mode = 'r' ) except : print ( "Failed to open file '%s'" % filename ) return False count = 0 changed = 0 for line in f : line = line . strip ( ) if not line or line [ 0 ] == "#" : continue line = line . replace ( ',' , ' ' ) a = line . split ( ) if len ( a ) != 2 : print ( "Invalid line: %s" % line ) continue # some parameters should not be loaded from files if a [ 0 ] in self . exclude_load : continue if not fnmatch . fnmatch ( a [ 0 ] . upper ( ) , wildcard . upper ( ) ) : continue if mav is not None : if check : if a [ 0 ] not in self . keys ( ) : print ( "Unknown parameter %s" % a [ 0 ] ) continue old_value = self . __getitem__ ( a [ 0 ] ) if math . fabs ( old_value - float ( a [ 1 ] ) ) <= self . mindelta : count += 1 continue if self . mavset ( mav , a [ 0 ] , a [ 1 ] ) : print ( "changed %s from %f to %f" % ( a [ 0 ] , old_value , float ( a [ 1 ] ) ) ) else : print ( "set %s to %f" % ( a [ 0 ] , float ( a [ 1 ] ) ) ) self . mavset ( mav , a [ 0 ] , a [ 1 ] ) changed += 1 else : self . __setitem__ ( a [ 0 ] , float ( a [ 1 ] ) ) count += 1 f . close ( ) if mav is not None : print ( "Loaded %u parameters from %s (changed %u)" % ( count , filename , changed ) ) else : print ( "Loaded %u parameters from %s" % ( count , filename ) ) return True
load parameters from a file
447
5
229,119
def diff ( self , filename , wildcard = '*' ) : other = MAVParmDict ( ) if not other . load ( filename ) : return keys = sorted ( list ( set ( self . keys ( ) ) . union ( set ( other . keys ( ) ) ) ) ) for k in keys : if not fnmatch . fnmatch ( str ( k ) . upper ( ) , wildcard . upper ( ) ) : continue if not k in other : print ( "%-16.16s %12.4f" % ( k , self [ k ] ) ) elif not k in self : print ( "%-16.16s %12.4f" % ( k , other [ k ] ) ) elif abs ( self [ k ] - other [ k ] ) > self . mindelta : print ( "%-16.16s %12.4f %12.4f" % ( k , other [ k ] , self [ k ] ) )
show differences with another parameter file
208
6
229,120
def generate ( basename , xml_list ) : for xml in xml_list : generate_one ( basename , xml ) generate_enums ( basename , xml ) generate_MAVLinkMessage ( basename , xml_list ) copy_fixed_headers ( basename , xml_list [ 0 ] )
generate complete MAVLink Java implemenation
67
11
229,121
def aq_telemetry_f_encode ( self , Index , value1 , value2 , value3 , value4 , value5 , value6 , value7 , value8 , value9 , value10 , value11 , value12 , value13 , value14 , value15 , value16 , value17 , value18 , value19 , value20 ) : return MAVLink_aq_telemetry_f_message ( Index , value1 , value2 , value3 , value4 , value5 , value6 , value7 , value8 , value9 , value10 , value11 , value12 , value13 , value14 , value15 , value16 , value17 , value18 , value19 , value20 )
Sends up to 20 raw float values .
153
9
229,122
def close ( self ) : self . close_event . set ( ) if self . is_alive ( ) : self . child . join ( 2 )
close the console
33
3
229,123
def cmd_rally_add ( self , args ) : if len ( args ) < 1 : alt = self . settings . rallyalt else : alt = float ( args [ 0 ] ) if len ( args ) < 2 : break_alt = self . settings . rally_breakalt else : break_alt = float ( args [ 1 ] ) if len ( args ) < 3 : flag = self . settings . rally_flags else : flag = int ( args [ 2 ] ) #currently only supporting autoland values: #True (nonzero) and False (zero) if ( flag != 0 ) : flag = 2 if not self . have_list : print ( "Please list rally points first" ) return if ( self . rallyloader . rally_count ( ) > 4 ) : print ( "Only 5 rally points possible per flight plan." ) return 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 land_hdg = 0.0 self . rallyloader . create_and_append_rally_point ( latlon [ 0 ] * 1e7 , latlon [ 1 ] * 1e7 , alt , break_alt , land_hdg , flag ) self . send_rally_points ( ) print ( "Added Rally point at %s %f %f, autoland: %s" % ( str ( latlon ) , alt , break_alt , bool ( flag & 2 ) ) )
handle rally add
334
3
229,124
def cmd_rally_alt ( self , args ) : if ( len ( args ) < 2 ) : print ( "Usage: rally alt RALLYNUM newAlt <newBreakAlt>" ) return if not self . have_list : print ( "Please list rally points first" ) return idx = int ( args [ 0 ] ) if idx <= 0 or idx > self . rallyloader . rally_count ( ) : print ( "Invalid rally point number %u" % idx ) return new_alt = int ( args [ 1 ] ) new_break_alt = None if ( len ( args ) > 2 ) : new_break_alt = int ( args [ 2 ] ) self . rallyloader . set_alt ( idx , new_alt , new_break_alt ) self . send_rally_point ( idx - 1 ) self . fetch_rally_point ( idx - 1 ) self . rallyloader . reindex ( )
handle rally alt change
206
4
229,125
def cmd_rally_move ( self , args ) : if len ( args ) < 1 : print ( "Usage: rally move RALLYNUM" ) return if not self . have_list : print ( "Please list rally points first" ) return idx = int ( args [ 0 ] ) if idx <= 0 or idx > self . rallyloader . rally_count ( ) : print ( "Invalid rally point number %u" % idx ) return rpoint = self . rallyloader . rally_point ( idx - 1 ) 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 oldpos = ( rpoint . lat * 1e-7 , rpoint . lng * 1e-7 ) self . rallyloader . move ( idx , latlon [ 0 ] , latlon [ 1 ] ) self . send_rally_point ( idx - 1 ) p = self . fetch_rally_point ( idx - 1 ) if p . lat != int ( latlon [ 0 ] * 1e7 ) or p . lng != int ( latlon [ 1 ] * 1e7 ) : print ( "Rally move failed" ) return self . rallyloader . reindex ( ) print ( "Moved rally point from %s to %s at %fm" % ( str ( oldpos ) , str ( latlon ) , rpoint . alt ) )
handle rally move
330
3
229,126
def cmd_rally ( self , args ) : #TODO: add_land arg if len ( args ) < 1 : self . print_usage ( ) return elif args [ 0 ] == "add" : self . cmd_rally_add ( args [ 1 : ] ) elif args [ 0 ] == "move" : self . cmd_rally_move ( args [ 1 : ] ) elif args [ 0 ] == "clear" : self . rallyloader . clear ( ) self . mav_param . mavset ( self . master , 'RALLY_TOTAL' , 0 , 3 ) elif args [ 0 ] == "remove" : if not self . have_list : print ( "Please list rally points first" ) return if ( len ( args ) < 2 ) : print ( "Usage: rally remove RALLYNUM" ) return self . rallyloader . remove ( int ( args [ 1 ] ) ) self . send_rally_points ( ) elif args [ 0 ] == "list" : self . list_rally_points ( ) self . have_list = True elif args [ 0 ] == "load" : if ( len ( args ) < 2 ) : print ( "Usage: rally load filename" ) return try : self . rallyloader . load ( args [ 1 ] ) except Exception as msg : print ( "Unable to load %s - %s" % ( args [ 1 ] , msg ) ) return self . send_rally_points ( ) self . have_list = True print ( "Loaded %u rally points from %s" % ( self . rallyloader . rally_count ( ) , args [ 1 ] ) ) elif args [ 0 ] == "save" : if ( len ( args ) < 2 ) : print ( "Usage: rally save filename" ) return self . rallyloader . save ( args [ 1 ] ) print ( "Saved rally file %s" % args [ 1 ] ) elif args [ 0 ] == "alt" : self . cmd_rally_alt ( args [ 1 : ] ) elif args [ 0 ] == "land" : if ( len ( args ) >= 2 and args [ 1 ] == "abort" ) : self . abort_ack_received = False self . abort_first_send_time = 0 self . abort_alt = self . settings . rally_breakalt if ( len ( args ) >= 3 ) : self . abort_alt = int ( args [ 2 ] ) else : self . master . mav . command_long_send ( self . settings . target_system , self . settings . target_component , mavutil . mavlink . MAV_CMD_DO_RALLY_LAND , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) else : self . print_usage ( )
rally point commands
615
4
229,127
def mavlink_packet ( self , m ) : type = m . get_type ( ) if type in [ 'COMMAND_ACK' ] : if m . command == mavutil . mavlink . MAV_CMD_DO_GO_AROUND : if ( m . result == 0 and self . abort_ack_received == False ) : self . say ( "Landing Abort Command Successfully Sent." ) self . abort_ack_received = True elif ( m . result != 0 and self . abort_ack_received == False ) : self . say ( "Landing Abort Command Unsuccessful." ) elif m . command == mavutil . mavlink . MAV_CMD_DO_RALLY_LAND : if ( m . result == 0 ) : self . say ( "Landing." )
handle incoming mavlink packet
183
6
229,128
def send_rally_point ( self , i ) : p = self . rallyloader . rally_point ( i ) p . target_system = self . target_system p . target_component = self . target_component self . master . mav . send ( p )
send rally points from fenceloader
59
6
229,129
def send_rally_points ( self ) : self . mav_param . mavset ( self . master , 'RALLY_TOTAL' , self . rallyloader . rally_count ( ) , 3 ) for i in range ( self . rallyloader . rally_count ( ) ) : self . send_rally_point ( i )
send rally points from rallyloader
75
6
229,130
def getBumper ( self ) : if self . hasproxy ( ) : self . lock . acquire ( ) bumper = self . bumper self . lock . release ( ) return bumper return None
Returns last Bumper .
39
5
229,131
def imageMsg2Image ( img , bridge ) : image = Image ( ) image . width = img . width image . height = img . height image . format = "RGB8" image . timeStamp = img . header . stamp . secs + ( img . header . stamp . nsecs * 1e-9 ) cv_image = 0 if ( img . encoding == "32FC1" ) : gray_img_buff = bridge . imgmsg_to_cv2 ( img , "32FC1" ) cv_image = depthToRGB8 ( gray_img_buff ) else : cv_image = bridge . imgmsg_to_cv2 ( img , "rgb8" ) image . data = cv_image return image
Translates from ROS Image to JderobotTypes Image .
163
14
229,132
def Images2Rgbd ( rgb , d ) : data = Rgbd ( ) data . color = imageMsg2Image ( rgb ) data . depth = imageMsg2Image ( d ) data . timeStamp = rgb . header . stamp . secs + ( rgb . header . stamp . nsecs * 1e-9 ) return data
Translates from ROS Images to JderobotTypes Rgbd .
74
16
229,133
def __callback ( self , rgb , d ) : data = Images2Rgbd ( rgb , d ) self . lock . acquire ( ) self . data = data self . lock . release ( )
Callback function to receive and save Rgbd Scans .
42
12
229,134
def getRgbdData ( self ) : self . lock . acquire ( ) data = self . data self . lock . release ( ) return data
Returns last RgbdData .
31
7
229,135
def fence_fetch_point_send ( self , target_system , target_component , idx , force_mavlink1 = False ) : return self . send ( self . fence_fetch_point_encode ( target_system , target_component , idx ) , force_mavlink1 = force_mavlink1 )
Request a current fence point from MAV
76
8
229,136
def hwstatus_send ( self , Vcc , I2Cerr , force_mavlink1 = False ) : return self . send ( self . hwstatus_encode ( Vcc , I2Cerr ) , force_mavlink1 = force_mavlink1 )
Status of key hardware
64
4
229,137
def data16_send ( self , type , len , data , force_mavlink1 = False ) : return self . send ( self . data16_encode ( type , len , data ) , force_mavlink1 = force_mavlink1 )
Data packet size 16
58
4
229,138
def data32_send ( self , type , len , data , force_mavlink1 = False ) : return self . send ( self . data32_encode ( type , len , data ) , force_mavlink1 = force_mavlink1 )
Data packet size 32
58
4
229,139
def data64_send ( self , type , len , data , force_mavlink1 = False ) : return self . send ( self . data64_encode ( type , len , data ) , force_mavlink1 = force_mavlink1 )
Data packet size 64
58
4
229,140
def data96_send ( self , type , len , data , force_mavlink1 = False ) : return self . send ( self . data96_encode ( type , len , data ) , force_mavlink1 = force_mavlink1 )
Data packet size 96
58
4
229,141
def rally_fetch_point_send ( self , target_system , target_component , idx , force_mavlink1 = False ) : return self . send ( self . rally_fetch_point_encode ( target_system , target_component , idx ) , force_mavlink1 = force_mavlink1 )
Request a current rally point from MAV . MAV should respond with a RALLY_POINT message . MAV should not respond if the request is invalid .
76
33
229,142
def battery2_send ( self , voltage , current_battery , force_mavlink1 = False ) : return self . send ( self . battery2_encode ( voltage , current_battery ) , force_mavlink1 = force_mavlink1 )
2nd Battery status
60
4
229,143
def gopro_heartbeat_send ( self , status , capture_mode , flags , force_mavlink1 = False ) : return self . send ( self . gopro_heartbeat_encode ( status , capture_mode , flags ) , force_mavlink1 = force_mavlink1 )
Heartbeat from a HeroBus attached GoPro
70
8
229,144
def gopro_get_request_send ( self , target_system , target_component , cmd_id , force_mavlink1 = False ) : return self . send ( self . gopro_get_request_encode ( target_system , target_component , cmd_id ) , force_mavlink1 = force_mavlink1 )
Request a GOPRO_COMMAND response from the GoPro
80
12
229,145
def gopro_get_response_send ( self , cmd_id , status , value , force_mavlink1 = False ) : return self . send ( self . gopro_get_response_encode ( cmd_id , status , value ) , force_mavlink1 = force_mavlink1 )
Response from a GOPRO_COMMAND get request
72
11
229,146
def gopro_set_response_send ( self , cmd_id , status , force_mavlink1 = False ) : return self . send ( self . gopro_set_response_encode ( cmd_id , status ) , force_mavlink1 = force_mavlink1 )
Response from a GOPRO_COMMAND set request
68
11
229,147
def rpm_send ( self , rpm1 , rpm2 , force_mavlink1 = False ) : return self . send ( self . rpm_encode ( rpm1 , rpm2 ) , force_mavlink1 = force_mavlink1 )
RPM sensor output
56
4
229,148
def convert ( self , value , fromunits , tounits ) : if fromunits == tounits : return value if ( fromunits , tounits ) in self . unitmap : return value * self . unitmap [ ( fromunits , tounits ) ] if ( tounits , fromunits ) in self . unitmap : return value / self . unitmap [ ( tounits , fromunits ) ] raise fgFDMError ( "unknown unit mapping (%s,%s)" % ( fromunits , tounits ) )
convert a value from one set of units to another
116
11
229,149
def units ( self , varname ) : if not varname in self . mapping . vars : raise fgFDMError ( 'Unknown variable %s' % varname ) return self . mapping . vars [ varname ] . units
return the default units of a variable
51
7
229,150
def variables ( self ) : return sorted ( list ( self . mapping . vars . keys ( ) ) , key = lambda v : self . mapping . vars [ v ] . index )
return a list of available variables
40
6
229,151
def get ( self , varname , idx = 0 , units = None ) : if not varname in self . mapping . vars : raise fgFDMError ( 'Unknown variable %s' % varname ) if idx >= self . mapping . vars [ varname ] . arraylength : raise fgFDMError ( 'index of %s beyond end of array idx=%u arraylength=%u' % ( varname , idx , self . mapping . vars [ varname ] . arraylength ) ) value = self . values [ self . mapping . vars [ varname ] . index + idx ] if units : value = self . convert ( value , self . mapping . vars [ varname ] . units , units ) return value
get a variable value
165
4
229,152
def set ( self , varname , value , idx = 0 , units = None ) : if not varname in self . mapping . vars : raise fgFDMError ( 'Unknown variable %s' % varname ) if idx >= self . mapping . vars [ varname ] . arraylength : raise fgFDMError ( 'index of %s beyond end of array idx=%u arraylength=%u' % ( varname , idx , self . mapping . vars [ varname ] . arraylength ) ) if units : value = self . convert ( value , units , self . mapping . vars [ varname ] . units ) # avoid range errors when packing into 4 byte floats if math . isinf ( value ) or math . isnan ( value ) or math . fabs ( value ) > 3.4e38 : value = 0 self . values [ self . mapping . vars [ varname ] . index + idx ] = value
set a variable value
209
4
229,153
def parse ( self , buf ) : try : t = struct . unpack ( self . pack_string , buf ) except struct . error as msg : raise fgFDMError ( 'unable to parse - %s' % msg ) self . values = list ( t )
parse a FD FDM buffer
59
6
229,154
def pack ( self ) : for i in range ( len ( self . values ) ) : if math . isnan ( self . values [ i ] ) : self . values [ i ] = 0 return struct . pack ( self . pack_string , * self . values )
pack a FD FDM buffer from current values
57
9
229,155
def quat2Yaw ( qw , qx , qy , qz ) : rotateZa0 = 2.0 * ( qx * qy + qw * qz ) rotateZa1 = qw * qw + qx * qx - qy * qy - qz * qz rotateZ = 0.0 if ( rotateZa0 != 0.0 and rotateZa1 != 0.0 ) : rotateZ = atan2 ( rotateZa0 , rotateZa1 ) return rotateZ
Translates from Quaternion to Yaw .
117
11
229,156
def quat2Pitch ( qw , qx , qy , qz ) : rotateYa0 = - 2.0 * ( qx * qz - qw * qy ) rotateY = 0.0 if ( rotateYa0 >= 1.0 ) : rotateY = pi / 2.0 elif ( rotateYa0 <= - 1.0 ) : rotateY = - pi / 2.0 else : rotateY = asin ( rotateYa0 ) return rotateY
Translates from Quaternion to Pitch .
108
10
229,157
def odometry2Pose3D ( odom ) : pose = Pose3d ( ) ori = odom . pose . pose . orientation pose . x = odom . pose . pose . position . x pose . y = odom . pose . pose . position . y pose . z = odom . pose . pose . position . z #pose.h = odom.pose.pose.position.h pose . yaw = quat2Yaw ( ori . w , ori . x , ori . y , ori . z ) pose . pitch = quat2Pitch ( ori . w , ori . x , ori . y , ori . z ) pose . roll = quat2Roll ( ori . w , ori . x , ori . y , ori . z ) pose . q = [ ori . w , ori . x , ori . y , ori . z ] pose . timeStamp = odom . header . stamp . secs + ( odom . header . stamp . nsecs * 1e-9 ) return pose
Translates from ROS Odometry to JderobotTypes Pose3d .
221
17
229,158
def __callback ( self , odom ) : pose = odometry2Pose3D ( odom ) self . lock . acquire ( ) self . data = pose self . lock . release ( )
Callback function to receive and save Pose3d .
42
10
229,159
def clip ( self , px , py , w , h , img ) : sx = 0 sy = 0 if px < 0 : sx = - px w += px px = 0 if py < 0 : sy = - py h += py py = 0 if px + w > img . width : w = img . width - px if py + h > img . height : h = img . height - py return ( px , py , sx , sy , w , h )
clip an area for display on the map
109
8
229,160
def update_position ( self , newpos ) : if getattr ( self , 'trail' , None ) is not None : self . trail . update_position ( newpos ) self . latlon = newpos . latlon if hasattr ( self , 'rotation' ) : self . rotation = newpos . rotation
update object position
69
3
229,161
def clicked ( self , px , py ) : if self . hidden : return None for i in range ( len ( self . _pix_points ) ) : if self . _pix_points [ i ] is None : continue ( pixx , pixy ) = self . _pix_points [ i ] if abs ( px - pixx ) < 6 and abs ( py - pixy ) < 6 : self . _selected_vertex = i return math . sqrt ( ( px - pixx ) ** 2 + ( py - pixy ) ** 2 ) return None
see if the polygon has been clicked on . Consider it clicked if the pixel is within 6 of the point
132
22
229,162
def clicked ( self , px , py ) : if self . hidden : return None if ( abs ( px - self . posx ) > self . width / 2 or abs ( py - self . posy ) > self . height / 2 ) : return None return math . sqrt ( ( px - self . posx ) ** 2 + ( py - self . posy ) ** 2 )
see if the image has been clicked on
85
8
229,163
def draw ( self , parent , box ) : import wx from MAVProxy . modules . lib import mp_widgets if self . imgpanel is None : self . imgpanel = mp_widgets . ImagePanel ( parent , self . img ( ) ) box . Add ( self . imgpanel , flag = wx . LEFT , border = 0 ) box . Layout ( )
redraw the image
81
4
229,164
def _resize ( self ) : lines = self . text . split ( '\n' ) xsize , ysize = 0 , 0 for line in lines : size = self . textctrl . GetTextExtent ( line ) xsize = max ( xsize , size [ 0 ] ) ysize = ysize + size [ 1 ] xsize = int ( xsize * 1.2 ) self . textctrl . SetSize ( ( xsize , ysize ) ) self . textctrl . SetMinSize ( ( xsize , ysize ) )
calculate and set text size handling multi - line
117
11
229,165
def draw ( self , parent , box ) : import wx if self . textctrl is None : self . textctrl = wx . TextCtrl ( parent , style = wx . TE_MULTILINE | wx . TE_READONLY ) self . textctrl . WriteText ( self . text ) self . _resize ( ) box . Add ( self . textctrl , flag = wx . LEFT , border = 0 ) box . Layout ( )
redraw the text
100
4
229,166
def button ( self , name , filename , command ) : try : img = LoadImage ( filename ) b = Tkinter . Button ( self . frame , image = img , command = command ) b . image = img except Exception : b = Tkinter . Button ( self . frame , text = filename , command = command ) b . pack ( side = Tkinter . LEFT ) self . buttons [ name ] = b
add a button
90
3
229,167
def find_message ( self ) : while True : self . msg = self . mlog . recv_match ( condition = args . condition ) if self . msg is not None and self . msg . get_type ( ) != 'BAD_DATA' : break if self . mlog . f . tell ( ) > self . filesize - 10 : self . paused = True break self . last_timestamp = getattr ( self . msg , '_timestamp' )
find the next valid message
102
5
229,168
def slew ( self , value ) : if float ( value ) != self . filepos : pos = float ( value ) * self . filesize self . mlog . f . seek ( int ( pos ) ) self . find_message ( )
move to a given position in the file
51
8
229,169
def draw_plot ( self ) : import numpy , pylab state = self . state if len ( self . data [ 0 ] ) == 0 : print ( "no data to plot" ) return vhigh = max ( self . data [ 0 ] ) vlow = min ( self . data [ 0 ] ) for i in range ( 1 , len ( self . plot_data ) ) : vhigh = max ( vhigh , max ( self . data [ i ] ) ) vlow = min ( vlow , min ( self . data [ i ] ) ) ymin = vlow - 0.05 * ( vhigh - vlow ) ymax = vhigh + 0.05 * ( vhigh - vlow ) if ymin == ymax : ymax = ymin + 0.1 ymin = ymin - 0.1 self . axes . set_ybound ( lower = ymin , upper = ymax ) self . axes . grid ( True , color = 'gray' ) pylab . setp ( self . axes . get_xticklabels ( ) , visible = True ) pylab . setp ( self . axes . get_legend ( ) . get_texts ( ) , fontsize = 'small' ) for i in range ( len ( self . plot_data ) ) : ydata = numpy . array ( self . data [ i ] ) xdata = self . xdata if len ( ydata ) < len ( self . xdata ) : xdata = xdata [ - len ( ydata ) : ] self . plot_data [ i ] . set_xdata ( xdata ) self . plot_data [ i ] . set_ydata ( ydata ) self . canvas . draw ( )
Redraws the plot
375
5
229,170
def set_close_on_exec ( fd ) : try : import fcntl flags = fcntl . fcntl ( fd , fcntl . F_GETFD ) flags |= fcntl . FD_CLOEXEC fcntl . fcntl ( fd , fcntl . F_SETFD , flags ) except Exception : pass
set the clone on exec flag on a file descriptor . Ignore exceptions
89
13
229,171
def mavlink_connection ( device , baud = 115200 , source_system = 255 , planner_format = None , write = False , append = False , robust_parsing = True , notimestamps = False , input = True , dialect = None , autoreconnect = False , zero_time_base = False , retries = 3 , use_native = default_native ) : global mavfile_global if dialect is not None : set_dialect ( dialect ) if device . startswith ( 'tcp:' ) : return mavtcp ( device [ 4 : ] , source_system = source_system , retries = retries , use_native = use_native ) if device . startswith ( 'tcpin:' ) : return mavtcpin ( device [ 6 : ] , source_system = source_system , retries = retries , use_native = use_native ) if device . startswith ( 'udpin:' ) : return mavudp ( device [ 6 : ] , input = True , source_system = source_system , use_native = use_native ) if device . startswith ( 'udpout:' ) : return mavudp ( device [ 7 : ] , input = False , source_system = source_system , use_native = use_native ) if device . startswith ( 'udpbcast:' ) : return mavudp ( device [ 9 : ] , input = False , source_system = source_system , use_native = use_native , broadcast = True ) # For legacy purposes we accept the following syntax and let the caller to specify direction if device . startswith ( 'udp:' ) : return mavudp ( device [ 4 : ] , input = input , source_system = source_system , use_native = use_native ) if device . lower ( ) . endswith ( '.bin' ) or device . lower ( ) . endswith ( '.px4log' ) : # support dataflash logs from pymavlink import DFReader m = DFReader . DFReader_binary ( device , zero_time_base = zero_time_base ) mavfile_global = m return m if device . endswith ( '.log' ) : # support dataflash text logs from pymavlink import DFReader if DFReader . DFReader_is_text_log ( device ) : m = DFReader . DFReader_text ( device , zero_time_base = zero_time_base ) mavfile_global = m return m # list of suffixes to prevent setting DOS paths as UDP sockets logsuffixes = [ 'mavlink' , 'log' , 'raw' , 'tlog' ] suffix = device . split ( '.' ) [ - 1 ] . lower ( ) if device . find ( ':' ) != - 1 and not suffix in logsuffixes : return mavudp ( device , source_system = source_system , input = input , use_native = use_native ) if os . path . isfile ( device ) : if device . endswith ( ".elf" ) or device . find ( "/bin/" ) != - 1 : print ( "executing '%s'" % device ) return mavchildexec ( device , source_system = source_system , use_native = use_native ) else : return mavlogfile ( device , planner_format = planner_format , write = write , append = append , robust_parsing = robust_parsing , notimestamps = notimestamps , source_system = source_system , use_native = use_native ) return mavserial ( device , baud = baud , source_system = source_system , autoreconnect = autoreconnect , use_native = use_native )
open a serial UDP TCP or file mavlink connection
830
11
229,172
def is_printable ( c ) : global have_ascii if have_ascii : return ascii . isprint ( c ) if isinstance ( c , int ) : ic = c else : ic = ord ( c ) return ic >= 32 and ic <= 126
see if a character is printable
60
7
229,173
def auto_detect_serial_win32 ( preferred_list = [ '*' ] ) : try : from serial . tools . list_ports_windows import comports list = sorted ( comports ( ) ) except : return [ ] ret = [ ] others = [ ] for port , description , hwid in list : matches = False p = SerialPort ( port , description = description , hwid = hwid ) for preferred in preferred_list : if fnmatch . fnmatch ( description , preferred ) or fnmatch . fnmatch ( hwid , preferred ) : matches = True if matches : ret . append ( p ) else : others . append ( p ) if len ( ret ) > 0 : return ret # now the rest ret . extend ( others ) return ret
try to auto - detect serial ports on win32
162
10
229,174
def auto_detect_serial_unix ( preferred_list = [ '*' ] ) : import glob glist = glob . glob ( '/dev/ttyS*' ) + glob . glob ( '/dev/ttyUSB*' ) + glob . glob ( '/dev/ttyACM*' ) + glob . glob ( '/dev/serial/by-id/*' ) ret = [ ] others = [ ] # try preferred ones first for d in glist : matches = False for preferred in preferred_list : if fnmatch . fnmatch ( d , preferred ) : matches = True if matches : ret . append ( SerialPort ( d ) ) else : others . append ( SerialPort ( d ) ) if len ( ret ) > 0 : return ret ret . extend ( others ) return ret
try to auto - detect serial ports on unix
169
10
229,175
def auto_detect_serial ( preferred_list = [ '*' ] ) : # see if if os . name == 'nt' : return auto_detect_serial_win32 ( preferred_list = preferred_list ) return auto_detect_serial_unix ( preferred_list = preferred_list )
try to auto - detect serial port
69
7
229,176
def mode_string_v09 ( msg ) : mode = msg . mode nav_mode = msg . nav_mode MAV_MODE_UNINIT = 0 MAV_MODE_MANUAL = 2 MAV_MODE_GUIDED = 3 MAV_MODE_AUTO = 4 MAV_MODE_TEST1 = 5 MAV_MODE_TEST2 = 6 MAV_MODE_TEST3 = 7 MAV_NAV_GROUNDED = 0 MAV_NAV_LIFTOFF = 1 MAV_NAV_HOLD = 2 MAV_NAV_WAYPOINT = 3 MAV_NAV_VECTOR = 4 MAV_NAV_RETURNING = 5 MAV_NAV_LANDING = 6 MAV_NAV_LOST = 7 MAV_NAV_LOITER = 8 cmode = ( mode , nav_mode ) mapping = { ( MAV_MODE_UNINIT , MAV_NAV_GROUNDED ) : "INITIALISING" , ( MAV_MODE_MANUAL , MAV_NAV_VECTOR ) : "MANUAL" , ( MAV_MODE_TEST3 , MAV_NAV_VECTOR ) : "CIRCLE" , ( MAV_MODE_GUIDED , MAV_NAV_VECTOR ) : "GUIDED" , ( MAV_MODE_TEST1 , MAV_NAV_VECTOR ) : "STABILIZE" , ( MAV_MODE_TEST2 , MAV_NAV_LIFTOFF ) : "FBWA" , ( MAV_MODE_AUTO , MAV_NAV_WAYPOINT ) : "AUTO" , ( MAV_MODE_AUTO , MAV_NAV_RETURNING ) : "RTL" , ( MAV_MODE_AUTO , MAV_NAV_LOITER ) : "LOITER" , ( MAV_MODE_AUTO , MAV_NAV_LIFTOFF ) : "TAKEOFF" , ( MAV_MODE_AUTO , MAV_NAV_LANDING ) : "LANDING" , ( MAV_MODE_AUTO , MAV_NAV_HOLD ) : "LOITER" , ( MAV_MODE_GUIDED , MAV_NAV_VECTOR ) : "GUIDED" , ( MAV_MODE_GUIDED , MAV_NAV_WAYPOINT ) : "GUIDED" , ( 100 , MAV_NAV_VECTOR ) : "STABILIZE" , ( 101 , MAV_NAV_VECTOR ) : "ACRO" , ( 102 , MAV_NAV_VECTOR ) : "ALT_HOLD" , ( 107 , MAV_NAV_VECTOR ) : "CIRCLE" , ( 109 , MAV_NAV_VECTOR ) : "LAND" , } if cmode in mapping : return mapping [ cmode ] return "Mode(%s,%s)" % cmode
mode string for 0 . 9 protocol
696
7
229,177
def mode_mapping_bynumber ( mav_type ) : map = None if mav_type in [ mavlink . MAV_TYPE_QUADROTOR , mavlink . MAV_TYPE_HELICOPTER , mavlink . MAV_TYPE_HEXAROTOR , mavlink . MAV_TYPE_OCTOROTOR , mavlink . MAV_TYPE_COAXIAL , mavlink . MAV_TYPE_TRICOPTER ] : map = mode_mapping_acm if mav_type == mavlink . MAV_TYPE_FIXED_WING : map = mode_mapping_apm if mav_type == mavlink . MAV_TYPE_GROUND_ROVER : map = mode_mapping_rover if mav_type == mavlink . MAV_TYPE_ANTENNA_TRACKER : map = mode_mapping_tracker if map is None : return None return map
return dictionary mapping mode numbers to name or None if unknown
222
11
229,178
def mode_string_v10 ( msg ) : if msg . autopilot == mavlink . MAV_AUTOPILOT_PX4 : return interpret_px4_mode ( msg . base_mode , msg . custom_mode ) if not msg . base_mode & mavlink . MAV_MODE_FLAG_CUSTOM_MODE_ENABLED : return "Mode(0x%08x)" % msg . base_mode if msg . type in [ mavlink . MAV_TYPE_QUADROTOR , mavlink . MAV_TYPE_HEXAROTOR , mavlink . MAV_TYPE_OCTOROTOR , mavlink . MAV_TYPE_TRICOPTER , mavlink . MAV_TYPE_COAXIAL , mavlink . MAV_TYPE_HELICOPTER ] : if msg . custom_mode in mode_mapping_acm : return mode_mapping_acm [ msg . custom_mode ] if msg . type == mavlink . MAV_TYPE_FIXED_WING : if msg . custom_mode in mode_mapping_apm : return mode_mapping_apm [ msg . custom_mode ] if msg . type == mavlink . MAV_TYPE_GROUND_ROVER : if msg . custom_mode in mode_mapping_rover : return mode_mapping_rover [ msg . custom_mode ] if msg . type == mavlink . MAV_TYPE_ANTENNA_TRACKER : if msg . custom_mode in mode_mapping_tracker : return mode_mapping_tracker [ msg . custom_mode ] return "Mode(%u)" % msg . custom_mode
mode string for 1 . 0 protocol from heartbeat
386
9
229,179
def auto_mavlink_version ( self , buf ) : global mavlink if len ( buf ) == 0 : return try : magic = ord ( buf [ 0 ] ) except : magic = buf [ 0 ] if not magic in [ 85 , 254 , 253 ] : return self . first_byte = False if self . WIRE_PROTOCOL_VERSION == "0.9" and magic == 254 : self . WIRE_PROTOCOL_VERSION = "1.0" set_dialect ( current_dialect ) elif self . WIRE_PROTOCOL_VERSION == "1.0" and magic == 85 : self . WIRE_PROTOCOL_VERSION = "0.9" os . environ [ 'MAVLINK09' ] = '1' set_dialect ( current_dialect ) elif self . WIRE_PROTOCOL_VERSION != "2.0" and magic == 253 : self . WIRE_PROTOCOL_VERSION = "2.0" os . environ [ 'MAVLINK20' ] = '1' set_dialect ( current_dialect ) else : return # switch protocol ( callback , callback_args , callback_kwargs ) = ( self . mav . callback , self . mav . callback_args , self . mav . callback_kwargs ) self . mav = mavlink . MAVLink ( self , srcSystem = self . source_system ) self . mav . robust_parsing = self . robust_parsing self . WIRE_PROTOCOL_VERSION = mavlink . WIRE_PROTOCOL_VERSION ( self . mav . callback , self . mav . callback_args , self . mav . callback_kwargs ) = ( callback , callback_args , callback_kwargs )
auto - switch mavlink protocol version
403
8
229,180
def select ( self , timeout ) : if self . fd is None : time . sleep ( min ( timeout , 0.5 ) ) return True try : ( rin , win , xin ) = select . select ( [ self . fd ] , [ ] , [ ] , timeout ) except select . error : return False return len ( rin ) == 1
wait for up to timeout seconds for more data
77
9
229,181
def packet_loss ( self ) : if self . mav_count == 0 : return 0 return ( 100.0 * self . mav_loss ) / ( self . mav_count + self . mav_loss )
packet loss as a percentage
49
6
229,182
def recv_match ( self , condition = None , type = None , blocking = False , timeout = None ) : if type is not None and not isinstance ( type , list ) : type = [ type ] start_time = time . time ( ) while True : if timeout is not None : now = time . time ( ) if now < start_time : start_time = now # If an external process rolls back system time, we should not spin forever. if start_time + timeout < time . time ( ) : return None m = self . recv_msg ( ) if m is None : if blocking : for hook in self . idle_hooks : hook ( self ) if timeout is None : self . select ( 0.05 ) else : self . select ( timeout / 2 ) continue return None if type is not None and not m . get_type ( ) in type : continue if not evaluate_condition ( condition , self . messages ) : continue return m
recv the next MAVLink message that matches the given condition type can be a string or a list of strings
205
23
229,183
def setup_logfile ( self , logfile , mode = 'w' ) : self . logfile = open ( logfile , mode = mode )
start logging to the given logfile with timestamps
32
11
229,184
def setup_logfile_raw ( self , logfile , mode = 'w' ) : self . logfile_raw = open ( logfile , mode = mode )
start logging raw bytes to the given logfile without timestamps
36
13
229,185
def param_fetch_all ( self ) : if time . time ( ) - getattr ( self , 'param_fetch_start' , 0 ) < 2.0 : # don't fetch too often return self . param_fetch_start = time . time ( ) self . param_fetch_in_progress = True self . mav . param_request_list_send ( self . target_system , self . target_component )
initiate fetch of all parameters
97
7
229,186
def param_fetch_one ( self , name ) : try : idx = int ( name ) self . mav . param_request_read_send ( self . target_system , self . target_component , "" , idx ) except Exception : self . mav . param_request_read_send ( self . target_system , self . target_component , name , - 1 )
initiate fetch of one parameter
85
7
229,187
def time_since ( self , mtype ) : if not mtype in self . messages : return time . time ( ) - self . start_time return time . time ( ) - self . messages [ mtype ] . _timestamp
return the time since the last message of type mtype was received
50
13
229,188
def param_set_send ( self , parm_name , parm_value , parm_type = None ) : if self . mavlink10 ( ) : if parm_type == None : parm_type = mavlink . MAVLINK_TYPE_FLOAT self . mav . param_set_send ( self . target_system , self . target_component , parm_name , parm_value , parm_type ) else : self . mav . param_set_send ( self . target_system , self . target_component , parm_name , parm_value )
wrapper for parameter set
136
4
229,189
def waypoint_request_list_send ( self ) : if self . mavlink10 ( ) : self . mav . mission_request_list_send ( self . target_system , self . target_component ) else : self . mav . waypoint_request_list_send ( self . target_system , self . target_component )
wrapper for waypoint_request_list_send
76
10
229,190
def waypoint_clear_all_send ( self ) : if self . mavlink10 ( ) : self . mav . mission_clear_all_send ( self . target_system , self . target_component ) else : self . mav . waypoint_clear_all_send ( self . target_system , self . target_component )
wrapper for waypoint_clear_all_send
76
10
229,191
def waypoint_request_send ( self , seq ) : if self . mavlink10 ( ) : self . mav . mission_request_send ( self . target_system , self . target_component , seq ) else : self . mav . waypoint_request_send ( self . target_system , self . target_component , seq )
wrapper for waypoint_request_send
76
8
229,192
def waypoint_set_current_send ( self , seq ) : if self . mavlink10 ( ) : self . mav . mission_set_current_send ( self . target_system , self . target_component , seq ) else : self . mav . waypoint_set_current_send ( self . target_system , self . target_component , seq )
wrapper for waypoint_set_current_send
82
10
229,193
def waypoint_current ( self ) : if self . mavlink10 ( ) : m = self . recv_match ( type = 'MISSION_CURRENT' , blocking = True ) else : m = self . recv_match ( type = 'WAYPOINT_CURRENT' , blocking = True ) return m . seq
return current waypoint
72
4
229,194
def waypoint_count_send ( self , seq ) : if self . mavlink10 ( ) : self . mav . mission_count_send ( self . target_system , self . target_component , seq ) else : self . mav . waypoint_count_send ( self . target_system , self . target_component , seq )
wrapper for waypoint_count_send
76
8
229,195
def set_mode_auto ( self ) : if self . mavlink10 ( ) : self . mav . command_long_send ( self . target_system , self . target_component , mavlink . MAV_CMD_MISSION_START , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) else : MAV_ACTION_SET_AUTO = 13 self . mav . action_send ( self . target_system , self . target_component , MAV_ACTION_SET_AUTO )
enter auto mode
119
3
229,196
def set_mode ( self , mode , custom_mode = 0 , custom_sub_mode = 0 ) : mav_autopilot = self . field ( 'HEARTBEAT' , 'autopilot' , None ) if mav_autopilot == mavlink . MAV_AUTOPILOT_PX4 : self . set_mode_px4 ( mode , custom_mode , custom_sub_mode ) else : self . set_mode_apm ( mode )
set arbitrary flight mode
108
4
229,197
def set_mode_rtl ( self ) : if self . mavlink10 ( ) : self . mav . command_long_send ( self . target_system , self . target_component , mavlink . MAV_CMD_NAV_RETURN_TO_LAUNCH , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) else : MAV_ACTION_RETURN = 3 self . mav . action_send ( self . target_system , self . target_component , MAV_ACTION_RETURN )
enter RTL mode
121
4
229,198
def set_mode_manual ( self ) : if self . mavlink10 ( ) : self . mav . command_long_send ( self . target_system , self . target_component , mavlink . MAV_CMD_DO_SET_MODE , 0 , mavlink . MAV_MODE_MANUAL_ARMED , 0 , 0 , 0 , 0 , 0 , 0 ) else : MAV_ACTION_SET_MANUAL = 12 self . mav . action_send ( self . target_system , self . target_component , MAV_ACTION_SET_MANUAL )
enter MANUAL mode
133
4
229,199
def set_mode_fbwa ( self ) : if self . mavlink10 ( ) : self . mav . command_long_send ( self . target_system , self . target_component , mavlink . MAV_CMD_DO_SET_MODE , 0 , mavlink . MAV_MODE_STABILIZE_ARMED , 0 , 0 , 0 , 0 , 0 , 0 ) else : print ( "Forcing FBWA not supported" )
enter FBWA mode
104
4