INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
add a spin control | def add_intspin(self, setting):
'''add a spin control'''
tab = self.panel(setting.tab)
default = setting.value
(minv, maxv) = setting.range
ctrl = wx.SpinCtrl(tab, -1,
initial = default,
min = minv,
... |
add a floating point spin control | def add_floatspin(self, setting):
'''add a floating point spin control'''
from wx.lib.agw.floatspin import FloatSpin
tab = self.panel(setting.tab)
default = setting.value
(minv, maxv) = setting.range
ctrl = FloatSpin(tab, -1,
value = default,
... |
handle an incoming mavlink packet | def process_mavlink_packet(self, m):
'''handle an incoming mavlink packet'''
mtype = m.get_type()
# if you add processing for an mtype here, remember to add it
# to mavlink_packet, above
if mtype in ['WAYPOINT_COUNT','MISSION_COUNT']:
if (self.num_wps_expected == 0):... |
child process - this holds GUI elements | def child_task(self, q, l, gq, gl, cw_sem):
'''child process - this holds GUI elements'''
mp_util.child_close_fds()
from MAVProxy.modules.lib import wx_processguard
from ..lib.wx_loader import wx
from MAVProxy.modules.mavproxy_misseditor import missionEditorFrame
self.a... |
close the Mission Editor window | def close(self):
'''close the Mission Editor window'''
self.time_to_quit = True
self.close_window.release()
if self.child.is_alive():
self.child.join(1)
self.child.terminate()
self.mavlink_message_queue_handler.join()
self.event_queue_lock.acquire()... |
Create a new figure manager instance | def new_figure_manager(num, *args, **kwargs):
"""
Create a new figure manager instance
"""
if __debug__: verbose.report('backend_agg.new_figure_manager',
'debug-annoying')
FigureClass = kwargs.pop('FigureClass', Figure)
thisFig = FigureClass(*args, **kwargs)
... |
Create a new figure manager instance for the given figure. | def new_figure_manager_given_figure(num, figure):
"""
Create a new figure manager instance for the given figure.
"""
canvas = FigureCanvasAgg(figure)
manager = FigureManagerBase(canvas, num)
return manager |
Draw the path | def draw_path(self, gc, path, transform, rgbFace=None):
"""
Draw the path
"""
nmax = rcParams['agg.path.chunksize'] # here at least for testing
npts = path.vertices.shape[0]
if (nmax > 100 and npts > nmax and path.should_simplify and
rgbFace is None and gc.get... |
Draw the math text using matplotlib.mathtext | def draw_mathtext(self, gc, x, y, s, prop, angle):
"""
Draw the math text using matplotlib.mathtext
"""
if __debug__: verbose.report('RendererAgg.draw_mathtext',
'debug-annoying')
ox, oy, width, height, descent, font_image, used_characters = \... |
Render the text | def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
"""
Render the text
"""
if __debug__: verbose.report('RendererAgg.draw_text', 'debug-annoying')
if ismath:
return self.draw_mathtext(gc, x, y, s, prop, angle)
flags = get_hinting_flag()... |
get the width and height in display coords of the string s
with FontPropertry prop
# passing rgb is a little hack to make cacheing in the
# texmanager more efficient. It is not meant to be used
# outside the backend | def get_text_width_height_descent(self, s, prop, ismath):
"""
get the width and height in display coords of the string s
with FontPropertry prop
# passing rgb is a little hack to make cacheing in the
# texmanager more efficient. It is not meant to be used
# outside the ... |
Get the font for text instance t, cacheing for efficiency | def _get_agg_font(self, prop):
"""
Get the font for text instance t, cacheing for efficiency
"""
if __debug__: verbose.report('RendererAgg._get_agg_font',
'debug-annoying')
key = hash(prop)
font = RendererAgg._fontd.get(key)
... |
Restore the saved region. If bbox (instance of BboxBase, or
its extents) is given, only the region specified by the bbox
will be restored. *xy* (a tuple of two floasts) optionally
specifies the new position (the LLC of the original region,
not the LLC of the bbox) where the region will b... | def restore_region(self, region, bbox=None, xy=None):
"""
Restore the saved region. If bbox (instance of BboxBase, or
its extents) is given, only the region specified by the bbox
will be restored. *xy* (a tuple of two floasts) optionally
specifies the new position (the LLC of the... |
Start filtering. It simply create a new canvas (the old one is saved). | def start_filter(self):
"""
Start filtering. It simply create a new canvas (the old one is saved).
"""
self._filter_renderers.append(self._renderer)
self._renderer = _RendererAgg(int(self.width), int(self.height),
self.dpi)
self._upda... |
Save the plot in the current canvas as a image and apply
the *post_processing* function.
def post_processing(image, dpi):
# ny, nx, depth = image.shape
# image (numpy array) has RGBA channels and has a depth of 4.
...
# create a new_image (numpy ar... | def stop_filter(self, post_processing):
"""
Save the plot in the current canvas as a image and apply
the *post_processing* function.
def post_processing(image, dpi):
# ny, nx, depth = image.shape
# image (numpy array) has RGBA channels and has a depth of 4.
... |
Draw the figure using the renderer | def draw(self):
"""
Draw the figure using the renderer
"""
if __debug__: verbose.report('FigureCanvasAgg.draw', 'debug-annoying')
self.renderer = self.get_renderer(cleared=True)
# acquire a lock on the shared font cache
RendererAgg.lock.acquire()
try:
... |
set a status value | def set_check(self, name, state):
'''set a status value'''
if self.child.is_alive():
self.parent_pipe.send(CheckItem(name, state)) |
Generate the checklists. Note that:
0,1 = off/on for auto-ticked items
2,3 = off/on for manually ticked items | def createLists(self):
'''Generate the checklists. Note that:
0,1 = off/on for auto-ticked items
2,3 = off/on for manually ticked items'''
self.beforeAssemblyList = {
'Confirm batteries charged':2,
'No physical damage to airframe':2,
'All electronics present and ... |
before assembly checklist | def createWidgets(self):
#create the panels for the tabs
PanelAssembly = wx.Panel(self.nb)
boxAssembly = wx.BoxSizer(wx.VERTICAL)
PanelAssembly.SetAutoLayout(True)
PanelAssembly.SetSizer(boxAssembly)
PanelAssembly.Layout()
PanelEngine = wx.Panel(self.nb)
... |
return vehicle type string from a heartbeat | def vehicle_type_string(self, hb):
'''return vehicle type string from a heartbeat'''
if hb.type == mavutil.mavlink.MAV_TYPE_FIXED_WING:
return 'Plane'
if hb.type == mavutil.mavlink.MAV_TYPE_GROUND_ROVER:
return 'Rover'
if hb.type == mavutil.mavlink.MAV_TYPE_SURFAC... |
update menu for new vehicles | def update_vehicle_menu(self):
'''update menu for new vehicles'''
self.vehicle_menu.items = []
for s in sorted(self.vehicle_list):
clist = self.module('param').get_component_id_list(s)
if len(clist) == 1:
name = 'SysID %u: %s' % (s, self.vehicle_name_by_sy... |
add a new vehicle | def add_new_vehicle(self, hb):
'''add a new vehicle'''
if hb.type == mavutil.mavlink.MAV_TYPE_GCS:
return
sysid = hb.get_srcSystem()
self.vehicle_list.append(sysid)
self.vehicle_name_by_sysid[sysid] = self.vehicle_type_string(hb)
self.update_vehicle_menu() |
handle an incoming mavlink packet | def mavlink_packet(self, msg):
'''handle an incoming mavlink packet'''
if not isinstance(self.console, wxconsole.MessageConsole):
return
if not self.console.is_alive():
self.mpstate.console = textconsole.SimpleConsole()
return
type = msg.get_type()
... |
handle an incoming mavlink packet | def mavlink_packet(self, msg):
'''handle an incoming mavlink packet'''
type = msg.get_type()
if type == "STATUSTEXT":
# say some statustext values
if msg.text.startswith("Tuning: "):
self.say(msg.text[8:]) |
speak some text using espeak | def say_espeak(self, text, priority='important'):
'''speak some text using espeak'''
from espeak import espeak
if self.settings.speech_voice:
espeak.set_voice(self.settings.speech_voice)
espeak.synth(text) |
speech commands | def cmd_speech(self, args):
'''speech commands'''
usage = "usage: speech <say>"
if len(args) < 1:
print(usage)
return
if args[0] == "say":
if len(args) < 2:
print("usage: speech say <text to say>")
return
se... |
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:
... |
append this menu item to a menu | def _append(self, menu):
'''append this menu item to a menu'''
from MAVProxy.modules.lib.wx_loader import wx
submenu = wx.Menu()
for i in range(len(self.items)):
submenu.AppendRadioItem(self.id()+i, self.items[i], self.description)
if self.items[i] == self.initial... |
return a wx.Menu() for this menu | def wx_menu(self):
'''return a wx.Menu() for this menu'''
from MAVProxy.modules.lib.wx_loader import wx
menu = wx.Menu()
for i in range(len(self.items)):
m = self.items[i]
m._append(menu)
return menu |
add an item to a submenu using a menu path array | def add_to_submenu(self, submenu_path, item):
'''
add an item to a submenu using a menu path array
'''
for m in self.items:
if m.name == submenu_path[0]:
m.add_to_submenu(submenu_path[1:], item)
return
raise(ValueError("No submenu (%s) ... |
return a wx.MenuBar() for the menu | def wx_menu(self):
'''return a wx.MenuBar() for the menu'''
from MAVProxy.modules.lib.wx_loader import wx
menubar = wx.MenuBar()
for i in range(len(self.items)):
m = self.items[i]
menubar.Append(m.wx_menu(), m.name)
return menubar |
show a file dialog | def call(self):
'''show a file dialog'''
from MAVProxy.modules.lib.wx_loader import wx
# remap flags to wx descriptors
flag_map = {
'open': wx.FD_OPEN,
'save': wx.FD_SAVE,
'overwrite_prompt': wx.FD_OVERWRITE_PROMPT,
}
flagsMapped = map... |
show a value dialog | def call(self):
'''show a value dialog'''
from MAVProxy.modules.lib.wx_loader import wx
try:
dlg = wx.TextEntryDialog(None, self.title, self.title, defaultValue=str(self.default))
except TypeError:
dlg = wx.TextEntryDialog(None, self.title, self.title, value=str(s... |
cammsg | def cmd_cammsg(self, args):
'''cammsg'''
params = [0, 0, 0, 0, 1, 0, 0]
# fill in any args passed by user
for i in range(min(len(args),len(params))):
params[i] = float(args[i])
print("Sent DIGICAM_CONTROL CMD_LONG")
self.master.mav.command_long_send(
... |
cammsg_old | def cmd_cammsg_old(self, args):
'''cammsg_old'''
print("Sent old DIGICAM_CONTROL")
self.master.mav.digicam_control_send(
self.settings.target_system, # target_system
0, # target_component
0, 0, 0, 0, 1, 0, 0, 0) |
execute supplied command long | def cmd_long(self, args):
'''execute supplied command long'''
if len(args) < 1:
print("Usage: long <command> [arg1] [arg2]...")
return
command = None
if args[0].isdigit():
command = int(args[0])
else:
try:
command = ... |
speed value | def cmd_do_change_speed(self, args):
'''speed value'''
if ( len(args) != 1):
print("Usage: setspeed SPEED_VALUE")
return
if (len(args) == 1):
speed = float(args[0])
print("SPEED %s" % (str(speed)))
self.master.mav.command_long_send(
... |
execute supplied command_int | def cmd_command_int(self, args):
'''execute supplied command_int'''
if len(args) != 11:
print("num args{0}".format(len(args)))
print("Usage: command_int frame command current autocontinue param1 param2 param3 param4 x y z")
print("e.g. command_int GLOBAL_RELATIVE_ALT ... |
Scale an in value in the range (inlow, inhigh) to the
range (outlow, outhigh). | def scale(val,
inlow=-1, inhigh=1,
outlow=1000, outhigh=2000):
'''Scale an in value in the range (inlow, inhigh) to the
range (outlow, outhigh).'''
return (
((float(val) - inlow) / (inhigh - inlow)) *
(outhigh - outlow) + outlow
) |
show key sensors | def cmd_sensors(self, args):
'''show key sensors'''
gps_heading = self.status.msgs['GPS_RAW_INT'].cog * 0.01
self.console.writeln("heading: %u/%u alt: %u/%u r/p: %u/%u speed: %u/%u thr: %u" % (
self.status.msgs['VFR_HUD'].heading,
gps_heading,
self.status... |
check heading discrepancy | def check_heading(self, m):
'''check heading discrepancy'''
if 'GPS_RAW_INT' in self.status.msgs:
gps = self.status.msgs['GPS_RAW_INT']
if gps.vel < 300:
return
diff = math.fabs(angle_diff(m.heading, gps.cog / 100.0))
else:
return
... |
returns 0 if key not found | def cmd_reverse_lookup(command_name):
'''returns 0 if key not found'''
for key, value in miss_cmds.items():
if (value.upper() == command_name.upper()):
return key
return 0 |
try to work out a reasonable column name from parameter description | def make_column_label(command_name, description, default):
'''try to work out a reasonable column name from parameter description'''
for (pattern, label) in description_map:
if fnmatch.fnmatch(description, pattern):
return label
return default |
return dictionary of column labels if available | def get_column_labels(command_name):
'''return dictionary of column labels if available'''
cmd = cmd_reverse_lookup(command_name)
if cmd == 0:
return {}
labels = {}
enum = mavutil.mavlink.enums['MAV_CMD'][cmd]
for col in enum.param.keys():
labels[col] = make_column_label(command_... |
find an antenna tracker connection if possible | def find_connection(self):
'''find an antenna tracker connection if possible'''
if self.connection is not None:
return self.connection
for m in self.mpstate.mav_master:
if 'HEARTBEAT' in m.messages:
if m.messages['HEARTBEAT'].type == mavutil.mavlink.MAV_TY... |
tracker command parser | def cmd_tracker(self, args):
'''tracker command parser'''
usage = "usage: tracker <start|set|arm|disarm|level|param|mode|position> [options]"
if len(args) == 0:
print(usage)
return
if args[0] == "start":
self.cmd_tracker_start()
elif args[0] ==... |
tracker manual positioning commands | def cmd_tracker_position(self, args):
'''tracker manual positioning commands'''
connection = self.find_connection()
if not connection:
print("No antenna tracker found")
return
positions = [0, 0, 0, 0, 0] # x, y, z, r, buttons. only position[0] (yaw) and position[1... |
calibrate barometer on tracker | def cmd_tracker_calpress(self, args):
'''calibrate barometer on tracker'''
connection = self.find_connection()
if not connection:
print("No antenna tracker found")
return
connection.calibrate_pressure() |
set arbitrary mode | def cmd_tracker_mode(self, args):
'''set arbitrary mode'''
connection = self.find_connection()
if not connection:
print("No antenna tracker found")
return
mode_mapping = connection.mode_mapping()
if mode_mapping is None:
print('No mode mapping ... |
handle an incoming mavlink packet from the master vehicle. Relay it to the tracker
if it is a GLOBAL_POSITION_INT | def mavlink_packet(self, m):
'''handle an incoming mavlink packet from the master vehicle. Relay it to the tracker
if it is a GLOBAL_POSITION_INT'''
if m.get_type() in ['GLOBAL_POSITION_INT', 'SCALED_PRESSURE']:
connection = self.find_connection()
if not connection:
... |
called in idle time | def idle_task(self):
'''called in idle time'''
if not self.connection:
return
# check for a mavlink message from the tracker
m = self.connection.recv_msg()
if m is None:
return
if self.tracker_settings.debug:
print(m)
self.ps... |
Parameter commands | def cmd_tracker_param(self, args):
'''Parameter commands'''
if not self.connection:
print("tracker not connected")
return
self.pstate.handle_command(self.connection, self.mpstate, args) |
fix up jumps when we add/remove rows | def fix_jumps(self, row_selected, delta):
'''fix up jumps when we add/remove rows'''
numrows = self.grid_mission.GetNumberRows()
for row in range(numrows):
command = self.grid_mission.GetCellValue(row, ME_COMMAND_COL)
if command in ["DO_JUMP", "DO_CONDITION_JUMP"]:
... |
setup legend for graphs | def cmd_legend(self, args):
'''setup legend for graphs'''
if len(args) == 0:
for leg in self.legend.keys():
print("%s -> %s" % (leg, self.legend[leg]))
elif len(args) == 1:
leg = args[0]
if leg in self.legend:
print("Removing le... |
called on idle | def idle_task(self):
'''called on idle'''
if self.menu is not None and self.module('map') is not None and not self.menu_added_map:
self.menu_added_map = True
self.module('map').add_menu(self.menu) |
control gimbal | def cmd_gimbal(self, args):
'''control gimbal'''
usage = 'Usage: gimbal <rate|point|roi|roivel|mode|status>'
if len(args) == 0:
print(usage)
return
if args[0] == 'rate':
self.cmd_gimbal_rate(args[1:])
elif args[0] == 'point':
self.c... |
control gimbal mode | def cmd_gimbal_mode(self, args):
'''control gimbal mode'''
if len(args) != 1:
print("usage: gimbal mode <GPS|MAVLink>")
return
if args[0].upper() == 'GPS':
mode = mavutil.mavlink.MAV_MOUNT_MODE_GPS_POINT
elif args[0].upper() == 'MAVLINK':
m... |
control roi position | def cmd_gimbal_roi(self, args):
'''control roi position'''
latlon = None
try:
latlon = self.module('map').click_position
except Exception:
print("No map available")
return
if latlon is None:
print("No map click position available")
... |
control roi position and velocity | def cmd_gimbal_roi_vel(self, args):
'''control roi position and velocity'''
if len(args) != 0 and len(args) != 3 and len(args) != 6:
print("usage: gimbal roivel [VEL_NORTH VEL_EAST VEL_DOWN] [ACC_NORTH ACC_EASY ACC_DOWN]")
return
latlon = None
vel = [0,0,0]
... |
control gimbal rate | def cmd_gimbal_rate(self, args):
'''control gimbal rate'''
if len(args) != 3:
print("usage: gimbal rate ROLL PITCH YAW")
return
(roll, pitch, yaw) = (float(args[0]), float(args[1]), float(args[2]))
self.master.mav.gimbal_control_send(self.target_system,
... |
control gimbal pointing | def cmd_gimbal_point(self, args):
'''control gimbal pointing'''
if len(args) != 3:
print("usage: gimbal point ROLL PITCH YAW")
return
(roll, pitch, yaw) = (float(args[0]), float(args[1]), float(args[2]))
self.master.mav.mount_control_send(self.target_system,
... |
show gimbal status | def cmd_gimbal_status(self, args):
'''show gimbal status'''
master = self.master
if 'GIMBAL_REPORT' in master.messages:
print(master.messages['GIMBAL_REPORT'])
else:
print("No GIMBAL_REPORT messages") |
handle an incoming mavlink packet | def mavlink_packet(self, m):
'''handle an incoming mavlink packet'''
if not self.mpstate.map:
# don't draw if no map
return
if m.get_type() != 'GIMBAL_REPORT':
return
needed = ['ATTITUDE', 'GLOBAL_POSITION_INT']
for n in needed:
... |
handle different image formats, returning (width,height) tuple | def image_shape(img):
'''handle different image formats, returning (width,height) tuple'''
if hasattr(img, 'shape'):
return (img.shape[1], img.shape[0])
return (img.width, img.height) |
draw a line on the image | def draw_line(self, img, pixmapper, pt1, pt2, colour, linewidth):
'''draw a line on the image'''
pix1 = pixmapper(pt1)
pix2 = pixmapper(pt2)
(width, height) = image_shape(img)
(ret, pix1, pix2) = cv2.clipLine((0, 0, width, height), pix1, pix2)
if ret is False:
... |
draw a line on the image | def draw_line(self, img, pixmapper, pt1, pt2, colour, linewidth):
'''draw a line on the image'''
pix1 = pixmapper(pt1)
pix2 = pixmapper(pt2)
(width, height) = image_shape(img)
(ret, pix1, pix2) = cv2.clipLine((0, 0, width, height), pix1, pix2)
if ret is False:
... |
draw legend on the image | def draw(self, img, pixmapper, bounds):
'''draw legend on the image'''
if self._img is None:
self._img = self.draw_legend()
w = self._img.shape[1]
h = self._img.shape[0]
px = 5
py = 5
img[py:py+h,px:px+w] = self._img |
return a cv image for the thumbnail | def img(self):
'''return a cv image for the thumbnail'''
if self._img is not None:
return self._img
self._img = cv2.cvtColor(self.original_img, cv2.COLOR_BGR2RGB)
if self.border_width and self.border_colour is not None:
cv2.rectangle(self._img, (0, 0), (self.widt... |
draw the thumbnail on the image | def draw(self, img, pixmapper, bounds):
'''draw the thumbnail on the image'''
if self.hidden:
return
thumb = self.img()
(px,py) = pixmapper(self.latlon)
# find top left
(w, h) = image_shape(thumb)
px -= w//2
py -= h//2
(px, py, sx, sy... |
draw the trail | def draw(self, img, pixmapper, bounds):
'''draw the trail'''
for p in self.points:
(px,py) = pixmapper(p)
(width, height) = image_shape(img)
if px >= 0 and py >= 0 and px < width and py < height:
cv2.circle(img, (px,py), 1, self.colour) |
return a cv image for the icon | def img(self):
'''return a cv image for the icon'''
SlipThumbnail.img(self)
if self.rotation:
# rotate the image
mat = cv2.getRotationMatrix2D((self.height//2, self.width//2), -self.rotation, 1.0)
self._rotated = cv2.warpAffine(self._img, mat, (self.height, s... |
draw the icon on the image | def draw(self, img, pixmapper, bounds):
'''draw the icon on the image'''
if self.hidden:
return
if self.trail is not None:
self.trail.draw(img, pixmapper, bounds)
icon = self.img()
(px,py) = pixmapper(self.latlon)
# find top left
(w, h)... |
return a wx image | def img(self):
'''return a wx image'''
import wx
with warnings.catch_warnings():
warnings.simplefilter('ignore')
img = wx.EmptyImage(self.width, self.height)
img.SetData(self.imgstr)
return img |
terrain command parser | def cmd_terrain(self, args):
'''terrain command parser'''
usage = "usage: terrain <set|status|check>"
if len(args) == 0:
print(usage)
return
if args[0] == "status":
print("blocks_sent: %u requests_received: %u" % (
self.blocks_sent,
... |
check a piece of terrain data | def cmd_terrain_check(self, args):
'''check a piece of terrain data'''
if len(args) >= 2:
latlon = (float(args[0]), float(args[1]))
else:
try:
latlon = self.module('map').click_position
except Exception:
print("No map available"... |
handle an incoming mavlink packet | def mavlink_packet(self, msg):
'''handle an incoming mavlink packet'''
type = msg.get_type()
master = self.master
# add some status fields
if type == 'TERRAIN_REQUEST':
self.current_request = msg
self.sent_mask = 0
self.requests_received += 1
... |
send some terrain data | def send_terrain_data_bit(self, bit):
'''send some terrain data'''
lat = self.current_request.lat * 1.0e-7
lon = self.current_request.lon * 1.0e-7
bit_spacing = self.current_request.grid_spacing * 4
(lat, lon) = mp_util.gps_offset(lat, lon,
... |
send some terrain data | def send_terrain_data(self):
'''send some terrain data'''
for bit in range(56):
if self.current_request.mask & (1<<bit) and self.sent_mask & (1<<bit) == 0:
self.send_terrain_data_bit(bit)
return
# no bits to send
self.current_request = None
... |
called when idle | def idle_task(self):
'''called when idle'''
if self.current_request is None:
return
if time.time() - self.last_send_time < 0.2:
# limit to 5 per second
return
self.send_terrain_data() |
set arbitrary mode | def cmd_mode(self, args):
'''set arbitrary mode'''
mode_mapping = self.master.mode_mapping()
if mode_mapping is None:
print('No mode mapping available')
return
if len(args) != 1:
print('Available modes: ', mode_mapping.keys())
return
... |
handle mode switch by mode name as command | def unknown_command(self, args):
'''handle mode switch by mode name as command'''
mode_mapping = self.master.mode_mapping()
mode = args[0].upper()
if mode in mode_mapping:
self.master.set_mode(mode_mapping[mode])
return True
return False |
set GUIDED target | def cmd_guided(self, args):
'''set GUIDED target'''
if len(args) != 1 and len(args) != 3:
print("Usage: guided ALTITUDE | guided LAT LON ALTITUDE")
return
if len(args) == 3:
latitude = float(args[0])
longitude = float(args[1])
altitude... |
child process - this holds all the GUI elements | def child_task(self):
'''child process - this holds all the GUI elements'''
self.parent_pipe_send.close()
from MAVProxy.modules.lib.wx_loader import wx
from MAVProxy.modules.lib.wxhorizon_ui import HorizonFrame
# Create wx application
app = wx.App(False)
... |
check for FDM packets from runsim | def check_sim_in(self):
'''check for FDM packets from runsim'''
try:
pkt = self.sim_in.recv(17*8 + 4)
except socket.error as e:
if not e.errno in [ errno.EAGAIN, errno.EWOULDBLOCK ]:
raise
return
if len(pkt) != 17*8 + 4:
# w... |
check if we should send new servos to flightgear | def check_sim_out(self):
'''check if we should send new servos to flightgear'''
now = time.time()
if now - self.last_sim_send_time < 0.02 or self.rc_channels_scaled is None:
return
self.last_sim_send_time = now
servos = []
for ch in range(1,9):
se... |
check if we should send new data to the APM | def check_apm_out(self):
'''check if we should send new data to the APM'''
now = time.time()
if now - self.last_apm_send_time < 0.02:
return
self.last_apm_send_time = now
if self.hil_state_msg is not None:
self.master.mav.send(self.hil_state_msg) |
convert a set of roll rates from earth frame to body frame | def convert_body_frame(self, phi, theta, phiDot, thetaDot, psiDot):
'''convert a set of roll rates from earth frame to body frame'''
p = phiDot - psiDot*math.sin(theta)
q = math.cos(phi)*thetaDot + math.sin(phi)*psiDot*math.cos(theta)
r = math.cos(phi)*psiDot*math.cos(theta) - math.sin(p... |
scale a channel to 1000/1500/2000 | def scale_channel(self, ch, value):
'''scale a channel to 1000/1500/2000'''
v = value/10000.0
if v < -1:
v = -1
elif v > 1:
v = 1
if ch == 3 and self.mpstate.vehicle_type != 'rover':
if v < 0:
v = 0
return int(1000 +... |
control behaviour of the module | def cmd_messagerate(self, args):
'''control behaviour of the module'''
if len(args) == 0:
print(self.usage())
elif args[0] == "status":
print(self.status())
elif args[0] == "reset":
self.reset()
else:
print(self.usage()) |
reset rates | def reset(self):
'''reset rates'''
self.counts = {}
self.buckets = []
self.last_calc = time.time() |
returns rates | def status(self):
'''returns rates'''
counts = {}
for bucket in self.buckets:
for x in bucket:
if not x in counts:
counts[x] = 0
counts[x] += bucket[x]
ret = ""
mtypes = counts.keys()
mtypes.sort()
f... |
called rapidly by mavproxy | def idle_task(self):
'''called rapidly by mavproxy'''
now = time.time()
time_delta = now - self.last_calc
if time_delta > 1:
self.last_calc = now
self.buckets.append(self.counts)
self.counts = {}
if len(self.buckets) > self.max_buckets:
... |
handle mavlink packets | def mavlink_packet(self, m):
'''handle mavlink packets'''
mtype = m.get_type()
if mtype not in self.counts:
self.counts[mtype] = 0
self.counts[mtype] += 1 |
set a setting | def set(self, value):
'''set a setting'''
if value == 'None' and self.default is None:
value = None
if value is not None:
if self.type == bool:
if str(value).lower() in ['1', 'true', 'yes']:
value = True
elif str(value).... |
add a new setting | def append(self, v):
'''add a new setting'''
if isinstance(v, MPSetting):
setting = v
else:
(name,type,default) = v
label = name
tab = None
if len(v) > 3:
label = v[3]
if len(v) > 4:
tab = v[4... |
set a setting | def set(self, name, value):
'''set a setting'''
if not name in self._vars:
raise AttributeError
setting = self._vars[name]
oldvalue = setting.value
if not setting.set(value):
print("Unable to convert %s to type %s" % (value, setting.type))
retu... |
get a setting | def get(self, name):
'''get a setting'''
if not name in self._vars:
raise AttributeError
setting = self._vars[name]
return setting.value |
control options from cmdline | def command(self, args):
'''control options from cmdline'''
if len(args) == 0:
self.show_all()
return
if getattr(self, args[0], [None]) == [None]:
print("Unknown setting '%s'" % args[0])
return
if len(args) == 1:
self.show(args[... |
save settings to a file. Return True/False on success/failure | def save(self, filename):
'''save settings to a file. Return True/False on success/failure'''
try:
f = open(filename, mode='w')
except Exception:
return False
for k in self.list():
f.write("%s=%s\n" % (k, self.get(k)))
f.close()
return ... |
load settings from a file. Return True/False on success/failure | def load(self, filename):
'''load settings from a file. Return True/False on success/failure'''
try:
f = open(filename, mode='r')
except Exception:
return False
while True:
line = f.readline()
if not line:
break
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.