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,000 | def bytes_needed ( self ) : if self . native : ret = self . native . expected_length - self . buf_len ( ) else : ret = self . expected_length - self . buf_len ( ) if ret <= 0 : return 1 return ret | return number of bytes needed for next parsing stage | 56 | 9 |
229,001 | def __callbacks ( self , msg ) : if self . callback : self . callback ( msg , * self . callback_args , * * self . callback_kwargs ) | this method exists only to make profiling results easier to read | 37 | 11 |
229,002 | def parse_char ( self , c ) : self . buf . extend ( c ) self . total_bytes_received += len ( c ) if self . native : if native_testing : self . test_buf . extend ( c ) m = self . __parse_char_native ( self . test_buf ) m2 = self . __parse_char_legacy ( ) if m2 != m : print ( "Native: %s\nLegacy: %s\n" % ( m , m2 ) ) raise Exception ( 'Native vs. Legacy mismatch' ) else : m = self . __parse_char_native ( self . buf ) else : m = self . __parse_char_legacy ( ) if m != None : self . total_packets_received += 1 self . __callbacks ( m ) else : # XXX The idea here is if we've read something and there's nothing left in # the buffer, reset it to 0 which frees the memory if self . buf_len ( ) == 0 and self . buf_index != 0 : self . buf = bytearray ( ) self . buf_index = 0 return m | input some data bytes possibly returning a new message | 248 | 9 |
229,003 | def parse_buffer ( self , s ) : m = self . parse_char ( s ) if m is None : return None ret = [ m ] while True : m = self . parse_char ( "" ) if m is None : return ret ret . append ( m ) return ret | input some data bytes possibly returning a list of new messages | 60 | 11 |
229,004 | def check_signature ( self , msgbuf , srcSystem , srcComponent ) : if isinstance ( msgbuf , array . array ) : msgbuf = msgbuf . tostring ( ) timestamp_buf = msgbuf [ - 12 : - 6 ] link_id = msgbuf [ - 13 ] ( tlow , thigh ) = struct . unpack ( '<IH' , timestamp_buf ) timestamp = tlow + ( thigh << 32 ) # see if the timestamp is acceptable stream_key = ( link_id , srcSystem , srcComponent ) if stream_key in self . signing . stream_timestamps : if timestamp <= self . signing . stream_timestamps [ stream_key ] : # reject old timestamp # print('old timestamp') return False else : # a new stream has appeared. Accept the timestamp if it is at most # one minute behind our current timestamp if timestamp + 6000 * 1000 < self . signing . timestamp : # print('bad new stream ', timestamp/(100.0*1000*60*60*24*365), self.signing.timestamp/(100.0*1000*60*60*24*365)) return False self . signing . stream_timestamps [ stream_key ] = timestamp # print('new stream') h = hashlib . new ( 'sha256' ) h . update ( self . signing . secret_key ) h . update ( msgbuf [ : - 6 ] ) sig1 = str ( h . digest ( ) ) [ : 6 ] sig2 = str ( msgbuf ) [ - 6 : ] if sig1 != sig2 : # print('sig mismatch') return False # the timestamp we next send with is the max of the received timestamp and # our current timestamp self . signing . timestamp = max ( self . signing . timestamp , timestamp ) return True | check signature on incoming message | 393 | 5 |
229,005 | def flexifunction_set_send ( self , target_system , target_component , force_mavlink1 = False ) : return self . send ( self . flexifunction_set_encode ( target_system , target_component ) , force_mavlink1 = force_mavlink1 ) | Depreciated but used as a compiler flag . Do not remove | 68 | 13 |
229,006 | def system_time_send ( self , time_unix_usec , time_boot_ms , force_mavlink1 = False ) : return self . send ( self . system_time_encode ( time_unix_usec , time_boot_ms ) , force_mavlink1 = force_mavlink1 ) | The system time is the time of the master clock typically the computer clock of the main onboard computer . | 76 | 20 |
229,007 | def set_mode_send ( self , target_system , base_mode , custom_mode , force_mavlink1 = False ) : return self . send ( self . set_mode_encode ( target_system , base_mode , custom_mode ) , force_mavlink1 = force_mavlink1 ) | THIS INTERFACE IS DEPRECATED . USE COMMAND_LONG with MAV_CMD_DO_SET_MODE INSTEAD . Set the system mode as defined by enum MAV_MODE . There is no target component id as the mode is by definition for the overall aircraft not only for one component . | 72 | 66 |
229,008 | def param_request_list_send ( self , target_system , target_component , force_mavlink1 = False ) : return self . send ( self . param_request_list_encode ( target_system , target_component ) , force_mavlink1 = force_mavlink1 ) | Request all parameters of this component . After this request all parameters are emitted . | 68 | 15 |
229,009 | def mission_current_send ( self , seq , force_mavlink1 = False ) : return self . send ( self . mission_current_encode ( seq ) , force_mavlink1 = force_mavlink1 ) | Message that announces the sequence number of the current active mission item . The MAV will fly towards this mission item . | 52 | 23 |
229,010 | def mission_count_send ( self , target_system , target_component , count , force_mavlink1 = False ) : return self . send ( self . mission_count_encode ( target_system , target_component , count ) , force_mavlink1 = force_mavlink1 ) | This message is emitted as response to MISSION_REQUEST_LIST by the MAV and to initiate a write transaction . The GCS can then request the individual mission item based on the knowledge of the total number of MISSIONs . | 68 | 48 |
229,011 | def mission_clear_all_send ( self , target_system , target_component , force_mavlink1 = False ) : return self . send ( self . mission_clear_all_encode ( target_system , target_component ) , force_mavlink1 = force_mavlink1 ) | Delete all mission items at once . | 68 | 7 |
229,012 | def data_stream_send ( self , stream_id , message_rate , on_off , force_mavlink1 = False ) : return self . send ( self . data_stream_encode ( stream_id , message_rate , on_off ) , force_mavlink1 = force_mavlink1 ) | THIS INTERFACE IS DEPRECATED . USE MESSAGE_INTERVAL INSTEAD . | 72 | 21 |
229,013 | def command_ack_send ( self , command , result , force_mavlink1 = False ) : return self . send ( self . command_ack_encode ( command , result ) , force_mavlink1 = force_mavlink1 ) | Report status of a command . Includes feedback wether the command was executed . | 56 | 15 |
229,014 | def timesync_send ( self , tc1 , ts1 , force_mavlink1 = False ) : return self . send ( self . timesync_encode ( tc1 , ts1 ) , force_mavlink1 = force_mavlink1 ) | Time synchronization message . | 58 | 4 |
229,015 | def camera_trigger_send ( self , time_usec , seq , force_mavlink1 = False ) : return self . send ( self . camera_trigger_encode ( time_usec , seq ) , force_mavlink1 = force_mavlink1 ) | Camera - IMU triggering and synchronisation message . | 62 | 10 |
229,016 | def log_erase_send ( self , target_system , target_component , force_mavlink1 = False ) : return self . send ( self . log_erase_encode ( target_system , target_component ) , force_mavlink1 = force_mavlink1 ) | Erase all logs | 66 | 4 |
229,017 | def log_request_end_send ( self , target_system , target_component , force_mavlink1 = False ) : return self . send ( self . log_request_end_encode ( target_system , target_component ) , force_mavlink1 = force_mavlink1 ) | Stop log transfer and resume normal logging | 68 | 7 |
229,018 | def power_status_send ( self , Vcc , Vservo , flags , force_mavlink1 = False ) : return self . send ( self . power_status_encode ( Vcc , Vservo , flags ) , force_mavlink1 = force_mavlink1 ) | Power supply status | 66 | 3 |
229,019 | def terrain_check_send ( self , lat , lon , force_mavlink1 = False ) : return self . send ( self . terrain_check_encode ( lat , lon ) , force_mavlink1 = force_mavlink1 ) | Request that the vehicle report terrain height at the given location . Used by GCS to check if vehicle has all terrain data needed for a mission . | 58 | 29 |
229,020 | def gps_input_encode ( self , time_usec , gps_id , ignore_flags , time_week_ms , time_week , fix_type , lat , lon , alt , hdop , vdop , vn , ve , vd , speed_accuracy , horiz_accuracy , vert_accuracy , satellites_visible ) : return MAVLink_gps_input_message ( time_usec , gps_id , ignore_flags , time_week_ms , time_week , fix_type , lat , lon , alt , hdop , vdop , vn , ve , vd , speed_accuracy , horiz_accuracy , vert_accuracy , satellites_visible ) | GPS sensor input message . This is a raw sensor value sent by the GPS . This is NOT the global position estimate of the sytem . | 166 | 29 |
229,021 | def message_interval_send ( self , message_id , interval_us , force_mavlink1 = False ) : return self . send ( self . message_interval_encode ( message_id , interval_us ) , force_mavlink1 = force_mavlink1 ) | This interface replaces DATA_STREAM | 66 | 7 |
229,022 | def extended_sys_state_send ( self , vtol_state , landed_state , force_mavlink1 = False ) : return self . send ( self . extended_sys_state_encode ( vtol_state , landed_state ) , force_mavlink1 = force_mavlink1 ) | Provides state for additional features | 72 | 6 |
229,023 | def named_value_float_send ( self , time_boot_ms , name , value , force_mavlink1 = False ) : return self . send ( self . named_value_float_encode ( time_boot_ms , name , value ) , force_mavlink1 = force_mavlink1 ) | Send a key - value pair as float . The use of this message is discouraged for normal packets but a quite efficient way for testing new messages and getting experimental debug output . | 72 | 34 |
229,024 | def named_value_int_send ( self , time_boot_ms , name , value , force_mavlink1 = False ) : return self . send ( self . named_value_int_encode ( time_boot_ms , name , value ) , force_mavlink1 = force_mavlink1 ) | Send a key - value pair as integer . The use of this message is discouraged for normal packets but a quite efficient way for testing new messages and getting experimental debug output . | 72 | 34 |
229,025 | def debug_send ( self , time_boot_ms , ind , value , force_mavlink1 = False ) : return self . send ( self . debug_encode ( time_boot_ms , ind , value ) , force_mavlink1 = force_mavlink1 ) | Send a debug value . The index is used to discriminate between values . These values show up in the plot of QGroundControl as DEBUG N . | 64 | 29 |
229,026 | def sendVX ( self , vx ) : self . lock . acquire ( ) self . data . vx = vx self . lock . release ( ) | Sends VX velocity . | 34 | 6 |
229,027 | def sendVY ( self , vy ) : self . lock . acquire ( ) self . data . vy = vy self . lock . release ( ) | Sends VY velocity . | 34 | 6 |
229,028 | def sendAZ ( self , az ) : self . lock . acquire ( ) self . data . az = az self . lock . release ( ) | Sends AZ velocity . | 30 | 5 |
229,029 | def bumperEvent2BumperData ( event ) : bump = BumperData ( ) bump . state = event . state bump . bumper = event . bumper #bump.timeStamp = event.header.stamp.secs + (event.header.stamp.nsecs *1e-9) return bump | Translates from ROS BumperScan to JderobotTypes BumperData . | 69 | 18 |
229,030 | def __callback ( self , event ) : bump = bumperEvent2BumperData ( event ) if bump . state == 1 : self . lock . acquire ( ) self . time = current_milli_time ( ) self . data = bump self . lock . release ( ) | Callback function to receive and save Bumper Scans . | 58 | 11 |
229,031 | def getBumperData ( self ) : self . lock . acquire ( ) t = current_milli_time ( ) if ( t - self . time ) > 500 : self . data . state = 0 bump = self . data self . lock . release ( ) return bump | Returns last BumperData . | 58 | 6 |
229,032 | def cmd_bat ( self , args ) : print ( "Flight battery: %u%%" % self . battery_level ) if self . settings . numcells != 0 : print ( "%.2f V/cell for %u cells - approx %u%%" % ( self . per_cell , self . settings . numcells , self . vcell_to_battery_percent ( self . per_cell ) ) ) | show battery levels | 91 | 3 |
229,033 | def battery_update ( self , SYS_STATUS ) : # main flight battery self . battery_level = SYS_STATUS . battery_remaining self . voltage_level = SYS_STATUS . voltage_battery self . current_battery = SYS_STATUS . current_battery if self . settings . numcells != 0 : self . per_cell = ( self . voltage_level * 0.001 ) / self . settings . numcells | update battery level | 101 | 3 |
229,034 | def cmd_accelcal ( self , args ) : mav = self . master # ack the APM to begin 3D calibration of accelerometers mav . mav . command_long_send ( mav . target_system , mav . target_component , mavutil . mavlink . MAV_CMD_PREFLIGHT_CALIBRATION , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 ) self . accelcal_count = 0 self . accelcal_wait_enter = False | do a full 3D accel calibration | 118 | 8 |
229,035 | def cmd_gyrocal ( self , args ) : mav = self . master mav . mav . command_long_send ( mav . target_system , mav . target_component , mavutil . mavlink . MAV_CMD_PREFLIGHT_CALIBRATION , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 ) | do a full gyro calibration | 83 | 6 |
229,036 | def cmd_magcal ( self , args ) : if len ( args ) < 1 : print ( "Usage: magcal <start|accept|cancel>" ) return if args [ 0 ] == 'start' : self . master . mav . command_long_send ( self . settings . target_system , # target_system 0 , # target_component mavutil . mavlink . MAV_CMD_DO_START_MAG_CAL , # command 0 , # confirmation 0 , # p1: mag_mask 0 , # p2: retry 1 , # p3: autosave 0 , # p4: delay 0 , # param5 0 , # param6 0 ) # param7 elif args [ 0 ] == 'accept' : self . master . mav . command_long_send ( self . settings . target_system , # target_system 0 , # target_component mavutil . mavlink . MAV_CMD_DO_ACCEPT_MAG_CAL , # command 0 , # confirmation 0 , # p1: mag_mask 0 , # param2 1 , # param3 0 , # param4 0 , # param5 0 , # param6 0 ) # param7 elif args [ 0 ] == 'cancel' : self . master . mav . command_long_send ( self . settings . target_system , # target_system 0 , # target_component mavutil . mavlink . MAV_CMD_DO_CANCEL_MAG_CAL , # command 0 , # confirmation 0 , # p1: mag_mask 0 , # param2 1 , # param3 0 , # param4 0 , # param5 0 , # param6 0 ) | control magnetometer calibration | 375 | 4 |
229,037 | def set_fence_enabled ( self , do_enable ) : self . master . mav . command_long_send ( self . target_system , self . target_component , mavutil . mavlink . MAV_CMD_DO_FENCE_ENABLE , 0 , do_enable , 0 , 0 , 0 , 0 , 0 , 0 ) | Enable or disable fence | 80 | 4 |
229,038 | def cmd_fence_move ( self , args ) : if len ( args ) < 1 : print ( "Usage: fence move FENCEPOINTNUM" ) return if not self . have_list : print ( "Please list fence points first" ) return idx = int ( args [ 0 ] ) if idx <= 0 or idx > self . fenceloader . count ( ) : print ( "Invalid fence point number %u" % idx ) 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 # note we don't subtract 1, as first fence point is the return point self . fenceloader . move ( idx , latlon [ 0 ] , latlon [ 1 ] ) if self . send_fence ( ) : print ( "Moved fence point %u" % idx ) | handle fencepoint move | 206 | 4 |
229,039 | def cmd_fence_remove ( self , args ) : if len ( args ) < 1 : print ( "Usage: fence remove FENCEPOINTNUM" ) return if not self . have_list : print ( "Please list fence points first" ) return idx = int ( args [ 0 ] ) if idx <= 0 or idx > self . fenceloader . count ( ) : print ( "Invalid fence point number %u" % idx ) return # note we don't subtract 1, as first fence point is the return point self . fenceloader . remove ( idx ) if self . send_fence ( ) : print ( "Removed fence point %u" % idx ) else : print ( "Failed to remove fence point %u" % idx ) | handle fencepoint remove | 165 | 4 |
229,040 | def send_fence ( self ) : # must disable geo-fencing when loading self . fenceloader . target_system = self . target_system self . fenceloader . target_component = self . target_component self . fenceloader . reindex ( ) action = self . get_mav_param ( 'FENCE_ACTION' , mavutil . mavlink . FENCE_ACTION_NONE ) self . param_set ( 'FENCE_ACTION' , mavutil . mavlink . FENCE_ACTION_NONE , 3 ) self . param_set ( 'FENCE_TOTAL' , self . fenceloader . count ( ) , 3 ) for i in range ( self . fenceloader . count ( ) ) : p = self . fenceloader . point ( i ) self . master . mav . send ( p ) p2 = self . fetch_fence_point ( i ) if p2 is None : self . param_set ( 'FENCE_ACTION' , action , 3 ) return False if ( p . idx != p2 . idx or abs ( p . lat - p2 . lat ) >= 0.00003 or abs ( p . lng - p2 . lng ) >= 0.00003 ) : print ( "Failed to send fence point %u" % i ) self . param_set ( 'FENCE_ACTION' , action , 3 ) return False self . param_set ( 'FENCE_ACTION' , action , 3 ) return True | send fence points from fenceloader | 324 | 6 |
229,041 | def fetch_fence_point ( self , i ) : self . master . mav . fence_fetch_point_send ( self . target_system , self . target_component , i ) tstart = time . time ( ) p = None while time . time ( ) - tstart < 3 : p = self . master . recv_match ( type = 'FENCE_POINT' , blocking = False ) if p is not None : break time . sleep ( 0.1 ) continue if p is None : self . console . error ( "Failed to fetch point %u" % i ) return None return p | fetch one fence point | 134 | 5 |
229,042 | def fence_draw_callback ( self , points ) : self . fenceloader . clear ( ) if len ( points ) < 3 : return self . fenceloader . target_system = self . target_system self . fenceloader . target_component = self . target_component bounds = mp_util . polygon_bounds ( points ) ( lat , lon , width , height ) = bounds center = ( lat + width / 2 , lon + height / 2 ) self . fenceloader . add_latlon ( center [ 0 ] , center [ 1 ] ) for p in points : self . fenceloader . add_latlon ( p [ 0 ] , p [ 1 ] ) # close it self . fenceloader . add_latlon ( points [ 0 ] [ 0 ] , points [ 0 ] [ 1 ] ) self . send_fence ( ) self . have_list = True | callback from drawing a fence | 188 | 5 |
229,043 | def add_menu ( self , menu ) : self . menu . add ( menu ) self . mpstate . console . set_menu ( self . menu , self . menu_callback ) | add a new menu | 39 | 4 |
229,044 | def estimated_time_remaining ( self , lat , lon , wpnum , speed ) : idx = wpnum if wpnum >= self . module ( 'wp' ) . wploader . count ( ) : return 0 distance = 0 done = set ( ) while idx < self . module ( 'wp' ) . wploader . count ( ) : if idx in done : break done . add ( idx ) w = self . module ( 'wp' ) . wploader . wp ( idx ) if w . command == mavutil . mavlink . MAV_CMD_DO_JUMP : idx = int ( w . param1 ) continue idx += 1 if ( w . x != 0 or w . y != 0 ) and w . command in [ mavutil . mavlink . MAV_CMD_NAV_WAYPOINT , mavutil . mavlink . MAV_CMD_NAV_LOITER_UNLIM , mavutil . mavlink . MAV_CMD_NAV_LOITER_TURNS , mavutil . mavlink . MAV_CMD_NAV_LOITER_TIME , mavutil . mavlink . MAV_CMD_NAV_LAND , mavutil . mavlink . MAV_CMD_NAV_TAKEOFF ] : distance += mp_util . gps_distance ( lat , lon , w . x , w . y ) lat = w . x lon = w . y if w . command == mavutil . mavlink . MAV_CMD_NAV_LAND : break return distance / speed | estimate time remaining in mission in seconds | 375 | 8 |
229,045 | def angle ( self , v ) : return acos ( ( self * v ) / ( self . length ( ) * v . length ( ) ) ) | return the angle between this vector and another vector | 32 | 9 |
229,046 | def from_euler ( self , roll , pitch , yaw ) : cp = cos ( pitch ) sp = sin ( pitch ) sr = sin ( roll ) cr = cos ( roll ) sy = sin ( yaw ) cy = cos ( yaw ) self . a . x = cp * cy self . a . y = ( sr * sp * cy ) - ( cr * sy ) self . a . z = ( cr * sp * cy ) + ( sr * sy ) self . b . x = cp * sy self . b . y = ( sr * sp * sy ) + ( cr * cy ) self . b . z = ( cr * sp * sy ) - ( sr * cy ) self . c . x = - sp self . c . y = sr * cp self . c . z = cr * cp | fill the matrix from Euler angles in radians | 174 | 10 |
229,047 | def from_euler312 ( self , roll , pitch , yaw ) : c3 = cos ( pitch ) s3 = sin ( pitch ) s2 = sin ( roll ) c2 = cos ( roll ) s1 = sin ( yaw ) c1 = cos ( yaw ) self . a . x = c1 * c3 - s1 * s2 * s3 self . b . y = c1 * c2 self . c . z = c3 * c2 self . a . y = - c2 * s1 self . a . z = s3 * c1 + c3 * s2 * s1 self . b . x = c3 * s1 + s3 * s2 * c1 self . b . z = s1 * s3 - s2 * c1 * c3 self . c . x = - s3 * c2 self . c . y = s2 | fill the matrix from Euler angles in radians in 312 convention | 195 | 13 |
229,048 | def rotate ( self , g ) : temp_matrix = Matrix3 ( ) a = self . a b = self . b c = self . c temp_matrix . a . x = a . y * g . z - a . z * g . y temp_matrix . a . y = a . z * g . x - a . x * g . z temp_matrix . a . z = a . x * g . y - a . y * g . x temp_matrix . b . x = b . y * g . z - b . z * g . y temp_matrix . b . y = b . z * g . x - b . x * g . z temp_matrix . b . z = b . x * g . y - b . y * g . x temp_matrix . c . x = c . y * g . z - c . z * g . y temp_matrix . c . y = c . z * g . x - c . x * g . z temp_matrix . c . z = c . x * g . y - c . y * g . x self . a += temp_matrix . a self . b += temp_matrix . b self . c += temp_matrix . c | rotate the matrix by a given amount on 3 axes | 278 | 11 |
229,049 | def normalize ( self ) : error = self . a * self . b t0 = self . a - ( self . b * ( 0.5 * error ) ) t1 = self . b - ( self . a * ( 0.5 * error ) ) t2 = t0 % t1 self . a = t0 * ( 1.0 / t0 . length ( ) ) self . b = t1 * ( 1.0 / t1 . length ( ) ) self . c = t2 * ( 1.0 / t2 . length ( ) ) | re - normalise a rotation matrix | 121 | 7 |
229,050 | def trace ( self ) : return self . a . x + self . b . y + self . c . z | the trace of the matrix | 24 | 5 |
229,051 | def from_axis_angle ( self , axis , angle ) : ux = axis . x uy = axis . y uz = axis . z ct = cos ( angle ) st = sin ( angle ) self . a . x = ct + ( 1 - ct ) * ux ** 2 self . a . y = ux * uy * ( 1 - ct ) - uz * st self . a . z = ux * uz * ( 1 - ct ) + uy * st self . b . x = uy * ux * ( 1 - ct ) + uz * st self . b . y = ct + ( 1 - ct ) * uy ** 2 self . b . z = uy * uz * ( 1 - ct ) - ux * st self . c . x = uz * ux * ( 1 - ct ) - uy * st self . c . y = uz * uy * ( 1 - ct ) + ux * st self . c . z = ct + ( 1 - ct ) * uz ** 2 | create a rotation matrix from axis and angle | 243 | 8 |
229,052 | def from_two_vectors ( self , vec1 , vec2 ) : angle = vec1 . angle ( vec2 ) cross = vec1 % vec2 if cross . length ( ) == 0 : # the two vectors are colinear return self . from_euler ( 0 , 0 , angle ) cross . normalize ( ) return self . from_axis_angle ( cross , angle ) | get a rotation matrix from two vectors . This returns a rotation matrix which when applied to vec1 will produce a vector pointing in the same direction as vec2 | 84 | 31 |
229,053 | def plane_intersection ( self , plane , forward_only = False ) : l_dot_n = self . vector * plane . normal if l_dot_n == 0.0 : # line is parallel to the plane return None d = ( ( plane . point - self . point ) * plane . normal ) / l_dot_n if forward_only and d < 0 : return None return ( self . vector * d ) + self . point | return point where line intersects with a plane | 96 | 9 |
229,054 | def getRgbd ( self ) : img = Rgb ( ) if self . hasproxy ( ) : self . lock . acquire ( ) img = self . image self . lock . release ( ) return img | Returns last Rgbd . | 44 | 6 |
229,055 | def add_mavlink_packet ( self , msg ) : mtype = msg . get_type ( ) if mtype not in self . msg_types : return for i in range ( len ( self . fields ) ) : if mtype not in self . field_types [ i ] : continue f = self . fields [ i ] self . values [ i ] = mavutil . evaluate_expression ( f , self . state . master . messages ) if self . livegraph is not None : self . livegraph . add_values ( self . values ) | add data to the graph | 120 | 5 |
229,056 | def generate ( basename , xml ) : if basename . endswith ( '.js' ) : filename = basename else : filename = basename + '.js' msgs = [ ] enums = [ ] filelist = [ ] for x in xml : msgs . extend ( x . message ) enums . extend ( x . enum ) filelist . append ( os . path . basename ( x . filename ) ) for m in msgs : if xml [ 0 ] . little_endian : m . fmtstr = '<' else : m . fmtstr = '>' for f in m . ordered_fields : m . fmtstr += mavfmt ( f ) m . order_map = [ 0 ] * len ( m . fieldnames ) for i in range ( 0 , len ( m . fieldnames ) ) : m . order_map [ i ] = m . ordered_fieldnames . index ( m . fieldnames [ i ] ) print ( "Generating %s" % filename ) outf = open ( filename , "w" ) generate_preamble ( outf , msgs , filelist , xml [ 0 ] ) generate_enums ( outf , enums ) generate_message_ids ( outf , msgs ) generate_classes ( outf , msgs ) generate_mavlink_class ( outf , msgs , xml [ 0 ] ) generate_footer ( outf ) outf . close ( ) print ( "Generated %s OK" % filename ) | generate complete javascript implementation | 326 | 5 |
229,057 | def flight_modes ( logfile ) : print ( "Processing log %s" % filename ) mlog = mavutil . mavlink_connection ( filename ) mode = "" previous_mode = "" mode_start_timestamp = - 1 time_in_mode = { } previous_percent = - 1 seconds_per_percent = - 1 filesize = os . path . getsize ( filename ) while True : m = mlog . recv_match ( type = [ 'SYS_STATUS' , 'HEARTBEAT' , 'MODE' ] , condition = 'MAV.flightmode!="%s"' % mlog . flightmode ) if m is None : break print ( '%s MAV.flightmode=%-12s (MAV.timestamp=%u %u%%)' % ( time . asctime ( time . localtime ( m . _timestamp ) ) , mlog . flightmode , m . _timestamp , mlog . percent ) ) mode = mlog . flightmode if ( mode not in time_in_mode ) : time_in_mode [ mode ] = 0 if ( mode_start_timestamp == - 1 ) : mode_start_timestamp = m . _timestamp elif ( previous_mode != "" and previous_mode != mode ) : time_in_mode [ previous_mode ] = time_in_mode [ previous_mode ] + ( m . _timestamp - mode_start_timestamp ) #figure out how many seconds per percentage point so I can #caculate how many seconds for the final mode if ( seconds_per_percent == - 1 and previous_percent != - 1 and previous_percent != mlog . percent ) : seconds_per_percent = ( m . _timestamp - mode_start_timestamp ) / ( mlog . percent - previous_percent ) mode_start_timestamp = m . _timestamp previous_mode = mode previous_percent = mlog . percent #put a whitespace line before the per-mode report print ( ) print ( "Time per mode:" ) #need to get the time in the final mode if ( seconds_per_percent != - 1 ) : seconds_remaining = ( 100.0 - previous_percent ) * seconds_per_percent time_in_mode [ previous_mode ] = time_in_mode [ previous_mode ] + seconds_remaining total_flight_time = 0 for key , value in time_in_mode . iteritems ( ) : total_flight_time = total_flight_time + value for key , value in time_in_mode . iteritems ( ) : print ( '%-12s %s %.2f%%' % ( key , str ( datetime . timedelta ( seconds = int ( value ) ) ) , ( value / total_flight_time ) * 100.0 ) ) else : #can't print time in mode if only one mode during flight print ( previous_mode , " 100% of flight time" ) | show flight modes for a log file | 652 | 7 |
229,058 | def have_graph ( name ) : for g in mestate . graphs : if g . name == name : return True return False | return true if we have a graph of the given name | 27 | 11 |
229,059 | def expression_ok ( expression ) : expression_ok = True fields = expression . split ( ) for f in fields : try : if f . endswith ( ':2' ) : f = f [ : - 2 ] if mavutil . evaluate_expression ( f , mestate . status . msgs ) is None : expression_ok = False except Exception : expression_ok = False break return expression_ok | return True if an expression is OK with current messages | 88 | 10 |
229,060 | def load_graph_xml ( xml , filename , load_all = False ) : ret = [ ] try : root = objectify . fromstring ( xml ) except Exception : return [ ] if root . tag != 'graphs' : return [ ] if not hasattr ( root , 'graph' ) : return [ ] for g in root . graph : name = g . attrib [ 'name' ] expressions = [ e . text for e in g . expression ] if load_all : ret . append ( GraphDefinition ( name , e , g . description . text , expressions , filename ) ) continue if have_graph ( name ) : continue for e in expressions : if expression_ok ( e ) : ret . append ( GraphDefinition ( name , e , g . description . text , expressions , filename ) ) break return ret | load a graph from one xml string | 174 | 7 |
229,061 | def cmd_condition ( args ) : if len ( args ) == 0 : print ( "condition is: %s" % mestate . settings . condition ) return mestate . settings . condition = ' ' . join ( args ) if len ( mestate . settings . condition ) == 0 or mestate . settings . condition == 'clear' : mestate . settings . condition = None | control MAVExporer conditions | 80 | 6 |
229,062 | def ualberta_sys_status_send ( self , mode , nav_mode , pilot , force_mavlink1 = False ) : return self . send ( self . ualberta_sys_status_encode ( mode , nav_mode , pilot ) , force_mavlink1 = force_mavlink1 ) | System status specific to ualberta uav | 74 | 10 |
229,063 | def button_change_send ( self , time_boot_ms , last_change_ms , state , force_mavlink1 = False ) : return self . send ( self . button_change_encode ( time_boot_ms , last_change_ms , state ) , force_mavlink1 = force_mavlink1 ) | Report button state change | 76 | 4 |
229,064 | def convert_from_latlon_to_utm ( points = None , latitudes = None , longitudes = None , false_easting = None , false_northing = None ) : old_geo = Geo_reference ( ) utm_points = [ ] if points == None : assert len ( latitudes ) == len ( longitudes ) points = map ( None , latitudes , longitudes ) for point in points : zone , easting , northing = redfearn ( float ( point [ 0 ] ) , float ( point [ 1 ] ) , false_easting = false_easting , false_northing = false_northing ) new_geo = Geo_reference ( zone ) old_geo . reconcile_zones ( new_geo ) utm_points . append ( [ easting , northing ] ) return utm_points , old_geo . get_zone ( ) | Convert latitude and longitude data to UTM as a list of coordinates . | 198 | 16 |
229,065 | def dcm ( self ) : if self . _dcm is None : if self . _q is not None : # try to get dcm from q self . _dcm = self . _q_to_dcm ( self . q ) elif self . _euler is not None : # try to get get dcm from euler self . _dcm = self . _euler_to_dcm ( self . _euler ) return self . _dcm | Get the DCM | 103 | 4 |
229,066 | def lock_time ( logfile ) : print ( "Processing log %s" % filename ) mlog = mavutil . mavlink_connection ( filename ) locked = False start_time = 0.0 total_time = 0.0 t = None m = mlog . recv_match ( type = [ 'GPS_RAW_INT' , 'GPS_RAW' ] , condition = args . condition ) if m is None : return 0 unlock_time = time . mktime ( time . localtime ( m . _timestamp ) ) while True : m = mlog . recv_match ( type = [ 'GPS_RAW_INT' , 'GPS_RAW' ] , condition = args . condition ) if m is None : if locked : total_time += time . mktime ( t ) - start_time if total_time > 0 : print ( "Lock time : %u:%02u" % ( int ( total_time ) / 60 , int ( total_time ) % 60 ) ) return total_time t = time . localtime ( m . _timestamp ) if m . fix_type >= 2 and not locked : print ( "Locked at %s after %u seconds" % ( time . asctime ( t ) , time . mktime ( t ) - unlock_time ) ) locked = True start_time = time . mktime ( t ) elif m . fix_type == 1 and locked : print ( "Lost GPS lock at %s" % time . asctime ( t ) ) locked = False total_time += time . mktime ( t ) - start_time unlock_time = time . mktime ( t ) elif m . fix_type == 0 and locked : print ( "Lost protocol lock at %s" % time . asctime ( t ) ) locked = False total_time += time . mktime ( t ) - start_time unlock_time = time . mktime ( t ) return total_time | work out gps lock times for a log file | 429 | 10 |
229,067 | def on_menu ( self , event ) : state = self . state # see if it is a popup menu if state . popup_object is not None : obj = state . popup_object ret = obj . popup_menu . find_selected ( event ) if ret is not None : ret . call_handler ( ) state . event_queue . put ( SlipMenuEvent ( state . popup_latlon , event , [ SlipObjectSelection ( obj . key , 0 , obj . layer , obj . selection_info ( ) ) ] , ret ) ) state . popup_object = None state . popup_latlon = None if state . default_popup is not None : ret = state . default_popup . popup . find_selected ( event ) if ret is not None : ret . call_handler ( ) state . event_queue . put ( SlipMenuEvent ( state . popup_latlon , event , [ ] , ret ) ) # otherwise a normal menu ret = self . menu . find_selected ( event ) if ret is None : return ret . call_handler ( ) if ret . returnkey == 'toggleGrid' : state . grid = ret . IsChecked ( ) elif ret . returnkey == 'toggleFollow' : state . follow = ret . IsChecked ( ) elif ret . returnkey == 'toggleDownload' : state . download = ret . IsChecked ( ) elif ret . returnkey == 'setService' : state . mt . set_service ( ret . get_choice ( ) ) elif ret . returnkey == 'gotoPosition' : state . panel . enter_position ( ) elif ret . returnkey == 'increaseBrightness' : state . brightness *= 1.25 elif ret . returnkey == 'decreaseBrightness' : state . brightness /= 1.25 state . need_redraw = True | handle menu selection | 401 | 3 |
229,068 | def follow ( self , object ) : state = self . state ( px , py ) = state . panel . pixmapper ( object . latlon ) ratio = 0.25 if ( px > ratio * state . width and px < ( 1.0 - ratio ) * state . width and py > ratio * state . height and py < ( 1.0 - ratio ) * state . height ) : # we're in the mid part of the map already, don't move return if not state . follow : # the user has disabled following return ( lat , lon ) = object . latlon state . panel . re_center ( state . width / 2 , state . height / 2 , lat , lon ) | follow an object on the map | 153 | 6 |
229,069 | def add_object ( self , obj ) : 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 | add an object to a later | 64 | 6 |
229,070 | def remove_object ( self , key ) : state = self . state for layer in state . layers : state . layers [ layer ] . pop ( key , None ) state . need_redraw = True | remove an object by key from all layers | 43 | 8 |
229,071 | def current_view ( self ) : state = self . state return ( state . lat , state . lon , state . width , state . height , state . ground_width , state . mt . tiles_pending ( ) ) | return a tuple representing the current view | 49 | 7 |
229,072 | def coordinates ( self , x , y ) : state = self . state return state . mt . coord_from_area ( x , y , state . lat , state . lon , state . width , state . ground_width ) | return coordinates of a pixel in the map | 49 | 8 |
229,073 | def re_center ( self , x , y , lat , lon ) : state = self . state if lat is None or lon is None : return ( lat2 , lon2 ) = self . coordinates ( x , y ) distance = mp_util . gps_distance ( lat2 , lon2 , lat , lon ) bearing = mp_util . gps_bearing ( lat2 , lon2 , lat , lon ) ( state . lat , state . lon ) = mp_util . gps_newpos ( state . lat , state . lon , bearing , distance ) | re - center view for pixel x y | 130 | 8 |
229,074 | def change_zoom ( self , zoom ) : state = self . state if self . mouse_pos : ( x , y ) = ( self . mouse_pos . x , self . mouse_pos . y ) else : ( x , y ) = ( state . width / 2 , state . height / 2 ) ( lat , lon ) = self . coordinates ( x , y ) state . ground_width *= zoom # limit ground_width to sane values state . ground_width = max ( state . ground_width , 20 ) state . ground_width = min ( state . ground_width , 20000000 ) self . re_center ( x , y , lat , lon ) | zoom in or out by zoom factor keeping centered | 146 | 10 |
229,075 | def enter_position ( self ) : state = self . state dlg = wx . TextEntryDialog ( self , 'Enter new position' , 'Position' ) dlg . SetValue ( "%f %f" % ( state . lat , state . lon ) ) if dlg . ShowModal ( ) == wx . ID_OK : latlon = dlg . GetValue ( ) . split ( ) dlg . Destroy ( ) state . lat = float ( latlon [ 0 ] ) state . lon = float ( latlon [ 1 ] ) self . re_center ( state . width / 2 , state . height / 2 , state . lat , state . lon ) self . redraw_map ( ) | enter new position | 160 | 3 |
229,076 | def update_position ( self ) : state = self . state pos = self . mouse_pos newtext = '' alt = 0 if pos is not None : ( lat , lon ) = self . coordinates ( pos . x , pos . y ) newtext += 'Cursor: %f %f (%s)' % ( lat , lon , mp_util . latlon_to_grid ( ( lat , lon ) ) ) if state . elevation : alt = self . ElevationMap . GetElevation ( lat , lon ) if alt is not None : newtext += ' %.1fm' % alt state . mt . set_download ( state . download ) pending = 0 if state . download : pending = state . mt . tiles_pending ( ) if pending : newtext += ' Map Downloading %u ' % pending if alt == - 1 : newtext += ' SRTM Downloading ' newtext += '\n' if self . click_pos is not None : newtext += 'Click: %f %f (%s %s) (%s)' % ( self . click_pos [ 0 ] , self . click_pos [ 1 ] , mp_util . degrees_to_dms ( self . click_pos [ 0 ] ) , mp_util . degrees_to_dms ( self . click_pos [ 1 ] ) , mp_util . latlon_to_grid ( self . click_pos ) ) if self . last_click_pos is not None : distance = mp_util . gps_distance ( self . last_click_pos [ 0 ] , self . last_click_pos [ 1 ] , self . click_pos [ 0 ] , self . click_pos [ 1 ] ) bearing = mp_util . gps_bearing ( self . last_click_pos [ 0 ] , self . last_click_pos [ 1 ] , self . click_pos [ 0 ] , self . click_pos [ 1 ] ) newtext += ' Distance: %.1fm Bearing %.1f' % ( distance , bearing ) if newtext != state . oldtext : self . position . Clear ( ) self . position . WriteText ( newtext ) state . oldtext = newtext | update position text | 479 | 3 |
229,077 | def selected_objects ( self , pos ) : state = self . state selected = [ ] ( px , py ) = pos for layer in state . layers : for key in state . layers [ layer ] : obj = state . layers [ layer ] [ key ] distance = obj . clicked ( px , py ) if distance is not None : selected . append ( SlipObjectSelection ( key , distance , layer , extra_info = obj . selection_info ( ) ) ) selected . sort ( key = lambda c : c . distance ) return selected | return a list of matching objects for a position | 115 | 9 |
229,078 | def show_default_popup ( self , pos ) : state = self . state if state . default_popup . popup is not None : wx_menu = state . default_popup . popup . wx_menu ( ) state . frame . PopupMenu ( wx_menu , pos ) | show default popup menu | 66 | 4 |
229,079 | def clear_thumbnails ( self ) : state = self . state for l in state . layers : keys = state . layers [ l ] . keys ( ) [ : ] for key in keys : if ( isinstance ( state . layers [ l ] [ key ] , SlipThumbnail ) and not isinstance ( state . layers [ l ] [ key ] , SlipIcon ) ) : state . layers [ l ] . pop ( key ) | clear all thumbnails from the map | 89 | 7 |
229,080 | def on_key_down ( self , event ) : state = self . state # send all key events to the parent if self . mouse_pos : latlon = self . coordinates ( self . mouse_pos . x , self . mouse_pos . y ) selected = self . selected_objects ( self . mouse_pos ) state . event_queue . put ( SlipKeyEvent ( latlon , event , selected ) ) c = event . GetUniChar ( ) if c == ord ( '+' ) or ( c == ord ( '=' ) and event . ShiftDown ( ) ) : self . change_zoom ( 1.0 / 1.2 ) event . Skip ( ) elif c == ord ( '-' ) : self . change_zoom ( 1.2 ) event . Skip ( ) elif c == ord ( 'G' ) : self . enter_position ( ) event . Skip ( ) elif c == ord ( 'C' ) : self . clear_thumbnails ( ) event . Skip ( ) | handle keyboard input | 218 | 3 |
229,081 | def evaluate_expression ( expression , vars ) : try : v = eval ( expression , globals ( ) , vars ) except NameError : return None except ZeroDivisionError : return None return v | evaluation an expression | 43 | 4 |
229,082 | def compile_all ( ) : # print("Compiling for Qt: style.qrc -> style.rcc") # os.system("rcc style.qrc -o style.rcc") print ( "Compiling for PyQt4: style.qrc -> pyqt_style_rc.py" ) os . system ( "pyrcc4 -py3 style.qrc -o pyqt_style_rc.py" ) print ( "Compiling for PyQt5: style.qrc -> pyqt5_style_rc.py" ) os . system ( "pyrcc5 style.qrc -o pyqt5_style_rc.py" ) print ( "Compiling for PySide: style.qrc -> pyside_style_rc.py" ) os . system ( "pyside-rcc -py3 style.qrc -o pyside_style_rc.py" ) | Compile style . qrc using rcc pyside - rcc and pyrcc4 | 206 | 20 |
229,083 | def null_term ( str ) : idx = str . find ( "\0" ) if idx != - 1 : str = str [ : idx ] return str | null terminate a string | 36 | 4 |
229,084 | def DFReader_is_text_log ( filename ) : f = open ( filename ) ret = ( f . read ( 8000 ) . find ( 'FMT, ' ) != - 1 ) f . close ( ) return ret | return True if a file appears to be a valid text log | 48 | 12 |
229,085 | def get_msgbuf ( self ) : values = [ ] for i in range ( len ( self . fmt . columns ) ) : if i >= len ( self . fmt . msg_mults ) : continue mul = self . fmt . msg_mults [ i ] name = self . fmt . columns [ i ] if name == 'Mode' and 'ModeNum' in self . fmt . columns : name = 'ModeNum' v = self . __getattr__ ( name ) if mul is not None : v /= mul values . append ( v ) return struct . pack ( "BBB" , 0xA3 , 0x95 , self . fmt . type ) + struct . pack ( self . fmt . msg_struct , * values ) | create a binary message buffer for a message | 159 | 8 |
229,086 | def find_time_base ( self , gps , first_us_stamp ) : t = self . _gpsTimeToTime ( gps . GWk , gps . GMS ) self . set_timebase ( t - gps . TimeUS * 0.000001 ) # this ensures FMT messages get appropriate timestamp: self . timestamp = self . timebase + first_us_stamp * 0.000001 | work out time basis for the log - even newer style | 93 | 11 |
229,087 | def find_time_base ( self , gps , first_ms_stamp ) : t = self . _gpsTimeToTime ( gps . Week , gps . TimeMS ) self . set_timebase ( t - gps . T * 0.001 ) self . timestamp = self . timebase + first_ms_stamp * 0.001 | work out time basis for the log - new style | 79 | 10 |
229,088 | def find_time_base ( self , gps ) : t = gps . GPSTime * 1.0e-6 self . timebase = t - self . px4_timebase | work out time basis for the log - PX4 native | 43 | 12 |
229,089 | def gps_message_arrived ( self , m ) : # msec-style GPS message? gps_week = getattr ( m , 'Week' , None ) gps_timems = getattr ( m , 'TimeMS' , None ) if gps_week is None : # usec-style GPS message? gps_week = getattr ( m , 'GWk' , None ) gps_timems = getattr ( m , 'GMS' , None ) if gps_week is None : if getattr ( m , 'GPSTime' , None ) is not None : # PX4-style timestamp; we've only been called # because we were speculatively created in case no # better clock was found. return t = self . _gpsTimeToTime ( gps_week , gps_timems ) deltat = t - self . timebase if deltat <= 0 : return for type in self . counts_since_gps : rate = self . counts_since_gps [ type ] / deltat if rate > self . msg_rate . get ( type , 0 ) : self . msg_rate [ type ] = rate self . msg_rate [ 'IMU' ] = 50.0 self . timebase = t self . counts_since_gps = { } | adjust time base from GPS message | 290 | 6 |
229,090 | def _rewind ( self ) : self . messages = { 'MAV' : self } self . flightmode = "UNKNOWN" self . percent = 0 if self . clock : self . clock . rewind_event ( ) | reset state on rewind | 49 | 5 |
229,091 | def init_clock ( self ) : self . _rewind ( ) # speculatively create a gps clock in case we don't find anything # better gps_clock = DFReaderClock_gps_interpolated ( ) self . clock = gps_clock px4_msg_time = None px4_msg_gps = None gps_interp_msg_gps1 = None gps_interp_msg_gps2 = None first_us_stamp = None first_ms_stamp = None have_good_clock = False while True : m = self . recv_msg ( ) if m is None : break type = m . get_type ( ) if first_us_stamp is None : first_us_stamp = getattr ( m , "TimeUS" , None ) if first_ms_stamp is None and ( type != 'GPS' and type != 'GPS2' ) : # Older GPS messages use TimeMS for msecs past start # of gps week first_ms_stamp = getattr ( m , "TimeMS" , None ) if type == 'GPS' or type == 'GPS2' : if getattr ( m , "TimeUS" , 0 ) != 0 and getattr ( m , "GWk" , 0 ) != 0 : # everything-usec-timestamped self . init_clock_usec ( ) if not self . _zero_time_base : self . clock . find_time_base ( m , first_us_stamp ) have_good_clock = True break if getattr ( m , "T" , 0 ) != 0 and getattr ( m , "Week" , 0 ) != 0 : # GPS is msec-timestamped if first_ms_stamp is None : first_ms_stamp = m . T self . init_clock_msec ( ) if not self . _zero_time_base : self . clock . find_time_base ( m , first_ms_stamp ) have_good_clock = True break if getattr ( m , "GPSTime" , 0 ) != 0 : # px4-style-only px4_msg_gps = m if getattr ( m , "Week" , 0 ) != 0 : if gps_interp_msg_gps1 is not None and ( gps_interp_msg_gps1 . TimeMS != m . TimeMS or gps_interp_msg_gps1 . Week != m . Week ) : # we've received two distinct, non-zero GPS # packets without finding a decent clock to # use; fall back to interpolation. Q: should # we wait a few more messages befoe doing # this? self . init_clock_gps_interpolated ( gps_clock ) have_good_clock = True break gps_interp_msg_gps1 = m elif type == 'TIME' : '''only px4-style logs use TIME''' if getattr ( m , "StartTime" , None ) != None : px4_msg_time = m if px4_msg_time is not None and px4_msg_gps is not None : self . init_clock_px4 ( px4_msg_time , px4_msg_gps ) have_good_clock = True break # print("clock is " + str(self.clock)) if not have_good_clock : # we failed to find any GPS messages to set a time # base for usec and msec clocks. Also, not a # PX4-style log if first_us_stamp is not None : self . init_clock_usec ( ) elif first_ms_stamp is not None : self . init_clock_msec ( ) self . _rewind ( ) return | work out time basis for the log | 853 | 7 |
229,092 | def _set_time ( self , m ) : # really just left here for profiling m . _timestamp = self . timestamp if len ( m . _fieldnames ) > 0 and self . clock is not None : self . clock . set_message_timestamp ( m ) | set time for a message | 59 | 5 |
229,093 | def _add_msg ( self , m ) : type = m . get_type ( ) self . messages [ type ] = m if self . clock : self . clock . message_arrived ( m ) if type == 'MSG' : if m . Message . find ( "Rover" ) != - 1 : self . mav_type = mavutil . mavlink . MAV_TYPE_GROUND_ROVER elif m . Message . find ( "Plane" ) != - 1 : self . mav_type = mavutil . mavlink . MAV_TYPE_FIXED_WING elif m . Message . find ( "Copter" ) != - 1 : self . mav_type = mavutil . mavlink . MAV_TYPE_QUADROTOR elif m . Message . startswith ( "Antenna" ) : self . mav_type = mavutil . mavlink . MAV_TYPE_ANTENNA_TRACKER if type == 'MODE' : if isinstance ( m . Mode , str ) : self . flightmode = m . Mode . upper ( ) elif 'ModeNum' in m . _fieldnames : mapping = mavutil . mode_mapping_bynumber ( self . mav_type ) if mapping is not None and m . ModeNum in mapping : self . flightmode = mapping [ m . ModeNum ] else : self . flightmode = mavutil . mode_string_acm ( m . Mode ) if type == 'STAT' and 'MainState' in m . _fieldnames : self . flightmode = mavutil . mode_string_px4 ( m . MainState ) if type == 'PARM' and getattr ( m , 'Name' , None ) is not None : self . params [ m . Name ] = m . Value self . _set_time ( m ) | add a new message | 413 | 4 |
229,094 | def recv_match ( self , condition = None , type = None , blocking = False ) : if type is not None and not isinstance ( type , list ) : type = [ type ] while True : m = self . recv_msg ( ) if m is None : return None if type is not None and not m . get_type ( ) in type : continue if not mavutil . evaluate_condition ( condition , self . messages ) : continue return m | recv the next message that matches the given condition type can be a string or a list of strings | 99 | 20 |
229,095 | def param ( self , name , default = None ) : if not name in self . params : return default return self . params [ name ] | convenient function for returning an arbitrary MAVLink parameter with a default | 29 | 14 |
229,096 | def cpu_load_send ( self , sensLoad , ctrlLoad , batVolt , force_mavlink1 = False ) : return self . send ( self . cpu_load_encode ( sensLoad , ctrlLoad , batVolt ) , force_mavlink1 = force_mavlink1 ) | Sensor and DSC control loads . | 70 | 7 |
229,097 | def ctrl_srfc_pt_send ( self , target , bitfieldPt , force_mavlink1 = False ) : return self . send ( self . ctrl_srfc_pt_encode ( target , bitfieldPt ) , force_mavlink1 = force_mavlink1 ) | This message sets the control surfaces for selective passthrough mode . | 70 | 13 |
229,098 | def slugs_mobile_location_send ( self , target , latitude , longitude , force_mavlink1 = False ) : return self . send ( self . slugs_mobile_location_encode ( target , latitude , longitude ) , force_mavlink1 = force_mavlink1 ) | Transmits the last known position of the mobile GS to the UAV . Very relevant when Track Mobile is enabled | 68 | 22 |
229,099 | def slugs_configuration_camera_send ( self , target , idOrder , order , force_mavlink1 = False ) : return self . send ( self . slugs_configuration_camera_encode ( target , idOrder , order ) , force_mavlink1 = force_mavlink1 ) | Control for camara . | 70 | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.