INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
arm commands | def cmd_arm(self, args):
'''arm commands'''
usage = "usage: arm <check|uncheck|list|throttle|safetyon|safetyoff>"
if len(args) <= 0:
print(usage)
return
if args[0] == "check":
if (len(args) < 2):
print("usage: arm check " + self.check... |
returns true if the UAV is skipping any arming checks | def all_checks_enabled(self):
''' returns true if the UAV is skipping any arming checks'''
arming_mask = int(self.get_mav_param("ARMING_CHECK",0))
if arming_mask == 1:
return True
for bit in arming_masks.values():
if not arming_mask & bit and bit != 1:
... |
special handling for the px4 style of PARAM_VALUE | def handle_px4_param_value(self, m):
'''special handling for the px4 style of PARAM_VALUE'''
if m.param_type == mavutil.mavlink.MAV_PARAM_TYPE_REAL32:
# already right type
return m.param_value
is_px4_params = False
if m.get_srcComponent() in [mavutil.mavlink.MAV_C... |
handle an incoming mavlink packet | def handle_mavlink_packet(self, master, m):
'''handle an incoming mavlink packet'''
if m.get_type() == 'PARAM_VALUE':
value = self.handle_px4_param_value(m)
param_id = "%.16s" % m.param_id
# Note: the xml specifies param_index is a uint16, so -1 in that field will sho... |
download XML files for parameters | def param_help_download(self):
'''download XML files for parameters'''
files = []
for vehicle in ['APMrover2', 'ArduCopter', 'ArduPlane', 'ArduSub', 'AntennaTracker']:
url = 'http://autotest.ardupilot.org/Parameters/%s/apm.pdef.xml' % vehicle
path = mp_util.dot_mavproxy("... |
return a "help tree", a map between a parameter and its metadata. May return None if help is not available | def param_help_tree(self):
'''return a "help tree", a map between a parameter and its metadata. May return None if help is not available'''
if self.xml_filepath is not None:
print("param: using xml_filepath=%s" % self.xml_filepath)
path = self.xml_filepath
else:
... |
search parameter help for a keyword, list those parameters | def param_apropos(self, args):
'''search parameter help for a keyword, list those parameters'''
if len(args) == 0:
print("Usage: param apropos keyword")
return
htree = self.param_help_tree()
if htree is None:
return
contains = {}
for ... |
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
htree = self.param_help_tree()
if htree is None:
return
for h in args:
h = h.upper()
if h i... |
handle parameter commands | def handle_command(self, master, mpstate, args):
'''handle parameter commands'''
param_wildcard = "*"
usage="Usage: param <fetch|save|set|show|load|preload|forceload|diff|download|help>"
if len(args) < 1:
print(usage)
return
if args[0] == "fetch":
... |
get list of component IDs with parameters for a given system ID | def get_component_id_list(self, system_id):
'''get list of component IDs with parameters for a given system ID'''
ret = []
for (s,c) in self.mpstate.mav_param_by_sysid.keys():
if s == system_id:
ret.append(c)
return ret |
handle a new target_system | def add_new_target_system(self, sysid):
'''handle a new target_system'''
if sysid in self.pstate:
return
if not sysid in self.mpstate.mav_param_by_sysid:
self.mpstate.mav_param_by_sysid[sysid] = mavparm.MAVParmDict()
self.new_sysid_timestamp = time.time()
... |
get sysid tuple to use for parameters | def get_sysid(self):
'''get sysid tuple to use for parameters'''
component = self.target_component
if component == 0:
component = 1
return (self.target_system, component) |
handle a new target_system | def check_new_target_system(self):
'''handle a new target_system'''
sysid = self.get_sysid()
if sysid in self.pstate:
return
self.add_new_target_system(sysid) |
handle an incoming mavlink packet | def mavlink_packet(self, m):
'''handle an incoming mavlink packet'''
sysid = (m.get_srcSystem(),m.get_srcComponent())
self.add_new_target_system(sysid)
self.pstate[sysid].handle_mavlink_packet(self.master, m) |
handle missing parameters | def idle_task(self):
'''handle missing parameters'''
self.check_new_target_system()
sysid = self.get_sysid()
self.pstate[sysid].vehicle_name = self.vehicle_name
self.pstate[sysid].fetch_check(self.master) |
control parameters | def cmd_param(self, args):
'''control parameters'''
self.check_new_target_system()
sysid = self.get_sysid()
self.pstate[sysid].handle_command(self.master, self.mpstate, args) |
Returns the tuple ( options, args )
options - a dictionary of option names and values
args - a sequence of args | def getOptionsAndArgs( self ):
'''Returns the tuple ( options, args )
options - a dictionary of option names and values
args - a sequence of args'''
option_values = self._getOptions()
args = self._getArgs()
return option_values, args |
multiprocessing wrapper around _parse_args | def parse_args( self, args = None, values = None ):
'''
multiprocessing wrapper around _parse_args
'''
q = multiproc.Queue()
p = multiproc.Process(target=self._parse_args, args=(q, args, values))
p.start()
ret = q.get()
p.join()
return ret |
This is the heart of it all - overrides optparse.OptionParser.parse_args
@param arg is irrelevant and thus ignored,
it is here only for interface compatibility | def _parse_args( self, q, args, values):
'''
This is the heart of it all - overrides optparse.OptionParser.parse_args
@param arg is irrelevant and thus ignored,
it is here only for interface compatibility
'''
if wx.GetApp() is None:
self.app = wx.App( F... |
get distance from a point | def distance_from(self, lat, lon):
'''get distance from a point'''
lat1 = self.pkt['I105']['Lat']['val']
lon1 = self.pkt['I105']['Lon']['val']
return mp_util.gps_distance(lat1, lon1, lat, lon) |
random initial position | def randpos(self):
'''random initial position'''
self.setpos(gen_settings.home_lat, gen_settings.home_lon)
self.move(random.uniform(0, 360), random.uniform(0, gen_settings.region_width)) |
return height above ground in feet | def ground_height(self):
'''return height above ground in feet'''
lat = self.pkt['I105']['Lat']['val']
lon = self.pkt['I105']['Lon']['val']
global ElevationMap
ret = ElevationMap.GetElevation(lat, lon)
ret -= gen_settings.wgs84_to_AMSL
return ret * 3.2807 |
move position by bearing and distance | def move(self, bearing, distance):
'''move position by bearing and distance'''
lat = self.pkt['I105']['Lat']['val']
lon = self.pkt['I105']['Lon']['val']
(lat, lon) = mp_util.gps_newpos(lat, lon, bearing, distance)
self.setpos(lat, lon) |
fly a square circuit | def update(self, deltat=1.0):
'''fly a square circuit'''
DNFZ.update(self, deltat)
self.dist_flown += self.speed * deltat
if self.dist_flown > self.circuit_width:
self.desired_heading = self.heading + 90
self.dist_flown = 0
if self.getalt() < self.ground_h... |
fly circles, then dive | def update(self, deltat=1.0):
'''fly circles, then dive'''
DNFZ.update(self, deltat)
self.time_circling += deltat
self.setheading(self.heading + self.turn_rate * deltat)
self.move(self.drift_heading, self.drift_speed)
if self.getalt() > self.max_alt or self.getalt() < sel... |
fly in long curves | def update(self, deltat=1.0):
'''fly in long curves'''
DNFZ.update(self, deltat)
if (self.distance_from_home() > gen_settings.region_width or
self.getalt() < self.ground_height() or
self.getalt() > self.ground_height() + 1000):
self.randpos()
self.... |
straight lines, with short life | def update(self, deltat=1.0):
'''straight lines, with short life'''
DNFZ.update(self, deltat)
self.lifetime -= deltat
if self.lifetime <= 0:
self.randpos()
self.lifetime = random.uniform(300,600) |
drop an object on the map | def cmd_dropobject(self, obj):
'''drop an object on the map'''
latlon = self.module('map').click_position
if self.last_click is not None and self.last_click == latlon:
return
self.last_click = latlon
if latlon is not None:
obj.setpos(latlon[0], latlon[1])
... |
genobstacles command parser | def cmd_genobstacles(self, args):
'''genobstacles command parser'''
usage = "usage: genobstacles <start|stop|restart|clearall|status|set>"
if len(args) == 0:
print(usage)
return
if args[0] == "set":
gen_settings.command(args[1:])
elif args[0] =... |
start sending packets | def start(self):
'''start sending packets'''
if self.sock is not None:
self.sock.close()
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.sock.connect(('', gen_setting... |
trigger sends from ATTITUDE packets | def mavlink_packet(self, m):
'''trigger sends from ATTITUDE packets'''
if not self.have_home and m.get_type() == 'GPS_RAW_INT' and m.fix_type >= 3:
gen_settings.home_lat = m.lat * 1.0e-7
gen_settings.home_lon = m.lon * 1.0e-7
self.have_home = True
if self.... |
update the threat state | def update(self, state, tnow):
'''update the threat state'''
self.state = state
self.update_time = tnow |
adsb command parser | def cmd_ADSB(self, args):
'''adsb command parser'''
usage = "usage: adsb <set>"
if len(args) == 0:
print(usage)
return
if args[0] == "status":
print("total threat count: %u active threat count: %u" %
(len(self.threat_vehicles), len(s... |
determine threats | def perform_threat_detection(self):
'''determine threats'''
# TODO: perform more advanced threat detection
threat_radius_clear = self.ADSB_settings.threat_radius * \
self.ADSB_settings.threat_radius_clear_multiplier
for id in self.threat_vehicles.keys():
if self.... |
update the distance between threats and vehicle | def update_threat_distances(self, latlonalt):
'''update the distance between threats and vehicle'''
for id in self.threat_vehicles.keys():
threat_latlonalt = (self.threat_vehicles[id].state['lat'] * 1e-7,
self.threat_vehicles[id].state['lon'] * 1e-7,
... |
get the horizontal distance between threat and vehicle | def get_h_distance(self, latlonalt1, latlonalt2):
'''get the horizontal distance between threat and vehicle'''
(lat1, lon1, alt1) = latlonalt1
(lat2, lon2, alt2) = latlonalt2
lat1 = radians(lat1)
lon1 = radians(lon1)
lat2 = radians(lat2)
lon2 = radians(lon2)
... |
get the horizontal distance between threat and vehicle | def get_v_distance(self, latlonalt1, latlonalt2):
'''get the horizontal distance between threat and vehicle'''
(lat1, lon1, alt1) = latlonalt1
(lat2, lon2, alt2) = latlonalt2
return alt2 - alt1 |
check and handle threat time out | def check_threat_timeout(self):
'''check and handle threat time out'''
for id in self.threat_vehicles.keys():
if self.threat_vehicles[id].update_time == 0:
self.threat_vehicles[id].update_time = self.get_time()
dt = self.get_time() - self.threat_vehicles[id].updat... |
handle an incoming mavlink packet | def mavlink_packet(self, m):
'''handle an incoming mavlink packet'''
if m.get_type() == "ADSB_VEHICLE":
id = 'ADSB-' + str(m.ICAO_address)
if id not in self.threat_vehicles.keys(): # check to see if the vehicle is in the dict
# if not then add it
... |
called on idle | def idle_task(self):
'''called on idle'''
if self.threat_timeout_timer.trigger():
self.check_threat_timeout()
if self.threat_detection_timer.trigger():
self.perform_threat_detection() |
handle an incoming mavlink packet | def mavlink_packet(self, msg):
'''handle an incoming mavlink packet'''
if not isinstance(self.checklist, mp_checklist.CheckUI):
return
if not self.checklist.is_alive():
return
type = msg.get_type()
master = self.master
if type == 'HEARTBEAT':
... |
gopro commands | def cmd_gopro(self, args):
'''gopro commands'''
usage = "status, shutter <start|stop>, mode <video|camera>, power <on|off>"
mav = self.master.mav
if args[0] == "status":
self.cmd_gopro_status(args[1:])
return
if args[0] == "shutter":
name = a... |
show gopro status | def cmd_gopro_status(self, args):
'''show gopro status'''
master = self.master
if 'GOPRO_HEARTBEAT' in master.messages:
print(master.messages['GOPRO_HEARTBEAT'])
else:
print("No GOPRO_HEARTBEAT messages") |
Returns the altitude (m ASL) of a given lat/long pair, or None if unknown | def GetElevation(self, latitude, longitude, timeout=0):
'''Returns the altitude (m ASL) of a given lat/long pair, or None if unknown'''
if latitude is None or longitude is None:
return None
if self.database == 'srtm':
TileID = (numpy.floor(latitude), numpy.floor(longitude... |
handle double clicks on URL text | def on_text_url(self, event):
'''handle double clicks on URL text'''
try:
import webbrowser
except ImportError:
return
mouse_event = event.GetMouseEvent()
if mouse_event.LeftDClick():
url_start = event.GetURLStart()
url_end = event.... |
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 in [ 'RC_CHANNELS' ]:
ilock = self.get_rc_input(msg, self.interlock_channel)
if ilock <= 0:
... |
update which channels provide input | def update_channels(self):
'''update which channels provide input'''
self.interlock_channel = -1
self.override_channel = -1
self.zero_I_channel = -1
self.no_vtol_channel = -1
# output channels
self.rsc_out_channel = 9
self.fwd_thr_channel = 10
fo... |
run periodic tasks | def idle_task(self):
'''run periodic tasks'''
now = time.time()
if now - self.last_chan_check >= 1:
self.last_chan_check = now
self.update_channels() |
rally loader by system ID | def rallyloader(self):
'''rally loader by system ID'''
if not self.target_system in self.rallyloader_by_sysid:
self.rallyloader_by_sysid[self.target_system] = mavwp.MAVRallyLoader(self.settings.target_system,
se... |
called in idle time | def idle_task(self):
'''called in idle time'''
try:
data = self.port.recv(1024) # Attempt to read up to 1024 bytes.
except socket.error as e:
if e.errno in [ errno.EAGAIN, errno.EWOULDBLOCK ]:
return
raise
try:
self.send_rtc... |
fps command | def fpsInformation(self,args):
'''fps command'''
invalidStr = 'Invalid number of arguments. Usage horizon-fps set <fps> or horizon-fps get. Set fps to zero to get unrestricted framerate.'
if len(args)>0:
if args[0] == "get":
'''Get the current framerate.'''
... |
handle an incoming mavlink packet | def mavlink_packet(self, msg):
'''handle an incoming mavlink packet'''
msgType = msg.get_type()
master = self.master
if msgType == 'HEARTBEAT':
# Update state and mode information
if type(master.motors_armed()) == type(True):
self.armed = ma... |
help commands | def cmd_help(self, args):
'''help commands'''
if len(args) < 1:
self.print_usage()
return
if args[0] == "about":
print(self.about_string())
elif args[0] == "site":
print("See http://ardupilot.github.io/MAVProxy/ for documentation")
... |
set the image to be displayed | def set_image(self, img):
'''set the image to be displayed'''
with warnings.catch_warnings():
warnings.simplefilter('ignore')
if hasattr(img, 'shape'):
(width, height) = (img.shape[1], img.shape[0])
self._bmp = wx.BitmapFromBuffer(width, height, np... |
returns information about module | def status(self):
'''returns information about module'''
if self.download is None:
return "Not started"
transferred = self.download - self.prev_download
self.prev_download = self.download
now = time.time()
interval = now - self.last_status_time
self.l... |
print out statistics every 10 seconds from idle loop | def idle_print_status(self):
'''print out statistics every 10 seconds from idle loop'''
now = time.time()
if (now - self.last_idle_status_printed_time) >= 10:
print(self.status())
self.last_idle_status_printed_time = now |
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" %... |
send a stop packet (if we haven't sent one in the last second) | def tell_sender_to_stop(self, m):
'''send a stop packet (if we haven't sent one in the last second)'''
now = time.time()
if now - self.time_last_stop_packet_sent < 1:
return
if self.log_settings.verbose:
print("DFLogger: Sending stop packet")
self.time_las... |
send a start packet (if we haven't sent one in the last second) | def tell_sender_to_start(self):
'''send a start packet (if we haven't sent one in the last second)'''
now = time.time()
if now - self.time_last_start_packet_sent < 1:
return
self.time_last_start_packet_sent = now
if self.log_settings.verbose:
print("DFLog... |
returns true if this packet is appropriately addressed | def packet_is_for_me(self, m):
'''returns true if this packet is appropriately addressed'''
if m.target_system != self.master.mav.srcSystem:
return False
if m.target_component != self.master.mav.srcComponent:
return False
# if have a sender we can also check the s... |
handle mavlink packets | def mavlink_packet(self, m):
'''handle mavlink packets'''
if m.get_type() == 'REMOTE_LOG_DATA_BLOCK':
if not self.packet_is_for_me(m):
self.dropped += 1
return
if self.sender is None and m.seqno == 0:
if self.log_settings.verbose:
... |
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.
"""
frame = FigureFrameWxAgg(num, figure)
figmgr = frame.get_figure_manager()
if matplotlib.is_interactive():
figmgr.frame.Show()
return figmgr |
Convert the region of the agg buffer bounded by bbox to a wx.Image. If
bbox is None, the entire buffer is converted.
Note: agg must be a backend_agg.RendererAgg instance. | def _convert_agg_to_wx_image(agg, bbox):
"""
Convert the region of the agg buffer bounded by bbox to a wx.Image. If
bbox is None, the entire buffer is converted.
Note: agg must be a backend_agg.RendererAgg instance.
"""
if bbox is None:
# agg => rgb -> image
image = wx.EmptyIma... |
Convert the region of the agg buffer bounded by bbox to a wx.Bitmap. If
bbox is None, the entire buffer is converted.
Note: agg must be a backend_agg.RendererAgg instance. | def _convert_agg_to_wx_bitmap(agg, bbox):
"""
Convert the region of the agg buffer bounded by bbox to a wx.Bitmap. If
bbox is None, the entire buffer is converted.
Note: agg must be a backend_agg.RendererAgg instance.
"""
if bbox is None:
# agg => rgba buffer -> bitmap
return w... |
Convert the region of a the agg buffer bounded by bbox to a wx.Bitmap.
Note: agg must be a backend_agg.RendererAgg instance. | def _WX28_clipped_agg_as_bitmap(agg, bbox):
"""
Convert the region of a the agg buffer bounded by bbox to a wx.Bitmap.
Note: agg must be a backend_agg.RendererAgg instance.
"""
l, b, width, height = bbox.bounds
r = l + width
t = b + height
srcBmp = wx.BitmapFromBufferRGBA(int(agg.width... |
Render the figure using agg. | def draw(self, drawDC=None):
"""
Render the figure using agg.
"""
DEBUG_MSG("draw()", 1, self)
FigureCanvasAgg.draw(self)
self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None)
self._isDrawn = True
self.gui_repaint(drawDC=drawDC) |
Transfer the region of the agg buffer defined by bbox to the display.
If bbox is None, the entire buffer is transferred. | def blit(self, bbox=None):
"""
Transfer the region of the agg buffer defined by bbox to the display.
If bbox is None, the entire buffer is transferred.
"""
if bbox is None:
self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None)
self.gui_repaint... |
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() |
set gcs location | def cmd_antenna(self, args):
'''set gcs location'''
if len(args) != 2:
if self.gcs_location is None:
print("GCS location not set")
else:
print("GCS location %s" % str(self.gcs_location))
return
self.gcs_location = (float(args[0]... |
handle an incoming mavlink packet | def mavlink_packet(self, m):
'''handle an incoming mavlink packet'''
if self.gcs_location is None and self.module('wp').wploader.count() > 0:
home = self.module('wp').get_home()
self.gcs_location = (home.x, home.y)
print("Antenna home set")
if self.gcs_locatio... |
start/stop RC calibration | def cmd_rccal(self, args):
'''start/stop RC calibration'''
if len(args) < 1:
self.print_cal_usage()
return
if (args[0] == "start"):
if len(args) > 1:
self.num_channels = int(args[1])
print("Calibrating %u channels" % self.num_chann... |
set RCx_TRIM | def cmd_rctrim(self, args):
'''set RCx_TRIM'''
if not 'RC_CHANNELS_RAW' in self.status.msgs:
print("No RC_CHANNELS_RAW to trim with")
return
m = self.status.msgs['RC_CHANNELS_RAW']
for ch in range(1,5):
self.param_set('RC%u_TRIM' % ch, getattr(m, 'chan... |
handle an incoming mavlink packet | def mavlink_packet(self, m):
'''handle an incoming mavlink packet'''
#do nothing if not caibrating
if (self.calibrating == False):
return
if m.get_type() == 'RC_CHANNELS_RAW':
for i in range(1,self.num_channels+1):
v = getattr(m, 'chan%u_raw' % i)... |
handle link commands | def cmd_signing(self, args):
'''handle link commands'''
usage = "signing: <setup|remove|disable|key> passphrase"
if len(args) == 0:
print(usage)
elif args[0] == 'setup':
self.cmd_signing_setup(args[1:])
elif args[0] == 'key':
self.cmd_signing_k... |
convert a passphrase to a 32 byte key | def passphrase_to_key(self, passphrase):
'''convert a passphrase to a 32 byte key'''
import hashlib
h = hashlib.new('sha256')
h.update(passphrase)
return h.digest() |
setup signing key on board | def cmd_signing_setup(self, args):
'''setup signing key on board'''
if len(args) == 0:
print("usage: signing setup passphrase")
return
if not self.master.mavlink20():
print("You must be using MAVLink2 for signing")
return
passphrase = args[... |
see if an unsigned packet should be allowed | def allow_unsigned(self, mav, msgId):
'''see if an unsigned packet should be allowed'''
if self.allow is None:
self.allow = {
mavutil.mavlink.MAVLINK_MSG_ID_RADIO : True,
mavutil.mavlink.MAVLINK_MSG_ID_RADIO_STATUS : True
}
if msgId in ... |
set signing key on connection | def cmd_signing_key(self, args):
'''set signing key on connection'''
if len(args) == 0:
print("usage: signing setup passphrase")
return
if not self.master.mavlink20():
print("You must be using MAVLink2 for signing")
return
passphrase = args... |
remove signing from server | def cmd_signing_remove(self, args):
'''remove signing from server'''
if not self.master.mavlink20():
print("You must be using MAVLink2 for signing")
return
self.master.mav.setup_signing_send(self.target_system, self.target_component, [0]*32, 0)
self.master.disable... |
#another drawing routine
#(taken from src/generic/renderg.cpp)
#Could port this later for animating the button when clicking
const wxCoord x = rect.x,
y = rect.y,
w = rect.width,
h = rect.height;
dc.SetBrush(*wxTRANSPARENT_BRUSH);
wxPen pen(*wxBLA... | def Draw(self, grid, attr, dc, rect, row, col, isSelected):
dc.SetBrush(wx.Brush(wx.SystemSettings.GetColour(
wx.SYS_COLOUR_BTNFACE)))
dc.DrawRectangle( rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight())
#draw a shaded rectangle to emulate a button
#(taken from src/... |
handle output commands | def cmd_output(self, args):
'''handle output commands'''
if len(args) < 1 or args[0] == "list":
self.cmd_output_list()
elif args[0] == "add":
if len(args) != 2:
print("Usage: output add OUTPUT")
return
self.cmd_output_add(args[1... |
list outputs | def cmd_output_list(self):
'''list outputs'''
print("%u outputs" % len(self.mpstate.mav_outputs))
for i in range(len(self.mpstate.mav_outputs)):
conn = self.mpstate.mav_outputs[i]
print("%u: %s" % (i, conn.address))
if len(self.mpstate.sysid_outputs) > 0:
... |
add new output | def cmd_output_add(self, args):
'''add new output'''
device = args[0]
print("Adding output %s" % device)
try:
conn = mavutil.mavlink_connection(device, input=False, source_system=self.settings.source_system)
conn.mav.srcComponent = self.settings.source_component
... |
add new output for a specific MAVLink sysID | def cmd_output_sysid(self, args):
'''add new output for a specific MAVLink sysID'''
sysid = int(args[0])
device = args[1]
print("Adding output %s for sysid %u" % (device, sysid))
try:
conn = mavutil.mavlink_connection(device, input=False, source_system=self.settings.s... |
remove an output | def cmd_output_remove(self, args):
'''remove an output'''
device = args[0]
for i in range(len(self.mpstate.mav_outputs)):
conn = self.mpstate.mav_outputs[i]
if str(i) == device or conn.address == device:
print("Removing output %s" % conn.address)
... |
called on idle | def idle_task(self):
'''called on idle'''
for m in self.mpstate.mav_outputs:
m.source_system = self.settings.source_system
m.mav.srcSystem = m.source_system
m.mav.srcComponent = self.settings.source_component |
child process - this holds all the GUI elements | def child_task(self):
'''child process - this holds all the GUI elements'''
mp_util.child_close_fds()
from MAVProxy.modules.lib import wx_processguard
from MAVProxy.modules.lib.wx_loader import wx
from MAVProxy.modules.mavproxy_map.mp_slipmap_ui import MPSlipMapFrame
st... |
set center of view | def set_center(self, lat, lon):
'''set center of view'''
self.object_queue.put(SlipCenter((lat,lon))) |
set follow on/off on an object | def set_follow_object(self, key, enable):
'''set follow on/off on an object'''
self.object_queue.put(SlipFollowObject(key, enable)) |
return next event or None | def get_event(self):
'''return next event or None'''
if self.event_queue.qsize() == 0:
return None
evt = self.event_queue.get()
while isinstance(evt, win_layout.WinLayout):
win_layout.set_layout(evt, self.set_layout)
if self.event_queue.qsize() == 0:
... |
handle layout command | def cmd_layout(self, args):
'''handle layout command'''
from MAVProxy.modules.lib import win_layout
if len(args) < 1:
print("usage: layout <save|load>")
return
if args[0] == "load":
win_layout.load_layout(self.mpstate.settings.vehicle_name)
eli... |
convert a PIL Image to a wx image | def PILTowx(pimg):
'''convert a PIL Image to a wx image'''
from MAVProxy.modules.lib.wx_loader import wx
wimg = wx.EmptyImage(pimg.size[0], pimg.size[1])
try:
wimg.SetData(pimg.convert('RGB').tobytes())
except NotImplementedError:
# old, removed method:
wimg.SetData(pimg.conv... |
return a path to store mavproxy data | def dot_mavproxy(name=None):
'''return a path to store mavproxy data'''
if 'HOME' not in os.environ:
dir = os.path.join(os.environ['LOCALAPPDATA'], '.mavproxy')
else:
dir = os.path.join(os.environ['HOME'], '.mavproxy')
mkdir_p(dir)
if name is None:
return dir
return os.pa... |
download a URL and return the content | def download_url(url):
'''download a URL and return the content'''
if sys.version_info.major < 3:
from urllib2 import urlopen as url_open
from urllib2 import URLError as url_error
else:
from urllib.request import urlopen as url_open
from urllib.error import URLError as url_er... |
download an array of files | def download_files(files):
'''download an array of files'''
for (url, file) in files:
print("Downloading %s as %s" % (url, file))
data = download_url(url)
if data is None:
continue
try:
open(file, mode='wb').write(data)
except Exception as e:
... |
null terminate a string for py3 | def null_term(str):
'''null terminate a string for py3'''
if sys.version_info.major < 3:
return str
if isinstance(str, bytes):
str = str.decode("utf-8")
idx = str.find("\0")
if idx != -1:
str = str[:idx]
return str |
decode one device ID. Used for 'devid' command in mavproxy and MAVExplorer | def decode_devid(devid, pname):
'''decode one device ID. Used for 'devid' command in mavproxy and MAVExplorer'''
devid = int(devid)
if devid == 0:
return
bus_type=devid & 0x07
bus=(devid>>3) & 0x1F
address=(devid>>8)&0xFF
devtype=(devid>>16)
bustypes = {
1: "I2C",
... |
This must return a (User, built) 2-tuple for the given LDAP user.
username is the Django-friendly username of the user. ldap_user.dn is
the user's DN and ldap_user.attrs contains all of their LDAP
attributes.
The returned User object may be an unsaved model instance. | def get_or_build_user(self, username, ldap_user):
"""
This must return a (User, built) 2-tuple for the given LDAP user.
username is the Django-friendly username of the user. ldap_user.dn is
the user's DN and ldap_user.attrs contains all of their LDAP
attributes.
The ret... |
Populates the Django user object using the default bind credentials. | def populate_user(self):
"""
Populates the Django user object using the default bind credentials.
"""
user = None
try:
# self.attrs will only be non-None if we were able to load this user
# from the LDAP directory, so this filters out nonexistent users.
... |
Binds to the LDAP server with the user's DN and password. Raises
AuthenticationFailed on failure. | def _authenticate_user_dn(self, password):
"""
Binds to the LDAP server with the user's DN and password. Raises
AuthenticationFailed on failure.
"""
if self.dn is None:
raise self.AuthenticationFailed("failed to map the username to a DN.")
try:
st... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.