INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Send a block of log data to remote location
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
seqno : log data block sequence number (uint32_t)
data : log data block... | def remote_log_data_block_encode(self, target_system, target_component, seqno, data):
'''
Send a block of log data to remote location
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
seqno ... |
Send a block of log data to remote location
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
seqno : log data block sequence number (uint32_t)
data : log data block... | def remote_log_data_block_send(self, target_system, target_component, seqno, data, force_mavlink1=False):
'''
Send a block of log data to remote location
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
... |
Send Status of each log block that autopilot board might have sent
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
seqno : log data block sequence number (uint32_t)
status ... | def remote_log_block_status_encode(self, target_system, target_component, seqno, status):
'''
Send Status of each log block that autopilot board might have sent
target_system : System ID (uint8_t)
target_component : Component ID (uint... |
Send Status of each log block that autopilot board might have sent
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
seqno : log data block sequence number (uint32_t)
status ... | def remote_log_block_status_send(self, target_system, target_component, seqno, status, force_mavlink1=False):
'''
Send Status of each log block that autopilot board might have sent
target_system : System ID (uint8_t)
target_component ... |
Control vehicle LEDs
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
instance : Instance (LED instance to control or 255 for all LEDs) (uint8_t)
pattern : Pattern (see L... | def led_control_encode(self, target_system, target_component, instance, pattern, custom_len, custom_bytes):
'''
Control vehicle LEDs
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
instanc... |
Control vehicle LEDs
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
instance : Instance (LED instance to control or 255 for all LEDs) (uint8_t)
pattern : Pattern (see L... | def led_control_send(self, target_system, target_component, instance, pattern, custom_len, custom_bytes, force_mavlink1=False):
'''
Control vehicle LEDs
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
... |
Reports progress of compass calibration.
compass_id : Compass being calibrated (uint8_t)
cal_mask : Bitmask of compasses being calibrated (uint8_t)
cal_status : Status (see MAG_CAL_STATUS enum) (uint8_t)
atte... | def mag_cal_progress_encode(self, compass_id, cal_mask, cal_status, attempt, completion_pct, completion_mask, direction_x, direction_y, direction_z):
'''
Reports progress of compass calibration.
compass_id : Compass being calibrated (uint8_t)
... |
Reports progress of compass calibration.
compass_id : Compass being calibrated (uint8_t)
cal_mask : Bitmask of compasses being calibrated (uint8_t)
cal_status : Status (see MAG_CAL_STATUS enum) (uint8_t)
atte... | def mag_cal_progress_send(self, compass_id, cal_mask, cal_status, attempt, completion_pct, completion_mask, direction_x, direction_y, direction_z, force_mavlink1=False):
'''
Reports progress of compass calibration.
compass_id : Compass being calibrated (ui... |
Reports results of completed compass calibration. Sent until
MAG_CAL_ACK received.
compass_id : Compass being calibrated (uint8_t)
cal_mask : Bitmask of compasses being calibrated (uint8_t)
cal_status : Statu... | def mag_cal_report_encode(self, compass_id, cal_mask, cal_status, autosaved, fitness, ofs_x, ofs_y, ofs_z, diag_x, diag_y, diag_z, offdiag_x, offdiag_y, offdiag_z):
'''
Reports results of completed compass calibration. Sent until
MAG_CAL_ACK received.
com... |
Reports results of completed compass calibration. Sent until
MAG_CAL_ACK received.
compass_id : Compass being calibrated (uint8_t)
cal_mask : Bitmask of compasses being calibrated (uint8_t)
cal_status : Statu... | def mag_cal_report_send(self, compass_id, cal_mask, cal_status, autosaved, fitness, ofs_x, ofs_y, ofs_z, diag_x, diag_y, diag_z, offdiag_x, offdiag_y, offdiag_z, force_mavlink1=False):
'''
Reports results of completed compass calibration. Sent until
MAG_CAL_ACK received.
... |
EKF Status message including flags and variances
flags : Flags (uint16_t)
velocity_variance : Velocity variance (float)
pos_horiz_variance : Horizontal Position variance (float)
pos_vert_variance : Vertical Posit... | def ekf_status_report_encode(self, flags, velocity_variance, pos_horiz_variance, pos_vert_variance, compass_variance, terrain_alt_variance):
'''
EKF Status message including flags and variances
flags : Flags (uint16_t)
velocity_varianc... |
EKF Status message including flags and variances
flags : Flags (uint16_t)
velocity_variance : Velocity variance (float)
pos_horiz_variance : Horizontal Position variance (float)
pos_vert_variance : Vertical Posit... | def ekf_status_report_send(self, flags, velocity_variance, pos_horiz_variance, pos_vert_variance, compass_variance, terrain_alt_variance, force_mavlink1=False):
'''
EKF Status message including flags and variances
flags : Flags (uint16_t)
... |
PID tuning information
axis : axis (uint8_t)
desired : desired rate (degrees/s) (float)
achieved : achieved rate (degrees/s) (float)
FF : FF component (float)
P... | def pid_tuning_encode(self, axis, desired, achieved, FF, P, I, D):
'''
PID tuning information
axis : axis (uint8_t)
desired : desired rate (degrees/s) (float)
achieved : achieved rate... |
PID tuning information
axis : axis (uint8_t)
desired : desired rate (degrees/s) (float)
achieved : achieved rate (degrees/s) (float)
FF : FF component (float)
P... | def pid_tuning_send(self, axis, desired, achieved, FF, P, I, D, force_mavlink1=False):
'''
PID tuning information
axis : axis (uint8_t)
desired : desired rate (degrees/s) (float)
achieved ... |
3 axis gimbal mesuraments
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
delta_time : Time since last update (seconds) (float)
delta_angle_x : Delta angle X (radians) (float)
... | def gimbal_report_encode(self, target_system, target_component, delta_time, delta_angle_x, delta_angle_y, delta_angle_z, delta_velocity_x, delta_velocity_y, delta_velocity_z, joint_roll, joint_el, joint_az):
'''
3 axis gimbal mesuraments
target_system : Syste... |
3 axis gimbal mesuraments
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
delta_time : Time since last update (seconds) (float)
delta_angle_x : Delta angle X (radians) (float)
... | def gimbal_report_send(self, target_system, target_component, delta_time, delta_angle_x, delta_angle_y, delta_angle_z, delta_velocity_x, delta_velocity_y, delta_velocity_z, joint_roll, joint_el, joint_az, force_mavlink1=False):
'''
3 axis gimbal mesuraments
target_system... |
Control message for rate gimbal
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
demanded_rate_x : Demanded angular rate X (rad/s) (float)
demanded_rate_y : Demanded angular rate Y (rad... | def gimbal_control_encode(self, target_system, target_component, demanded_rate_x, demanded_rate_y, demanded_rate_z):
'''
Control message for rate gimbal
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
... |
Control message for rate gimbal
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
demanded_rate_x : Demanded angular rate X (rad/s) (float)
demanded_rate_y : Demanded angular rate Y (rad... | def gimbal_control_send(self, target_system, target_component, demanded_rate_x, demanded_rate_y, demanded_rate_z, force_mavlink1=False):
'''
Control message for rate gimbal
target_system : System ID (uint8_t)
target_component : Compon... |
100 Hz gimbal torque command telemetry
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
rl_torque_cmd : Roll Torque Command (int16_t)
el_torque_cmd : Elevation Torque Command (int16... | def gimbal_torque_cmd_report_encode(self, target_system, target_component, rl_torque_cmd, el_torque_cmd, az_torque_cmd):
'''
100 Hz gimbal torque command telemetry
target_system : System ID (uint8_t)
target_component : Component ID (u... |
100 Hz gimbal torque command telemetry
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
rl_torque_cmd : Roll Torque Command (int16_t)
el_torque_cmd : Elevation Torque Command (int16... | def gimbal_torque_cmd_report_send(self, target_system, target_component, rl_torque_cmd, el_torque_cmd, az_torque_cmd, force_mavlink1=False):
'''
100 Hz gimbal torque command telemetry
target_system : System ID (uint8_t)
target_component ... |
Heartbeat from a HeroBus attached GoPro
status : Status (uint8_t)
capture_mode : Current capture mode (uint8_t)
flags : additional status bits (uint8_t) | def gopro_heartbeat_send(self, status, capture_mode, flags, force_mavlink1=False):
'''
Heartbeat from a HeroBus attached GoPro
status : Status (uint8_t)
capture_mode : Current capture mode (uint8_t)
flags ... |
Request a GOPRO_COMMAND response from the GoPro
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
cmd_id : Command ID (uint8_t) | def gopro_get_request_send(self, target_system, target_component, cmd_id, force_mavlink1=False):
'''
Request a GOPRO_COMMAND response from the GoPro
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
... |
Response from a GOPRO_COMMAND get request
cmd_id : Command ID (uint8_t)
status : Status (uint8_t)
value : Value (uint8_t) | def gopro_get_response_send(self, cmd_id, status, value, force_mavlink1=False):
'''
Response from a GOPRO_COMMAND get request
cmd_id : Command ID (uint8_t)
status : Status (uint8_t)
value ... |
Request to set a GOPRO_COMMAND with a desired
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
cmd_id : Command ID (uint8_t)
value : Value (uint8_t) | def gopro_set_request_encode(self, target_system, target_component, cmd_id, value):
'''
Request to set a GOPRO_COMMAND with a desired
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
cmd_id... |
Request to set a GOPRO_COMMAND with a desired
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
cmd_id : Command ID (uint8_t)
value : Value (uint8_t) | def gopro_set_request_send(self, target_system, target_component, cmd_id, value, force_mavlink1=False):
'''
Request to set a GOPRO_COMMAND with a desired
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
... |
Response from a GOPRO_COMMAND set request
cmd_id : Command ID (uint8_t)
status : Status (uint8_t) | def gopro_set_response_send(self, cmd_id, status, force_mavlink1=False):
'''
Response from a GOPRO_COMMAND set request
cmd_id : Command ID (uint8_t)
status : Status (uint8_t)
'''
retur... |
RPM sensor output
rpm1 : RPM Sensor1 (float)
rpm2 : RPM Sensor2 (float) | def rpm_send(self, rpm1, rpm2, force_mavlink1=False):
'''
RPM sensor output
rpm1 : RPM Sensor1 (float)
rpm2 : RPM Sensor2 (float)
'''
return self.send(self.rpm_encode(rpm1, rpm2), ... |
Static data to configure the ADS-B transponder (send within 10 sec of
a POR and every 10 sec thereafter)
ICAO : Vehicle address (24 bit) (uint32_t)
callsign : Vehicle identifier (8 characters, null terminated, valid characters are A-... | def uavionix_adsb_out_cfg_encode(self, ICAO, callsign, emitterType, aircraftSize, gpsOffsetLat, gpsOffsetLon, stallSpeed, rfSelect):
'''
Static data to configure the ADS-B transponder (send within 10 sec of
a POR and every 10 sec thereafter)
ICAO ... |
Static data to configure the ADS-B transponder (send within 10 sec of
a POR and every 10 sec thereafter)
ICAO : Vehicle address (24 bit) (uint32_t)
callsign : Vehicle identifier (8 characters, null terminated, valid characters are A-... | def uavionix_adsb_out_cfg_send(self, ICAO, callsign, emitterType, aircraftSize, gpsOffsetLat, gpsOffsetLon, stallSpeed, rfSelect, force_mavlink1=False):
'''
Static data to configure the ADS-B transponder (send within 10 sec of
a POR and every 10 sec thereafter)
... |
Dynamic data used to generate ADS-B out transponder data (send at 5Hz)
utcTime : UTC time in seconds since GPS epoch (Jan 6, 1980). If unknown set to UINT32_MAX (uint32_t)
gpsLat : Latitude WGS84 (deg * 1E7). If unknown set to INT32_MAX (int32_t)
... | def uavionix_adsb_out_dynamic_encode(self, utcTime, gpsLat, gpsLon, gpsAlt, gpsFix, numSats, baroAltMSL, accuracyHor, accuracyVert, accuracyVel, velVert, velNS, VelEW, emergencyStatus, state, squawk):
'''
Dynamic data used to generate ADS-B out transponder data (send at 5Hz)
... |
Dynamic data used to generate ADS-B out transponder data (send at 5Hz)
utcTime : UTC time in seconds since GPS epoch (Jan 6, 1980). If unknown set to UINT32_MAX (uint32_t)
gpsLat : Latitude WGS84 (deg * 1E7). If unknown set to INT32_MAX (int32_t)
... | def uavionix_adsb_out_dynamic_send(self, utcTime, gpsLat, gpsLon, gpsAlt, gpsFix, numSats, baroAltMSL, accuracyHor, accuracyVert, accuracyVel, velVert, velNS, VelEW, emergencyStatus, state, squawk, force_mavlink1=False):
'''
Dynamic data used to generate ADS-B out transponder data (send ... |
Transceiver heartbeat with health report (updated every 10s)
rfHealth : ADS-B transponder messages (uint8_t) | def uavionix_adsb_transceiver_health_report_send(self, rfHealth, force_mavlink1=False):
'''
Transceiver heartbeat with health report (updated every 10s)
rfHealth : ADS-B transponder messages (uint8_t)
'''
return self.send... |
convert a value from one set of units to another | def convert(self, value, fromunits, tounits):
'''convert a value from one set of units to another'''
if fromunits == tounits:
return value
if (fromunits,tounits) in self.unitmap:
return value * self.unitmap[(fromunits,tounits)]
if (tounits,fromunits) in self.unitm... |
return the default units of a variable | def units(self, varname):
'''return the default units of a variable'''
if not varname in self.mapping.vars:
raise fgFDMError('Unknown variable %s' % varname)
return self.mapping.vars[varname].units |
return a list of available variables | def variables(self):
'''return a list of available variables'''
return sorted(list(self.mapping.vars.keys()),
key = lambda v : self.mapping.vars[v].index) |
get a variable value | def get(self, varname, idx=0, units=None):
'''get a variable value'''
if not varname in self.mapping.vars:
raise fgFDMError('Unknown variable %s' % varname)
if idx >= self.mapping.vars[varname].arraylength:
raise fgFDMError('index of %s beyond end of array idx=%u arraylen... |
set a variable value | def set(self, varname, value, idx=0, units=None):
'''set a variable value'''
if not varname in self.mapping.vars:
raise fgFDMError('Unknown variable %s' % varname)
if idx >= self.mapping.vars[varname].arraylength:
raise fgFDMError('index of %s beyond end of array idx=%u a... |
parse a FD FDM buffer | def parse(self, buf):
'''parse a FD FDM buffer'''
try:
t = struct.unpack(self.pack_string, buf)
except struct.error as msg:
raise fgFDMError('unable to parse - %s' % msg)
self.values = list(t) |
pack a FD FDM buffer from current values | def pack(self):
'''pack a FD FDM buffer from current values'''
for i in range(len(self.values)):
if math.isnan(self.values[i]):
self.values[i] = 0
return struct.pack(self.pack_string, *self.values) |
Translates from Quaternion to Yaw.
@param qw,qx,qy,qz: Quaternion values
@type qw,qx,qy,qz: float
@return Yaw value translated from Quaternion | def quat2Yaw(qw, qx, qy, qz):
'''
Translates from Quaternion to Yaw.
@param qw,qx,qy,qz: Quaternion values
@type qw,qx,qy,qz: float
@return Yaw value translated from Quaternion
'''
rotateZa0=2.0*(qx*qy + qw*qz)
rotateZa1=qw*qw + qx*qx - qy*qy - qz*qz
rotateZ=0.0
if(rotateZa0... |
Translates from Quaternion to Pitch.
@param qw,qx,qy,qz: Quaternion values
@type qw,qx,qy,qz: float
@return Pitch value translated from Quaternion | def quat2Pitch(qw, qx, qy, qz):
'''
Translates from Quaternion to Pitch.
@param qw,qx,qy,qz: Quaternion values
@type qw,qx,qy,qz: float
@return Pitch value translated from Quaternion
'''
rotateYa0=-2.0*(qx*qz - qw*qy)
rotateY=0.0
if(rotateYa0 >= 1.0):
rotateY = pi/2.0
... |
Translates from ROS Odometry to JderobotTypes Pose3d.
@param odom: ROS Odometry to translate
@type odom: Odometry
@return a Pose3d translated from odom | def odometry2Pose3D(odom):
'''
Translates from ROS Odometry to JderobotTypes Pose3d.
@param odom: ROS Odometry to translate
@type odom: Odometry
@return a Pose3d translated from odom
'''
pose = Pose3d()
ori = odom.pose.pose.orientation
pose.x = odom.pose.pose.position.x
pos... |
Callback function to receive and save Pose3d.
@param odom: ROS Odometry received
@type odom: Odometry | def __callback (self, odom):
'''
Callback function to receive and save Pose3d.
@param odom: ROS Odometry received
@type odom: Odometry
'''
pose = odometry2Pose3D(odom)
self.lock.acquire()
self.data = pose
self.lock.release() |
Starts (Subscribes) the client. | def start (self):
'''
Starts (Subscribes) the client.
'''
self.sub = rospy.Subscriber(self.topic, Odometry, self.__callback) |
clip an area for display on the map | def clip(self, px, py, w, h, img):
'''clip an area for display on the map'''
sx = 0
sy = 0
if px < 0:
sx = -px
w += px
px = 0
if py < 0:
sy = -py
h += py
py = 0
if px+w > img.width:
w = i... |
update object position | def update_position(self, newpos):
'''update object position'''
if getattr(self, 'trail', None) is not None:
self.trail.update_position(newpos)
self.latlon = newpos.latlon
if hasattr(self, 'rotation'):
self.rotation = newpos.rotation |
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)
clipped = cv.ClipLine((img.width, img.height), pix1, pix2)
if clipped is None:
if len(self._pix_points) == 0:
s... |
draw a polygon on the image | def draw(self, img, pixmapper, bounds):
'''draw a polygon on the image'''
if self.hidden:
return
self._pix_points = []
for i in range(len(self.points)-1):
if len(self.points[i]) > 2:
colour = self.points[i][2]
else:
colo... |
see if the polygon has been clicked on.
Consider it clicked if the pixel is within 6 of the point | def clicked(self, px, py):
'''see if the polygon has been clicked on.
Consider it clicked if the pixel is within 6 of the point
'''
if self.hidden:
return None
for i in range(len(self._pix_points)):
if self._pix_points[i] is None:
continue
... |
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)
clipped = cv.ClipLine((img.width, img.height), pix1, pix2)
if clipped is None:
return
(pix1, pix2) = clipped
cv... |
draw a polygon on the image | def draw(self, img, pixmapper, bounds):
'''draw a polygon on the image'''
if self.hidden:
return
(x,y,w,h) = bounds
spacing = 1000
while True:
start = mp_util.latlon_round((x,y), spacing)
dist = mp_util.gps_distance(x,y,x+w,y+h)
cou... |
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 = cv.CreateImage((self.width, self.height), 8, 3)
cv.SetData(self._img, self.imgstr)
cv.CvtColor(self._img, self._img, cv.CV_BGR2RGB)
if self.border_w... |
see if the image has been clicked on | def clicked(self, px, py):
'''see if the image has been clicked on'''
if self.hidden:
return None
if (abs(px - self.posx) > self.width/2 or
abs(py - self.posy) > self.height/2):
return None
return math.sqrt((px-self.posx)**2 + (py-self.posy)**2) |
update trail | def update_position(self, newpos):
'''update trail'''
tnow = time.time()
if tnow >= self.last_time + self.timestep:
self.points.append(newpos.latlon)
self.last_time = tnow
while len(self.points) > self.count:
self.points.pop(0) |
draw the trail | def draw(self, img, pixmapper, bounds):
'''draw the trail'''
for p in self.points:
(px,py) = pixmapper(p)
if px >= 0 and py >= 0 and px < img.width and py < img.height:
cv.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 = cv.CreateMat(2, 3, cv.CV_32FC1)
cv.GetRotationMatrix2D((self.width/2,self.height/2),
-self.rotation, 1.0,... |
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
px -= ... |
return a wx image | def img(self):
'''return a wx image'''
import wx
img = wx.EmptyImage(self.width, self.height)
img.SetData(self.imgstr)
return img |
redraw the image | def draw(self, parent, box):
'''redraw the image'''
import wx
from MAVProxy.modules.lib import mp_widgets
if self.imgpanel is None:
self.imgpanel = mp_widgets.ImagePanel(parent, self.img())
box.Add(self.imgpanel, flag=wx.LEFT, border=0)
box.Layout() |
update the image | def update(self, newinfo):
'''update the image'''
self.imgstr = newinfo.imgstr
self.width = newinfo.width
self.height = newinfo.height
if self.imgpanel is not None:
self.imgpanel.set_image(self.img()) |
calculate and set text size, handling multi-line | def _resize(self):
'''calculate and set text size, handling multi-line'''
lines = self.text.split('\n')
xsize, ysize = 0, 0
for line in lines:
size = self.textctrl.GetTextExtent(line)
xsize = max(xsize, size[0])
ysize = ysize + size[1]
xsize = ... |
redraw the text | def draw(self, parent, box):
'''redraw the text'''
import wx
if self.textctrl is None:
self.textctrl = wx.TextCtrl(parent, style=wx.TE_MULTILINE|wx.TE_READONLY)
self.textctrl.WriteText(self.text)
self._resize()
box.Add(self.textctrl, flag=wx.LEFT, ... |
update the image | def update(self, newinfo):
'''update the image'''
self.text = newinfo.text
if self.textctrl is not None:
self.textctrl.Clear()
self.textctrl.WriteText(self.text)
self._resize() |
Application entry point | def main():
"""
Application entry point
"""
logging.basicConfig(level=logging.DEBUG)
# create the application and the main window
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QMainWindow()
# setup ui
ui = example_ui.Ui_MainWindow()
ui.setupUi(window)
ui.bt_delay... |
return pixel coordinates in the map image for a (lat,lon) | def pixel_coords(latlon, ground_width=0, mt=None, topleft=None, width=None):
'''return pixel coordinates in the map image for a (lat,lon)'''
(lat,lon) = (latlon[0], latlon[1])
return mt.coord_to_pixel(topleft[0], topleft[1], width, ground_width, lat, lon) |
create path and mission as an image file | def create_imagefile(options, filename, latlon, ground_width, path_objs, mission_obj, fence_obj, width=600, height=600):
'''create path and mission as an image file'''
mt = mp_tile.MPTile(service=options.service)
map_img = mt.area_to_image(latlon[0], latlon[1],
width, height,... |
display the waypoints | def display_waypoints(wploader, map):
'''display the waypoints'''
mission_list = wploader.view_list()
polygons = wploader.polygon_list()
map.add_object(mp_slipmap.SlipClearLayer('Mission'))
for i in range(len(polygons)):
p = polygons[i]
if len(p) > 1:
map.add_object(mp_sl... |
create a map for a log file | def mavflightview_mav(mlog, options=None, title=None):
'''create a map for a log file'''
if not title:
title='MAVFlightView'
wp = mavwp.MAVWPLoader()
if options.mission is not None:
wp.load(options.mission)
fen = mavwp.MAVFenceLoader()
if options.fence is not None:
fen.lo... |
return an image from the images/ directory | def LoadImage(filename):
'''return an image from the images/ directory'''
app_dir = os.path.dirname(os.path.realpath(__file__))
path = os.path.join(app_dir, 'images', filename)
return Tkinter.PhotoImage(file=path) |
add a button | def button(self, name, filename, command):
'''add a button'''
try:
img = LoadImage(filename)
b = Tkinter.Button(self.frame, image=img, command=command)
b.image = img
except Exception:
b = Tkinter.Button(self.frame, text=filename, command=command)
... |
rewind 10% | def rewind(self):
'''rewind 10%'''
pos = int(self.mlog.f.tell() - 0.1*self.filesize)
if pos < 0:
pos = 0
self.mlog.f.seek(pos)
self.find_message() |
show status | def status(self):
'''show status'''
for m in sorted(self.mlog.messages.keys()):
print(str(self.mlog.messages[m])) |
find the next valid message | def find_message(self):
'''find the next valid message'''
while True:
self.msg = self.mlog.recv_match(condition=args.condition)
if self.msg is not None and self.msg.get_type() != 'BAD_DATA':
break
if self.mlog.f.tell() > self.filesize - 10:
... |
move to a given position in the file | def slew(self, value):
'''move to a given position in the file'''
if float(value) != self.filepos:
pos = float(value) * self.filesize
self.mlog.f.seek(int(pos))
self.find_message() |
called as each msg is ready | def next_message(self):
'''called as each msg is ready'''
msg = self.msg
if msg is None:
self.paused = True
if self.paused:
self.root.after(100, self.next_message)
return
try:
speed = float(self.playback.get())
except:
... |
Redraws the plot | def draw_plot(self):
""" Redraws the plot
"""
import numpy, pylab
state = self.state
if len(self.data[0]) == 0:
print("no data to plot")
return
vhigh = max(self.data[0])
vlow = min(self.data[0])
for i in range(1,len(self.plot_dat... |
evaluation a conditional (boolean) statement | def evaluate_condition(condition, vars):
'''evaluation a conditional (boolean) statement'''
if condition is None:
return True
v = evaluate_expression(condition, vars)
if v is None:
return False
return v |
set the MAVLink dialect to work with.
For example, set_dialect("ardupilotmega") | def set_dialect(dialect):
'''set the MAVLink dialect to work with.
For example, set_dialect("ardupilotmega")
'''
global mavlink, current_dialect
from .generator import mavparse
if 'MAVLINK20' in os.environ:
wire_protocol = mavparse.PROTOCOL_2_0
modname = "pymavlink.dialects.v20."... |
set the clone on exec flag on a file descriptor. Ignore exceptions | def set_close_on_exec(fd):
'''set the clone on exec flag on a file descriptor. Ignore exceptions'''
try:
import fcntl
flags = fcntl.fcntl(fd, fcntl.F_GETFD)
flags |= fcntl.FD_CLOEXEC
fcntl.fcntl(fd, fcntl.F_SETFD, flags)
except Exception:
pass |
open a serial, UDP, TCP or file mavlink connection | def mavlink_connection(device, baud=115200, source_system=255,
planner_format=None, write=False, append=False,
robust_parsing=True, notimestamps=False, input=True,
dialect=None, autoreconnect=False, zero_time_base=False,
retries... |
see if a character is printable | def is_printable(c):
'''see if a character is printable'''
global have_ascii
if have_ascii:
return ascii.isprint(c)
if isinstance(c, int):
ic = c
else:
ic = ord(c)
return ic >= 32 and ic <= 126 |
try to auto-detect serial ports on win32 | def auto_detect_serial_win32(preferred_list=['*']):
'''try to auto-detect serial ports on win32'''
try:
from serial.tools.list_ports_windows import comports
list = sorted(comports())
except:
return []
ret = []
others = []
for port, description, hwid in list:
match... |
try to auto-detect serial ports on unix | def auto_detect_serial_unix(preferred_list=['*']):
'''try to auto-detect serial ports on unix'''
import glob
glist = glob.glob('/dev/ttyS*') + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') + glob.glob('/dev/serial/by-id/*')
ret = []
others = []
# try preferred ones first
for d in gli... |
try to auto-detect serial port | def auto_detect_serial(preferred_list=['*']):
'''try to auto-detect serial port'''
# see if
if os.name == 'nt':
return auto_detect_serial_win32(preferred_list=preferred_list)
return auto_detect_serial_unix(preferred_list=preferred_list) |
mode string for 0.9 protocol | def mode_string_v09(msg):
'''mode string for 0.9 protocol'''
mode = msg.mode
nav_mode = msg.nav_mode
MAV_MODE_UNINIT = 0
MAV_MODE_MANUAL = 2
MAV_MODE_GUIDED = 3
MAV_MODE_AUTO = 4
MAV_MODE_TEST1 = 5
MAV_MODE_TEST2 = 6
MAV_MODE_TEST3 = 7
MAV_NAV_GROUNDED = 0
MAV_NAV_LIFTO... |
return dictionary mapping mode names to numbers, or None if unknown | def mode_mapping_byname(mav_type):
'''return dictionary mapping mode names to numbers, or None if unknown'''
map = None
if mav_type in [mavlink.MAV_TYPE_QUADROTOR,
mavlink.MAV_TYPE_HELICOPTER,
mavlink.MAV_TYPE_HEXAROTOR,
mavlink.MAV_TYPE_OCTOROTOR,... |
return dictionary mapping mode numbers to name, or None if unknown | def mode_mapping_bynumber(mav_type):
'''return dictionary mapping mode numbers to name, or None if unknown'''
map = None
if mav_type in [mavlink.MAV_TYPE_QUADROTOR,
mavlink.MAV_TYPE_HELICOPTER,
mavlink.MAV_TYPE_HEXAROTOR,
mavlink.MAV_TYPE_OCTOROTOR... |
mode string for 1.0 protocol, from heartbeat | def mode_string_v10(msg):
'''mode string for 1.0 protocol, from heartbeat'''
if msg.autopilot == mavlink.MAV_AUTOPILOT_PX4:
return interpret_px4_mode(msg.base_mode, msg.custom_mode)
if not msg.base_mode & mavlink.MAV_MODE_FLAG_CUSTOM_MODE_ENABLED:
return "Mode(0x%08x)" % msg.base_mode
if... |
auto-switch mavlink protocol version | def auto_mavlink_version(self, buf):
'''auto-switch mavlink protocol version'''
global mavlink
if len(buf) == 0:
return
try:
magic = ord(buf[0])
except:
magic = buf[0]
if not magic in [ 85, 254, 253 ]:
return
self.fi... |
wait for up to timeout seconds for more data | def select(self, timeout):
'''wait for up to timeout seconds for more data'''
if self.fd is None:
time.sleep(min(timeout,0.5))
return True
try:
(rin, win, xin) = select.select([self.fd], [], [], timeout)
except select.error:
return False
... |
default post message call | def post_message(self, msg):
'''default post message call'''
if '_posted' in msg.__dict__:
return
msg._posted = True
msg._timestamp = time.time()
type = msg.get_type()
if type != 'HEARTBEAT' or (msg.type != mavlink.MAV_TYPE_GCS and msg.type != mavlink.MAV_TYPE... |
packet loss as a percentage | def packet_loss(self):
'''packet loss as a percentage'''
if self.mav_count == 0:
return 0
return (100.0*self.mav_loss)/(self.mav_count+self.mav_loss) |
message receive routine | def recv_msg(self):
'''message receive routine'''
self.pre_message()
while True:
n = self.mav.bytes_needed()
s = self.recv(n)
numnew = len(s)
if numnew != 0:
if self.logfile_raw:
self.logfile_raw.write(str(s))
... |
recv the next MAVLink message that matches the given condition
type can be a string or a list of strings | def recv_match(self, condition=None, type=None, blocking=False, timeout=None):
'''recv the next MAVLink message that matches the given condition
type can be a string or a list of strings'''
if type is not None and not isinstance(type, list):
type = [type]
start_time = time.ti... |
start logging to the given logfile, with timestamps | def setup_logfile(self, logfile, mode='w'):
'''start logging to the given logfile, with timestamps'''
self.logfile = open(logfile, mode=mode) |
start logging raw bytes to the given logfile, without timestamps | def setup_logfile_raw(self, logfile, mode='w'):
'''start logging raw bytes to the given logfile, without timestamps'''
self.logfile_raw = open(logfile, mode=mode) |
initiate fetch of all parameters | def param_fetch_all(self):
'''initiate fetch of all parameters'''
if time.time() - getattr(self, 'param_fetch_start', 0) < 2.0:
# don't fetch too often
return
self.param_fetch_start = time.time()
self.param_fetch_in_progress = True
self.mav.param_request_l... |
initiate fetch of one parameter | def param_fetch_one(self, name):
'''initiate fetch of one parameter'''
try:
idx = int(name)
self.mav.param_request_read_send(self.target_system, self.target_component, "", idx)
except Exception:
self.mav.param_request_read_send(self.target_system, self.target_... |
return the time since the last message of type mtype was received | def time_since(self, mtype):
'''return the time since the last message of type mtype was received'''
if not mtype in self.messages:
return time.time() - self.start_time
return time.time() - self.messages[mtype]._timestamp |
wrapper for parameter set | def param_set_send(self, parm_name, parm_value, parm_type=None):
'''wrapper for parameter set'''
if self.mavlink10():
if parm_type == None:
parm_type = mavlink.MAVLINK_TYPE_FLOAT
self.mav.param_set_send(self.target_system, self.target_component,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.