idx
int64
0
252k
question
stringlengths
48
5.28k
target
stringlengths
5
1.23k
230,000
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 ) : return if not state . follow : return ( lat ...
follow an object on the map
230,001
def add_object ( self , obj ) : state = self . state if not obj . layer in state . layers : state . layers [ obj . layer ] = { } state . layers [ obj . layer ] [ obj . key ] = obj state . need_redraw = True
add an object to a later
230,002
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
230,003
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
230,004
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
230,005
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_...
re - center view for pixel x y
230,006
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 state . ground_width = max ( state . ground_wid...
zoom in or out by zoom factor keeping centered
230,007
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 ] ) stat...
enter new position
230,008
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 . Ge...
update position text
230,009
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 ,...
return a list of matching objects for a position
230,010
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
230,011
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
230,012
def on_key_down ( self , event ) : state = self . state 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 == or...
handle keyboard input
230,013
def evaluate_expression ( expression , vars ) : try : v = eval ( expression , globals ( ) , vars ) except NameError : return None except ZeroDivisionError : return None return v
evaluation an expression
230,014
def compile_all ( ) : 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_styl...
Compile style . qrc using rcc pyside - rcc and pyrcc4
230,015
def null_term ( str ) : idx = str . find ( "\0" ) if idx != - 1 : str = str [ : idx ] return str
null terminate a string
230,016
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
230,017
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 mu...
create a binary message buffer for a message
230,018
def find_time_base ( self , gps , first_us_stamp ) : t = self . _gpsTimeToTime ( gps . GWk , gps . GMS ) self . set_timebase ( t - gps . TimeUS * 0.000001 ) self . timestamp = self . timebase + first_us_stamp * 0.000001
work out time basis for the log - even newer style
230,019
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
230,020
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
230,021
def gps_message_arrived ( self , m ) : gps_week = getattr ( m , 'Week' , None ) gps_timems = getattr ( m , 'TimeMS' , None ) if gps_week is None : 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 : return t = self . _...
adjust time base from GPS message
230,022
def _rewind ( self ) : self . messages = { 'MAV' : self } self . flightmode = "UNKNOWN" self . percent = 0 if self . clock : self . clock . rewind_event ( )
reset state on rewind
230,023
def init_clock ( self ) : self . _rewind ( ) 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 ...
work out time basis for the log
230,024
def _set_time ( self , m ) : 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
230,025
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 =...
add a new message
230,026
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 ( con...
recv the next message that matches the given condition type can be a string or a list of strings
230,027
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
230,028
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 .
230,029
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 .
230,030
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
230,031
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 .
230,032
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
230,033
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
230,034
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 .
230,035
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 .
230,036
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 .
230,037
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
230,038
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 , ...
Updates Pose3d .
230,039
def getPose3d ( self ) : self . lock . acquire ( ) pose = self . pose self . lock . release ( ) return pose
Returns last Pose3d .
230,040
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 .
230,041
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 , ...
kill speech dispatcher processs
230,042
def loadFileList ( self ) : try : data = open ( self . filelist_file , 'rb' ) except IOError : 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 : s...
Load a previously created file list or create a new one if none is available .
230,043
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 .
230,044
def calcOffset ( self , x , y ) : return x + self . size * ( self . size - y - 1 )
Calculate offset into data array . Only uses to test correctness of the formula .
230,045
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 ) offset = x + self . size * ( self . size - y - 1 ) value = self . data [ offset ] if value == - 32768 : return - 1 return value
Get the value of a pixel from the data handling voids in the SRTM data .
230,046
def getAltitudeFromLatLon ( self , lat , lon ) : lat -= self . lat lon -= self . lon 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 ) x_int = int ( x ) x_frac = x - i...
Get the altitude of a lat lon pair using the four neighbouring pixels for interpolation .
230,047
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
230,048
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 ==...
set a parameter on a mavlink connection
230,049
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 ...
save parameters to a file
230,050
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 ( ','...
load parameters from a file
230,051
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...
show differences with another parameter file
230,052
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
230,053
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 , ...
Sends up to 20 raw float values .
230,054
def close ( self ) : self . close_event . set ( ) if self . is_alive ( ) : self . child . join ( 2 )
close the console
230,055
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 ...
handle rally add
230,056
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 nu...
handle rally alt change
230,057
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...
handle rally move
230,058
def cmd_rally ( self , args ) : 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 point commands
230,059
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 . resu...
handle incoming mavlink packet
230,060
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
230,061
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
230,062
def getBumper ( self ) : if self . hasproxy ( ) : self . lock . acquire ( ) bumper = self . bumper self . lock . release ( ) return bumper return None
Returns last Bumper .
230,063
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...
Translates from ROS Image to JderobotTypes Image .
230,064
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 .
230,065
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 .
230,066
def getRgbdData ( self ) : self . lock . acquire ( ) data = self . data self . lock . release ( ) return data
Returns last RgbdData .
230,067
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
230,068
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
230,069
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
230,070
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
230,071
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
230,072
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
230,073
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 .
230,074
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
230,075
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
230,076
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
230,077
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
230,078
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
230,079
def rpm_send ( self , rpm1 , rpm2 , force_mavlink1 = False ) : return self . send ( self . rpm_encode ( rpm1 , rpm2 ) , force_mavlink1 = force_mavlink1 )
RPM sensor output
230,080
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 (...
convert a value from one set of units to another
230,081
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
230,082
def variables ( self ) : return sorted ( list ( self . mapping . vars . keys ( ) ) , key = lambda v : self . mapping . vars [ v ] . index )
return a list of available variables
230,083
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 ....
get a variable value
230,084
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 . m...
set a variable value
230,085
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
230,086
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
230,087
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 .
230,088
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 .
230,089
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 . yaw = quat2Yaw ( ori . w , ori . x , ori . y , ori . z ) pose . pitch = quat2Pitch ( ori ....
Translates from ROS Odometry to JderobotTypes Pose3d .
230,090
def __callback ( self , odom ) : pose = odometry2Pose3D ( odom ) self . lock . acquire ( ) self . data = pose self . lock . release ( )
Callback function to receive and save Pose3d .
230,091
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
230,092
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
230,093
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 ) **...
see if the polygon has been clicked on . Consider it clicked if the pixel is within 6 of the point
230,094
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
230,095
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
230,096
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 ( (...
calculate and set text size handling multi - line
230,097
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
230,098
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 [ ...
add a button
230,099
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 , '...
find the next valid message