INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Send packets to UAV in idle loop | def idle_send_acks_and_nacks(self):
'''Send packets to UAV in idle loop'''
max_blocks_to_send = 10
blocks_sent = 0
i=0
now = time.time()
while i < len(self.blocks_to_ack_and_nack) and blocks_sent < max_blocks_to_send:
# print("ACKLIST: %s" % ([x[1] for x in sel... |
handle REMOTE_LOG_DATA_BLOCK packets | def mavlink_packet(self, m):
'''handle REMOTE_LOG_DATA_BLOCK packets'''
now = time.time()
if m.get_type() == 'REMOTE_LOG_DATA_BLOCK':
if self.stopped:
# send a stop packet every second until the other end gets the idea:
if now - self.time_last_stop_pac... |
state of APM memory
brkval : heap top (uint16_t)
freemem : free memory (uint16_t) | def meminfo_send(self, brkval, freemem, force_mavlink1=False):
'''
state of APM memory
brkval : heap top (uint16_t)
freemem : free memory (uint16_t)
'''
return self.send(self.meminfo_en... |
return true if m is older than lastm by timestamp | def older_message(m, lastm):
'''return true if m is older than lastm by timestamp'''
atts = {'time_boot_ms' : 1.0e-3,
'time_unix_usec' : 1.0e-6,
'time_usec' : 1.0e-6}
for a in atts.keys():
if hasattr(m, a):
mul = atts[a]
t1 = m.getattr(a) * mul
... |
process one logfile | def process(filename):
'''process one logfile'''
print("Processing %s" % filename)
mlog = mavutil.mavlink_connection(filename, notimestamps=args.notimestamps,
robust_parsing=args.robust)
ext = os.path.splitext(filename)[1]
isbin = ext in ['.bin', '.BIN']
i... |
handle an incoming mavlink packet | def mavlink_packet(self, m):
'''handle an incoming mavlink packet'''
if m.get_type() == 'LOG_ENTRY':
self.handle_log_entry(m)
elif m.get_type() == 'LOG_DATA':
self.handle_log_data(m) |
handling incoming log entry | def handle_log_entry(self, m):
'''handling incoming log entry'''
if m.time_utc == 0:
tstring = ''
else:
tstring = time.ctime(m.time_utc)
self.entries[m.id] = m
print("Log %u numLogs %u lastLog %u size %u %s" % (m.id, m.num_logs, m.last_log_num, m.size, ts... |
handling incoming log data | def handle_log_data(self, m):
'''handling incoming log data'''
if self.download_file is None:
return
# lose some data
# import random
# if random.uniform(0,1) < 0.05:
# print('dropping ', str(m))
# return
if m.ofs != self.download_ofs:
... |
handling missing incoming log data | def handle_log_data_missing(self):
'''handling missing incoming log data'''
if len(self.download_set) == 0:
return
highest = max(self.download_set)
diff = set(range(highest)).difference(self.download_set)
if len(diff) == 0:
self.master.mav.log_request_data... |
show download status | def log_status(self):
'''show download status'''
if self.download_filename is None:
print("No download")
return
dt = time.time() - self.download_start
speed = os.path.getsize(self.download_filename) / (1000.0 * dt)
m = self.entries.get(self.download_lognum... |
download a log file | def log_download(self, log_num, filename):
'''download a log file'''
print("Downloading log %u as %s" % (log_num, filename))
self.download_lognum = log_num
self.download_file = open(filename, "wb")
self.master.mav.log_request_data_send(self.target_system,
... |
log commands | def cmd_log(self, args):
'''log commands'''
if len(args) < 1:
print("usage: log <list|download|erase|resume|status|cancel>")
return
if args[0] == "status":
self.log_status()
if args[0] == "list":
print("Requesting log list")
se... |
handle missing log data | def idle_task(self):
'''handle missing log data'''
if self.download_last_timestamp is not None and time.time() - self.download_last_timestamp > 0.7:
self.download_last_timestamp = time.time()
self.handle_log_data_missing() |
complete mavproxy module names | def complete_modules(text):
'''complete mavproxy module names'''
import MAVProxy.modules, pkgutil
modlist = [x[1] for x in pkgutil.iter_modules(MAVProxy.modules.__path__)]
ret = []
loaded = set(complete_loadedmodules(''))
for m in modlist:
if not m.startswith("mavproxy_"):
co... |
complete a filename | def complete_filename(text):
'''complete a filename'''
#ensure directories have trailing slashes:
list = glob.glob(text+'*')
for idx, val in enumerate(list):
if os.path.isdir(val):
list[idx] = (val + os.path.sep)
return list |
complete a MAVLink variable | def complete_variable(text):
'''complete a MAVLink variable'''
if text.find('.') != -1:
var = text.split('.')[0]
if var in rline_mpstate.status.msgs:
ret = []
for f in rline_mpstate.status.msgs[var].get_fieldnames():
ret.append(var + '.' + f)
r... |
expand one rule component | def rule_expand(component, text):
'''expand one rule component'''
global rline_mpstate
if component[0] == '<' and component[-1] == '>':
return component[1:-1].split('|')
if component in rline_mpstate.completion_functions:
return rline_mpstate.completion_functions[component](text)
ret... |
see if one rule component matches | def rule_match(component, cmd):
'''see if one rule component matches'''
if component == cmd:
return True
expanded = rule_expand(component, cmd)
if cmd in expanded:
return True
return False |
complete using a list of completion rules | def complete_rules(rules, cmd):
'''complete using a list of completion rules'''
if not isinstance(rules, list):
rules = [rules]
ret = []
for r in rules:
ret += complete_rule(r, cmd)
return ret |
completion routine for when user presses tab | def complete(text, state):
'''completion routine for when user presses tab'''
global last_clist
global rline_mpstate
if state != 0 and last_clist is not None:
return last_clist[state]
# split the command so far
cmd = readline.get_line_buffer().split()
if len(cmd) == 1:
# if... |
Translates from ROS LaserScan to JderobotTypes LaserData.
@param scan: ROS LaserScan to translate
@type scan: LaserScan
@return a LaserData translated from scan | def laserScan2LaserData(scan):
'''
Translates from ROS LaserScan to JderobotTypes LaserData.
@param scan: ROS LaserScan to translate
@type scan: LaserScan
@return a LaserData translated from scan
'''
laser = LaserData()
laser.values = scan.ranges
'''
ROS Angle Map ... |
Callback function to receive and save Laser Scans.
@param scan: ROS LaserScan received
@type scan: LaserScan | def __callback (self, scan):
'''
Callback function to receive and save Laser Scans.
@param scan: ROS LaserScan received
@type scan: LaserScan
'''
laser = laserScan2LaserData(scan)
self.lock.acquire()
self.data = laser
self.lock.release... |
Starts (Subscribes) the client. | def start (self):
'''
Starts (Subscribes) the client.
'''
self.sub = rospy.Subscriber(self.topic, LaserScan, self.__callback) |
Returns last LaserData.
@return last JdeRobotTypes LaserData saved | def getLaserData(self):
'''
Returns last LaserData.
@return last JdeRobotTypes LaserData saved
'''
self.lock.acquire()
laser = self.data
self.lock.release()
return laser |
add a point to the kml file | def add_to_linestring(position_data, kml_linestring):
'''add a point to the kml file'''
global kml
# add altitude offset
position_data[2] += float(args.aoff)
kml_linestring.coords.addcoordinates([position_data]) |
add some data | def add_data(t, msg, msg_types, vars, fields, field_types, position_field_type):
'''add some data'''
mtype = msg.get_type()
if mtype not in msg_types:
return
for i in range(0, len(fields)):
if mtype not in field_types[i]:
continue
f = fields[i]
v = mavutil.e... |
process one file | def process_file(filename, source):
'''process one file'''
print("Processing %s" % filename)
mlog = mavutil.mavlink_connection(filename, notimestamps=args.notimestamps)
position_field_type = sniff_field_spelling(mlog, source)
# init fields and field_types lists
fields = [args.source + ... |
attempt to detect whether APM or PX4 attributes names are in use | def sniff_field_spelling(mlog, source):
'''attempt to detect whether APM or PX4 attributes names are in use'''
position_field_type_default = position_field_types[0] # Default to PX4 spelling
msg = mlog.recv_match(source)
mlog._rewind() # Unfortunately it's either call this or return a mutated objec... |
called on idle | def idle_task(self):
'''called on idle'''
if mp_util.has_wxpython and (not self.menu_added_console and self.module('console') is not None):
self.menu_added_console = True
# we don't dynamically update these yet due to a wx bug
self.menu_add.items = [ MPMenuItem(p, p, ... |
handle link commands | def cmd_link(self, args):
'''handle link commands'''
if len(args) < 1:
self.show_link()
elif args[0] == "list":
self.cmd_link_list()
elif args[0] == "add":
if len(args) != 2:
print("Usage: link add LINK")
return
... |
show link information | def show_link(self):
'''show link information'''
for master in self.mpstate.mav_master:
linkdelay = (self.status.highest_msec - master.highest_msec)*1.0e-3
if master.linkerror:
print("link %u down" % (master.linknum+1))
else:
print("lin... |
list links | def cmd_link_list(self):
'''list links'''
print("%u links" % len(self.mpstate.mav_master))
for i in range(len(self.mpstate.mav_master)):
conn = self.mpstate.mav_master[i]
print("%u: %s" % (i, conn.address)) |
add new link | def link_add(self, device):
'''add new link'''
try:
print("Connect %s source_system=%d" % (device, self.settings.source_system))
conn = mavutil.mavlink_connection(device, autoreconnect=True,
source_system=self.settings.source_system,
... |
add new link | def cmd_link_add(self, args):
'''add new link'''
device = args[0]
print("Adding link %s" % device)
self.link_add(device) |
show available ports | def cmd_link_ports(self):
'''show available ports'''
ports = mavutil.auto_detect_serial(preferred_list=['*FTDI*',"*Arduino_Mega_2560*", "*3D_Robotics*", "*USB_to_UART*", '*PX4*', '*FMU*'])
for p in ports:
print("%s : %s : %s" % (p.device, p.description, p.hwid)) |
process mavlink message m on master, sending any messages to recipients | def master_callback(self, m, master):
'''process mavlink message m on master, sending any messages to recipients'''
# see if it is handled by a specialised sysid connection
sysid = m.get_srcSystem()
if sysid in self.mpstate.sysid_outputs:
self.mpstate.sysid_outputs[sysid].wr... |
write to the console | def write(self, text, fg='black', bg='white'):
'''write to the console'''
if isinstance(text, str):
sys.stdout.write(text)
else:
sys.stdout.write(str(text))
sys.stdout.flush()
if self.udp.connected():
self.udp.writeln(text)
if self.tcp.... |
write to the console with linefeed | def writeln(self, text, fg='black', bg='white'):
'''write to the console with linefeed'''
if not isinstance(text, str):
text = str(text)
self.write(text + '\n', fg=fg, bg=bg) |
see if the path matches a extension | def match_extension(f):
'''see if the path matches a extension'''
(root,ext) = os.path.splitext(f)
return ext.lower() in extensions |
load an icon from the data directory | def mp_icon(filename):
'''load an icon from the data directory'''
# we have to jump through a lot of hoops to get an OpenCV image
# when we may be in a package zip file
try:
import pkg_resources
name = __name__
if name == "__main__":
... |
return lat,lon within a tile given (offsetx,offsety) | def coord(self, offset=(0,0)):
'''return lat,lon within a tile given (offsetx,offsety)'''
(tilex, tiley) = self.tile
(offsetx, offsety) = offset
world_tiles = 1<<self.zoom
x = ( tilex + 1.0*offsetx/TILES_WIDTH ) / (world_tiles/2.) - 1
y = ( tiley + 1.0*offsety/TILES_HEIGHT) / (world_tiles/2.) - 1
lon = x ... |
return tile size as (width,height) in meters | def size(self):
'''return tile size as (width,height) in meters'''
(lat1, lon1) = self.coord((0,0))
(lat2, lon2) = self.coord((TILES_WIDTH,0))
width = mp_util.gps_distance(lat1, lon1, lat2, lon2)
(lat2, lon2) = self.coord((0,TILES_HEIGHT))
height = mp_util.gps_distance(lat1, lon1, lat2, lon2)
return (widt... |
distance of this tile from a given lat/lon | def distance(self, lat, lon):
'''distance of this tile from a given lat/lon'''
(tlat, tlon) = self.coord((TILES_WIDTH/2,TILES_HEIGHT/2))
return mp_util.gps_distance(lat, lon, tlat, tlon) |
return relative path of tile image | def path(self):
'''return relative path of tile image'''
(x, y) = self.tile
return os.path.join('%u' % self.zoom,
'%u' % y,
'%u.img' % x) |
return URL for a tile | def url(self, service):
'''return URL for a tile'''
if service not in TILE_SERVICES:
raise TileException('unknown tile service %s' % service)
url = string.Template(TILE_SERVICES[service])
(x,y) = self.tile
tile_info = TileServiceInfo(x, y, self.zoom)
return url.substitute(tile_info) |
convert lat/lon/zoom to a TileInfo | def coord_to_tile(self, lat, lon, zoom):
'''convert lat/lon/zoom to a TileInfo'''
world_tiles = 1<<zoom
x = world_tiles / 360.0 * (lon + 180.0)
tiles_pre_radian = world_tiles / (2 * math.pi)
e = math.sin(lat * (1/180.*math.pi))
y = world_tiles/2 + 0.5*math.log((1+e)/(1-e)) * (-tiles_pre_radian)
offsetx = ... |
return full path to a tile | def tile_to_path(self, tile):
'''return full path to a tile'''
return os.path.join(self.cache_path, self.service, tile.path()) |
return the tile ID that covers a latitude/longitude at
a specified zoom level | def coord_to_tilepath(self, lat, lon, zoom):
'''return the tile ID that covers a latitude/longitude at
a specified zoom level
'''
tile = self.coord_to_tile(lat, lon, zoom)
return self.tile_to_path(tile) |
start the downloader | def start_download_thread(self):
'''start the downloader'''
if self._download_thread:
return
t = threading.Thread(target=self.downloader)
t.daemon = True
self._download_thread = t
t.start() |
load a lower resolution tile from cache to fill in a
map while waiting for a higher resolution tile | def load_tile_lowres(self, tile):
'''load a lower resolution tile from cache to fill in a
map while waiting for a higher resolution tile'''
if tile.zoom == self.min_zoom:
return None
# find the equivalent lower res tile
(lat,lon) = tile.coord()
width2 = TILES_WIDTH
height2 = TILES_HEIGHT
for zoom2... |
load a tile from cache or tile server | def load_tile(self, tile):
'''load a tile from cache or tile server'''
# see if its in the tile cache
key = tile.key()
if key in self._tile_cache:
img = self._tile_cache[key]
if img == self._unavailable:
img = self.load_tile_lowres(tile)
if img is None:
img = self._unavailable
return img... |
return a scaled tile | def scaled_tile(self, tile):
'''return a scaled tile'''
width = int(TILES_WIDTH / tile.scale)
height = int(TILES_HEIGHT / tile.scale)
scaled_tile = cv.CreateImage((width,height), 8, 3)
full_tile = self.load_tile(tile)
cv.Resize(full_tile, scaled_tile)
return scaled_tile |
return (lat,lon) for a pixel in an area image | def coord_from_area(self, x, y, lat, lon, width, ground_width):
'''return (lat,lon) for a pixel in an area image'''
pixel_width = ground_width / float(width)
dx = x * pixel_width
dy = y * pixel_width
return mp_util.gps_offset(lat, lon, dx, -dy) |
return pixel coordinate (px,py) for position (lat2,lon2)
in an area image. Note that the results are relative to top,left
and may be outside the image | def coord_to_pixel(self, lat, lon, width, ground_width, lat2, lon2):
'''return pixel coordinate (px,py) for position (lat2,lon2)
in an area image. Note that the results are relative to top,left
and may be outside the image'''
pixel_width = ground_width / float(width)
if lat is None or lon is None or lat2 is ... |
return a list of TileInfoScaled objects needed for
an area of land, with ground_width in meters, and
width/height in pixels.
lat/lon is the top left corner. If unspecified, the
zoom is automatically chosen to avoid having to grow
the tiles | def area_to_tile_list(self, lat, lon, width, height, ground_width, zoom=None):
'''return a list of TileInfoScaled objects needed for
an area of land, with ground_width in meters, and
width/height in pixels.
lat/lon is the top left corner. If unspecified, the
zoom is automatically chosen to avoid having to gr... |
return an RGB image for an area of land, with ground_width
in meters, and width/height in pixels.
lat/lon is the top left corner. The zoom is automatically
chosen to avoid having to grow the tiles | def area_to_image(self, lat, lon, width, height, ground_width, zoom=None, ordered=True):
'''return an RGB image for an area of land, with ground_width
in meters, and width/height in pixels.
lat/lon is the top left corner. The zoom is automatically
chosen to avoid having to grow the tiles'''
img = cv.CreateI... |
Run a shell command with a timeout.
See http://stackoverflow.com/questions/1191374/subprocess-with-timeout | def run_command(args, cwd = None, shell = False, timeout = None, env = None):
'''
Run a shell command with a timeout.
See http://stackoverflow.com/questions/1191374/subprocess-with-timeout
'''
from subprocess import PIPE, Popen
from StringIO import StringIO
import fcntl, os, signal
p = P... |
calculate barometric altitude | def altitude_difference(self, pressure1, pressure2, ground_temp):
'''calculate barometric altitude'''
scaling = pressure2 / pressure1
temp = ground_temp + 273.15
return 153.8462 * temp * (1.0 - math.exp(0.190259 * math.log(scaling))) |
estimate QNH pressure from GPS altitude and scaled pressure | def qnh_estimate(self):
'''estimate QNH pressure from GPS altitude and scaled pressure'''
alt_gps = self.master.field('GPS_RAW_INT', 'alt', 0) * 0.001
pressure2 = self.master.field('SCALED_PRESSURE', 'press_abs', 0)
ground_temp = self.get_mav_param('GND_TEMP', 21)
temp = ground_t... |
show altitude | def cmd_alt(self, args):
'''show altitude'''
print("Altitude: %.1f" % self.status.altitude)
qnh_pressure = self.get_mav_param('AFS_QNH_PRESSURE', None)
if qnh_pressure is not None and qnh_pressure > 0:
ground_temp = self.get_mav_param('GND_TEMP', 21)
pressure = s... |
adjust TRIM_PITCH_CD up by 5 degrees | def cmd_up(self, args):
'''adjust TRIM_PITCH_CD up by 5 degrees'''
if len(args) == 0:
adjust = 5.0
else:
adjust = float(args[0])
old_trim = self.get_mav_param('TRIM_PITCH_CD', None)
if old_trim is None:
print("Existing trim value unknown!")
... |
show autopilot time | def cmd_time(self, args):
'''show autopilot time'''
tusec = self.master.field('SYSTEM_TIME', 'time_unix_usec', 0)
if tusec == 0:
print("No SYSTEM_TIME time available")
return
print("%s (%s)\n" % (time.ctime(tusec * 1.0e-6), time.ctime())) |
change target altitude | def cmd_changealt(self, args):
'''change target altitude'''
if len(args) < 1:
print("usage: changealt <relaltitude>")
return
relalt = float(args[0])
self.master.mav.mission_item_send(self.settings.target_system,
self.setti... |
auto land commands | def cmd_land(self, args):
'''auto land commands'''
if len(args) < 1:
self.master.mav.command_long_send(self.settings.target_system,
0,
mavutil.mavlink.MAV_CMD_DO_LAND_START,
... |
show version | def cmd_version(self, args):
'''show version'''
self.master.mav.command_long_send(self.settings.target_system,
self.settings.target_component,
mavutil.mavlink.MAV_CMD_REQUEST_AUTOPILOT_CAPABILITIES,
... |
start RC bind | def cmd_rcbind(self, args):
'''start RC bind'''
if len(args) < 1:
print("Usage: rcbind <dsmmode>")
return
self.master.mav.command_long_send(self.settings.target_system,
self.settings.target_component,
... |
repeat a command at regular intervals | def cmd_repeat(self, args):
'''repeat a command at regular intervals'''
if len(args) == 0:
if len(self.repeats) == 0:
print("No repeats")
return
for i in range(len(self.repeats)):
print("%u: %s" % (i, self.repeats[i]))
r... |
called on idle | def idle_task(self):
'''called on idle'''
for r in self.repeats:
if r.event.trigger():
self.mpstate.functions.process_stdin(r.cmd, immediate=True) |
process one file | def process_file(filename, timeshift):
'''process one file'''
print("Processing %s" % filename)
mlog = mavutil.mavlink_connection(filename, notimestamps=args.notimestamps, zero_time_base=args.zero_time_base, dialect=args.dialect)
vars = {}
while True:
msg = mlog.recv_match(args.condition)
... |
show map position click information | def show_position(self):
'''show map position click information'''
pos = self.click_position
dms = (mp_util.degrees_to_dms(pos[0]), mp_util.degrees_to_dms(pos[1]))
msg = "Coordinates in WGS84\n"
msg += "Decimal: %.6f %.6f\n" % (pos[0], pos[1])
msg += "DMS: %s %s\n" %... |
map commands | def cmd_map(self, args):
'''map commands'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
if args[0] == "icon":
if len(args) < 3:
print("Usage: map icon <lat> <lon> <icon>")
else:
lat = args[1]
lon = args[2]
... |
display the waypoints | def display_waypoints(self):
'''display the waypoints'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
self.mission_list = self.module('wp').wploader.view_list()
polygons = self.module('wp').wploader.polygon_list()
self.mpstate.map.add_object(mp_slipmap.SlipClearLayer('Mis... |
display the fence | def display_fence(self):
'''display the fence'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
self.fence_change_time = self.module('fence').fenceloader.last_change
points = self.module('fence').fenceloader.polygon()
self.mpstate.map.add_object(mp_slipmap.SlipClearLayer('F... |
find closest waypoint to a position | def closest_waypoint(self, latlon):
'''find closest waypoint to a position'''
(lat, lon) = latlon
best_distance = -1
closest = -1
for i in range(self.module('wp').wploader.count()):
w = self.module('wp').wploader.wp(i)
distance = mp_util.gps_distance(lat, ... |
remove a rally point | def remove_rally(self, key):
'''remove a rally point'''
a = key.split(' ')
if a[0] != 'Rally' or len(a) != 2:
print("Bad rally object %s" % key)
return
i = int(a[1])
self.mpstate.functions.process_stdin('rally remove %u' % i) |
move a rally point | def move_rally(self, key):
'''move a rally point'''
a = key.split(' ')
if a[0] != 'Rally' or len(a) != 2:
print("Bad rally object %s" % key)
return
i = int(a[1])
self.moving_rally = i |
return a mission idx from a selection_index | def selection_index_to_idx(self, key, selection_index):
'''return a mission idx from a selection_index'''
a = key.split(' ')
if a[0] != 'mission' or len(a) != 2:
print("Bad mission object %s" % key)
return None
midx = int(a[1])
if midx < 0 or midx >= len(s... |
move a mission point | def move_mission(self, key, selection_index):
'''move a mission point'''
idx = self.selection_index_to_idx(key, selection_index)
self.moving_wp = idx
print("Moving wp %u" % idx) |
remove a mission point | def remove_mission(self, key, selection_index):
'''remove a mission point'''
idx = self.selection_index_to_idx(key, selection_index)
self.mpstate.functions.process_stdin('wp remove %u' % idx) |
unload module | def unload(self):
'''unload module'''
self.mpstate.map.close()
self.mpstate.map = None
self.mpstate.map_functions = {} |
add a vehicle to the map | def create_vehicle_icon(self, name, colour, follow=False, vehicle_type=None):
'''add a vehicle to the map'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
if vehicle_type is None:
vehicle_type = self.vehicle_type_name
if name in self.have_vehicle and self.have_vehicle[... |
update line drawing | def drawing_update(self):
'''update line drawing'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
if self.draw_callback is None:
return
self.draw_line.append(self.click_position)
if len(self.draw_line) > 1:
self.mpstate.map.add_object(mp_slipmap.Sli... |
called when user selects "Set Home" on map | def cmd_set_home(self, args):
'''called when user selects "Set Home" on map'''
(lat, lon) = (self.click_position[0], self.click_position[1])
alt = self.ElevationMap.GetElevation(lat, lon)
print("Setting home to: ", lat, lon, alt)
self.master.mav.command_long_send(
sel... |
Returns the configuration as dict
@param filename: Name of the file
@type filename: String
@return a dict with propierties reader from file | def load(filename):
'''
Returns the configuration as dict
@param filename: Name of the file
@type filename: String
@return a dict with propierties reader from file
'''
filepath = findConfigFile(filename)
prop= None
if (filepath):
print ('loading Config file %s' %(filepath... |
handle an incoming mavlink packet | def handle_mavlink_packet(self, master, m):
'''handle an incoming mavlink packet'''
if m.get_type() == 'PARAM_VALUE':
param_id = "%.16s" % m.param_id
# Note: the xml specifies param_index is a uint16, so -1 in that field will show as 65535
# We accept both -1 and 6553... |
check for missing parameters periodically | def fetch_check(self, master):
'''check for missing parameters periodically'''
if self.param_period.trigger():
if master is None:
return
if len(self.mav_param_set) == 0:
master.param_fetch_all()
elif self.mav_param_count != 0 and len(se... |
show help on a parameter | def param_help(self, args):
'''show help on a parameter'''
if len(args) == 0:
print("Usage: param help PARAMETER_NAME")
return
if self.vehicle_name is None:
print("Unknown vehicle type")
return
path = mp_util.dot_mavproxy("%s.xml" % self.ve... |
handle missing parameters | def idle_task(self):
'''handle missing parameters'''
self.pstate.vehicle_name = self.vehicle_name
self.pstate.fetch_check(self.master) |
control parameters | def cmd_param(self, args):
'''control parameters'''
self.pstate.handle_command(self.master, self.mpstate, args) |
child process - this holds all the GUI elements | def child_task(self):
'''child process - this holds all the GUI elements'''
from MAVProxy.modules.lib import mp_util
import wx_processguard
from wx_loader import wx
from wxsettings_ui import SettingsDlg
mp_util.child_close_fds()
app = wx.App(False)
... |
watch for settings changes from child | def watch_thread(self):
'''watch for settings changes from child'''
from mp_settings import MPSetting
while True:
setting = self.child_pipe.recv()
if not isinstance(setting, MPSetting):
break
try:
self.settings.set(setting.name,... |
enable/disable speed report | def cmd_speed(self, args):
'''enable/disable speed report'''
self.settings.set('speedreporting', not self.settings.speedreporting)
if self.settings.speedreporting:
self.console.writeln("Speed reporting enabled", bg='yellow')
else:
self.console.writeln("Speed repor... |
report a sensor error | def report(self, name, ok, msg=None, deltat=20):
'''report a sensor error'''
r = self.reports[name]
if time.time() < r.last_report + deltat:
r.ok = ok
return
r.last_report = time.time()
if ok and not r.ok:
self.say("%s OK" % name)
r.ok ... |
report a sensor change | def report_change(self, name, value, maxdiff=1, deltat=10):
'''report a sensor change'''
r = self.reports[name]
if time.time() < r.last_report + deltat:
return
r.last_report = time.time()
if math.fabs(r.value - value) < maxdiff:
return
r.value = va... |
check heading discrepancy | def check_heading(self, m):
'''check heading discrepancy'''
if 'GPS_RAW' in self.status.msgs:
gps = self.status.msgs['GPS_RAW']
if gps.v < 3:
return
diff = math.fabs(angle_diff(m.heading, gps.hdg))
elif 'GPS_RAW_INT' in self.status.msgs:
... |
handle an incoming mavlink packet | def mavlink_packet(self, m):
'''handle an incoming mavlink packet'''
if m.get_type() == 'VFR_HUD' and ('GPS_RAW' in self.status.msgs or 'GPS_RAW_INT' in self.status.msgs):
self.check_heading(m)
if self.settings.speedreporting:
if m.airspeed != 0:
... |
generate complete python implemenation | def generate(basename, xml):
'''generate complete python implemenation'''
if basename.endswith('.py'):
filename = basename
else:
filename = basename + '.py'
msgs = []
enums = []
filelist = []
for x in xml:
msgs.extend(x.message)
enums.extend(x.enum)
f... |
close the window | def close(self):
'''close the window'''
self.close_window.release()
count=0
while self.child.is_alive() and count < 30: # 3 seconds to die...
time.sleep(0.1) #?
count+=1
if self.child.is_alive():
self.child.terminate()
self.child.join... |
hide an object on the map by key | def hide_object(self, key, hide=True):
'''hide an object on the map by key'''
self.object_queue.put(SlipHideObject(key, hide)) |
move an object on the map | def set_position(self, key, latlon, layer=None, rotation=0):
'''move an object on the map'''
self.object_queue.put(SlipPosition(key, latlon, layer, rotation)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.