idx
int64
0
63k
question
stringlengths
61
4.03k
target
stringlengths
6
1.23k
41,100
def battery_update ( self , SYS_STATUS ) : 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
41,101
def cmd_accelcal ( self , args ) : mav = self . master 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
41,102
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
41,103
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 , 0 , mavutil . mavlink . MAV_CMD_DO_START_MAG_CAL , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 ) elif args [ 0 ] == 'acce...
control magnetometer calibration
41,104
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
41,105
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 ...
handle fencepoint move
41,106
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 ) ret...
handle fencepoint remove
41,107
def send_fence ( self ) : 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 . mavl...
send fence points from fenceloader
41,108
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...
fetch one fence point
41,109
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 ...
callback from drawing a fence
41,110
def add_menu ( self , menu ) : self . menu . add ( menu ) self . mpstate . console . set_menu ( self . menu , self . menu_callback )
add a new menu
41,111
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 . w...
estimate time remaining in mission in seconds
41,112
def angle ( self , v ) : return acos ( ( self * v ) / ( self . length ( ) * v . length ( ) ) )
return the angle between this vector and another vector
41,113
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 * ...
fill the matrix from Euler angles in radians
41,114
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 = ...
fill the matrix from Euler angles in radians in 312 convention
41,115
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 =...
rotate the matrix by a given amount on 3 axes
41,116
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
41,117
def trace ( self ) : return self . a . x + self . b . y + self . c . z
the trace of the matrix
41,118
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 = ...
create a rotation matrix from axis and angle
41,119
def from_two_vectors ( self , vec1 , vec2 ) : angle = vec1 . angle ( vec2 ) cross = vec1 % vec2 if cross . length ( ) == 0 : 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
41,120
def plane_intersection ( self , plane , forward_only = False ) : l_dot_n = self . vector * plane . normal if l_dot_n == 0.0 : 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
41,121
def getRgbd ( self ) : img = Rgb ( ) if self . hasproxy ( ) : self . lock . acquire ( ) img = self . image self . lock . release ( ) return img
Returns last Rgbd .
41,122
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 )...
add data to the graph
41,123
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 [ ...
generate complete javascript implementation
41,124
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_ma...
show flight modes for a log file
41,125
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
41,126
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
41,127
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 . ...
load a graph from one xml string
41,128
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
41,129
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
41,130
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
41,131
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 : zo...
Convert latitude and longitude data to UTM as a list of coordinates .
41,132
def dcm ( self ) : if self . _dcm is None : if self . _q is not None : self . _dcm = self . _q_to_dcm ( self . q ) elif self . _euler is not None : self . _dcm = self . _euler_to_dcm ( self . _euler ) return self . _dcm
Get the DCM
41,133
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 . mktim...
work out gps lock times for a log file
41,134
def on_menu ( self , event ) : state = self . state 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 ,...
handle menu selection
41,135
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
41,136
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
41,137
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
41,138
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
41,139
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
41,140
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
41,141
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
41,142
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
41,143
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
41,144
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
41,145
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
41,146
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
41,147
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
41,148
def evaluate_expression ( expression , vars ) : try : v = eval ( expression , globals ( ) , vars ) except NameError : return None except ZeroDivisionError : return None return v
evaluation an expression
41,149
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
41,150
def null_term ( str ) : idx = str . find ( "\0" ) if idx != - 1 : str = str [ : idx ] return str
null terminate a string
41,151
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
41,152
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
41,153
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
41,154
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
41,155
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
41,156
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
41,157
def _rewind ( self ) : self . messages = { 'MAV' : self } self . flightmode = "UNKNOWN" self . percent = 0 if self . clock : self . clock . rewind_event ( )
reset state on rewind
41,158
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
41,159
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
41,160
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
41,161
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
41,162
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
41,163
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 .
41,164
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 .
41,165
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
41,166
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 .
41,167
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
41,168
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
41,169
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 .
41,170
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 .
41,171
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 .
41,172
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
41,173
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 .
41,174
def getPose3d ( self ) : self . lock . acquire ( ) pose = self . pose self . lock . release ( ) return pose
Returns last Pose3d .
41,175
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 .
41,176
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
41,177
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 .
41,178
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 .
41,179
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 .
41,180
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 .
41,181
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 .
41,182
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
41,183
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
41,184
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
41,185
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
41,186
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
41,187
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
41,188
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 .
41,189
def close ( self ) : self . close_event . set ( ) if self . is_alive ( ) : self . child . join ( 2 )
close the console
41,190
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
41,191
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
41,192
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
41,193
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
41,194
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
41,195
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
41,196
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
41,197
def getBumper ( self ) : if self . hasproxy ( ) : self . lock . acquire ( ) bumper = self . bumper self . lock . release ( ) return bumper return None
Returns last Bumper .
41,198
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 .
41,199
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 .