_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q230500 | compile_all | train | def compile_all():
"""
Compile style.qrc using rcc, pyside-rcc and pyrcc4
"""
# print("Compiling for Qt: style.qrc -> style.rcc")
# os.system("rcc style.qrc -o style.rcc")
print("Compiling for PyQt4: style.qrc -> pyqt_style_rc.py")
os.system("pyrcc4 -py3 style.qrc -o pyqt_style_rc.py")
p... | python | {
"resource": ""
} |
q230501 | null_term | train | def null_term(str):
'''null terminate a string'''
idx = str.find("\0")
if idx != -1:
str = str[:idx]
return str | python | {
"resource": ""
} |
q230502 | DFReader_is_text_log | train | def DFReader_is_text_log(filename):
'''return True if a file appears to be a valid text log'''
f = open(filename)
ret = (f.read(8000).find('FMT, ') != -1)
f.close()
return ret | python | {
"resource": ""
} |
q230503 | DFMessage.get_msgbuf | train | def get_msgbuf(self):
'''create a binary message buffer for a message'''
values = []
for i in range(len(self.fmt.columns)):
if i >= len(self.fmt.msg_mults):
continue
mul = self.fmt.msg_mults[i]
name = self.fmt.columns[i]
if name == ... | python | {
"resource": ""
} |
q230504 | DFReaderClock_usec.find_time_base | train | def find_time_base(self, gps, first_us_stamp):
'''work out time basis for the log - even newer style'''
t = self._gpsTimeToTime(gps.GWk, gps.GMS)
self.set_timebase(t - gps.TimeUS*0.000001)
# this ensures FMT messages get appropriate timestamp:
self.timestamp = self.timebase + fir... | python | {
"resource": ""
} |
q230505 | DFReaderClock_msec.find_time_base | train | def find_time_base(self, gps, first_ms_stamp):
'''work out time basis for the log - new style'''
t = self._gpsTimeToTime(gps.Week, gps.TimeMS)
self.set_timebase(t - gps.T*0.001)
self.timestamp = self.timebase + first_ms_stamp*0.001 | python | {
"resource": ""
} |
q230506 | DFReaderClock_px4.find_time_base | train | def find_time_base(self, gps):
'''work out time basis for the log - PX4 native'''
t = gps.GPSTime * 1.0e-6
self.timebase = t - self.px4_timebase | python | {
"resource": ""
} |
q230507 | DFReaderClock_gps_interpolated.gps_message_arrived | train | def gps_message_arrived(self, m):
'''adjust time base from GPS message'''
# msec-style GPS message?
gps_week = getattr(m, 'Week', None)
gps_timems = getattr(m, 'TimeMS', None)
if gps_week is None:
# usec-style GPS message?
gps_week = getattr(m, 'GWk', None... | python | {
"resource": ""
} |
q230508 | DFReader._rewind | train | def _rewind(self):
'''reset state on rewind'''
self.messages = { 'MAV' : self }
self.flightmode = "UNKNOWN"
self.percent = 0
if self.clock:
self.clock.rewind_event() | python | {
"resource": ""
} |
q230509 | DFReader.init_clock | train | def init_clock(self):
'''work out time basis for the log'''
self._rewind()
# speculatively create a gps clock in case we don't find anything
# better
gps_clock = DFReaderClock_gps_interpolated()
self.clock = gps_clock
px4_msg_time = None
px4_msg_gps = N... | python | {
"resource": ""
} |
q230510 | DFReader._set_time | train | def _set_time(self, m):
'''set time for a message'''
# really just left here for profiling
m._timestamp = self.timestamp
if len(m._fieldnames) > 0 and self.clock is not None:
self.clock.set_message_timestamp(m) | python | {
"resource": ""
} |
q230511 | DFReader._add_msg | train | def _add_msg(self, m):
'''add a new message'''
type = m.get_type()
self.messages[type] = m
if self.clock:
self.clock.message_arrived(m)
if type == 'MSG':
if m.Message.find("Rover") != -1:
self.mav_type = mavutil.mavlink.MAV_TYPE_GROUND_RO... | python | {
"resource": ""
} |
q230512 | DFReader.recv_match | train | def recv_match(self, condition=None, type=None, blocking=False):
'''recv the next 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]
while True:
m = self.recv_msg(... | python | {
"resource": ""
} |
q230513 | DFReader.param | train | def param(self, name, default=None):
'''convenient function for returning an arbitrary MAVLink
parameter with a default'''
if not name in self.params:
return default
return self.params[name] | python | {
"resource": ""
} |
q230514 | MAVLink.cpu_load_send | train | def cpu_load_send(self, sensLoad, ctrlLoad, batVolt, force_mavlink1=False):
'''
Sensor and DSC control loads.
sensLoad : Sensor DSC Load (uint8_t)
ctrlLoad : Control DSC Load (uint8_t)
batVolt ... | python | {
"resource": ""
} |
q230515 | MAVLink.ctrl_srfc_pt_send | train | def ctrl_srfc_pt_send(self, target, bitfieldPt, force_mavlink1=False):
'''
This message sets the control surfaces for selective passthrough mode.
target : The system setting the commands (uint8_t)
bitfieldPt : Bitfield co... | python | {
"resource": ""
} |
q230516 | MAVLink.slugs_mobile_location_send | train | def slugs_mobile_location_send(self, target, latitude, longitude, force_mavlink1=False):
'''
Transmits the last known position of the mobile GS to the UAV. Very
relevant when Track Mobile is enabled
target : The system reporting the act... | python | {
"resource": ""
} |
q230517 | MAVLink.slugs_configuration_camera_send | train | def slugs_configuration_camera_send(self, target, idOrder, order, force_mavlink1=False):
'''
Control for camara.
target : The system setting the commands (uint8_t)
idOrder : ID 0: brightness 1: aperture 2: iris 3: ICR ... | python | {
"resource": ""
} |
q230518 | MAVLink.volt_sensor_send | train | def volt_sensor_send(self, r2Type, voltage, reading2, force_mavlink1=False):
'''
Transmits the readings from the voltage and current sensors
r2Type : It is the value of reading 2: 0 - Current, 1 - Foreward Sonar, 2 - Back Sonar, 3 - RPM (uint8_t)
... | python | {
"resource": ""
} |
q230519 | MAVLink.ptz_status_send | train | def ptz_status_send(self, zoom, pan, tilt, force_mavlink1=False):
'''
Transmits the actual Pan, Tilt and Zoom values of the camera unit
zoom : The actual Zoom Value (uint8_t)
pan : The Pan value in 10ths of degre... | python | {
"resource": ""
} |
q230520 | MAVLink.script_request_send | train | def script_request_send(self, target_system, target_component, seq, force_mavlink1=False):
'''
Request script item with the sequence number seq. The response of the
system to this message should be a SCRIPT_ITEM
message.
target_system ... | python | {
"resource": ""
} |
q230521 | MAVLink.script_count_send | train | def script_count_send(self, target_system, target_component, count, force_mavlink1=False):
'''
This message is emitted as response to SCRIPT_REQUEST_LIST by the MAV
to get the number of mission scripts.
target_system : System ID (uint8_t)
... | python | {
"resource": ""
} |
q230522 | MAVLink.script_current_send | train | def script_current_send(self, seq, force_mavlink1=False):
'''
This message informs about the currently active SCRIPT.
seq : Active Sequence (uint16_t)
'''
return self.send(self.script_current_encode(seq), force_mavli... | python | {
"resource": ""
} |
q230523 | generate | train | def generate(basename, xml_list):
'''generate complete MAVLink C implemenation'''
for idx in range(len(xml_list)):
xml = xml_list[idx]
xml.xml_idx = idx
generate_one(basename, xml)
copy_fixed_headers(basename, xml_list[0]) | python | {
"resource": ""
} |
q230524 | Pose3D.update | train | def update(self):
'''
Updates Pose3d.
'''
pos = Pose3d()
if self.hasproxy():
pose = self.proxy.getPose3DData()
pos.yaw = self.quat2Yaw(pose.q0, pose.q1, pose.q2, pose.q3)
pos.pitch = self.quat2Pitch(pose.q0, pose.q1, pose.q2, pose.q3)
... | python | {
"resource": ""
} |
q230525 | Pose3D.getPose3d | train | def getPose3d(self):
'''
Returns last Pose3d.
@return last JdeRobotTypes Pose3d saved
'''
self.lock.acquire()
pose = self.pose
self.lock.release()
return pose | python | {
"resource": ""
} |
q230526 | Pose3D.quat2Roll | train | def quat2Roll (self, qw, qx, qy, qz):
'''
Translates from Quaternion to Roll.
@param qw,qx,qy,qz: Quaternion values
@type qw,qx,qy,qz: float
@return Roll value translated from Quaternion
'''
rotateXa0=2.0*(qy*qz + qw*qx)
rotateXa1=qw*qw - qx*qx - qy*q... | python | {
"resource": ""
} |
q230527 | SpeechModule.kill_speech_dispatcher | train | def kill_speech_dispatcher(self):
'''kill speech dispatcher processs'''
if not 'HOME' in os.environ:
return
pidpath = os.path.join(os.environ['HOME'], '.speech-dispatcher',
'pid', 'speech-dispatcher.pid')
if os.path.exists(pidpath):
... | python | {
"resource": ""
} |
q230528 | SRTMDownloader.loadFileList | train | def loadFileList(self):
"""Load a previously created file list or create a new one if none is
available."""
try:
data = open(self.filelist_file, 'rb')
except IOError:
'''print "No SRTM cached file list. Creating new one!"'''
if self.offline == 0:
... | python | {
"resource": ""
} |
q230529 | SRTMTile._avg | train | def _avg(value1, value2, weight):
"""Returns the weighted average of two values and handles the case where
one value is None. If both values are None, None is returned.
"""
if value1 is None:
return value2
if value2 is None:
return value1
retur... | python | {
"resource": ""
} |
q230530 | SRTMTile.calcOffset | train | def calcOffset(self, x, y):
"""Calculate offset into data array. Only uses to test correctness
of the formula."""
# Datalayout
# X = longitude
# Y = latitude
# Sample for size 1201x1201
# ( 0/1200) ( 1/1200) ... (1199/1200) (1200/1200)
... | python | {
"resource": ""
} |
q230531 | SRTMTile.getPixelValue | train | def getPixelValue(self, x, y):
"""Get the value of a pixel from the data, handling voids in the
SRTM data."""
assert x < self.size, "x: %d<%d" % (x, self.size)
assert y < self.size, "y: %d<%d" % (y, self.size)
# Same as calcOffset, inlined for performance reasons
offs... | python | {
"resource": ""
} |
q230532 | SRTMTile.getAltitudeFromLatLon | train | def getAltitudeFromLatLon(self, lat, lon):
"""Get the altitude of a lat lon pair, using the four neighbouring
pixels for interpolation.
"""
# print "-----\nFromLatLon", lon, lat
lat -= self.lat
lon -= self.lon
# print "lon, lat", lon, lat
if lat < 0.0 ... | python | {
"resource": ""
} |
q230533 | mavmemlog.rewind | train | def rewind(self):
'''rewind to start'''
self._index = 0
self.percent = 0
self.messages = {}
self._flightmode_index = 0
self._timestamp = None
self.flightmode = None
self.params = {} | python | {
"resource": ""
} |
q230534 | MAVParmDict.mavset | train | def mavset(self, mav, name, value, retries=3):
'''set a parameter on a mavlink connection'''
got_ack = False
while retries > 0 and not got_ack:
retries -= 1
mav.param_set_send(name.upper(), float(value))
tstart = time.time()
while time.time() - tst... | python | {
"resource": ""
} |
q230535 | MAVParmDict.save | train | def save(self, filename, wildcard='*', verbose=False):
'''save parameters to a file'''
f = open(filename, mode='w')
k = list(self.keys())
k.sort()
count = 0
for p in k:
if p and fnmatch.fnmatch(str(p).upper(), wildcard.upper()):
f.write("%-16.1... | python | {
"resource": ""
} |
q230536 | MAVParmDict.load | train | def load(self, filename, wildcard='*', mav=None, check=True):
'''load parameters from a file'''
try:
f = open(filename, mode='r')
except:
print("Failed to open file '%s'" % filename)
return False
count = 0
changed = 0
for line in f:
... | python | {
"resource": ""
} |
q230537 | MAVParmDict.diff | train | def diff(self, filename, wildcard='*'):
'''show differences with another parameter file'''
other = MAVParmDict()
if not other.load(filename):
return
keys = sorted(list(set(self.keys()).union(set(other.keys()))))
for k in keys:
if not fnmatch.fnmatch(str(k)... | python | {
"resource": ""
} |
q230538 | generate | train | def generate(basename, xml_list):
'''generate complete MAVLink Java implemenation'''
for xml in xml_list:
generate_one(basename, xml)
generate_enums(basename, xml)
generate_MAVLinkMessage(basename, xml_list)
copy_fixed_headers(basename, xml_list[0]) | python | {
"resource": ""
} |
q230539 | MAVLink.aq_telemetry_f_encode | train | def aq_telemetry_f_encode(self, Index, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20):
'''
Sends up to 20 raw float values.
Index ... | python | {
"resource": ""
} |
q230540 | MessageConsole.close | train | def close(self):
'''close the console'''
self.close_event.set()
if self.is_alive():
self.child.join(2) | python | {
"resource": ""
} |
q230541 | RallyModule.cmd_rally_add | train | def cmd_rally_add(self, args):
'''handle rally add'''
if len(args) < 1:
alt = self.settings.rallyalt
else:
alt = float(args[0])
if len(args) < 2:
break_alt = self.settings.rally_breakalt
else:
break_alt = float(args[1])
if... | python | {
"resource": ""
} |
q230542 | RallyModule.cmd_rally_alt | train | def cmd_rally_alt(self, args):
'''handle rally alt change'''
if (len(args) < 2):
print("Usage: rally alt RALLYNUM newAlt <newBreakAlt>")
return
if not self.have_list:
print("Please list rally points first")
return
idx = int(args[0])
... | python | {
"resource": ""
} |
q230543 | RallyModule.cmd_rally_move | train | def cmd_rally_move(self, args):
'''handle rally move'''
if len(args) < 1:
print("Usage: rally move RALLYNUM")
return
if not self.have_list:
print("Please list rally points first")
return
idx = int(args[0])
if idx <= 0 or idx > self... | python | {
"resource": ""
} |
q230544 | RallyModule.cmd_rally | train | def cmd_rally(self, args):
'''rally point commands'''
#TODO: add_land arg
if len(args) < 1:
self.print_usage()
return
elif args[0] == "add":
self.cmd_rally_add(args[1:])
elif args[0] == "move":
self.cmd_rally_move(args[1:])
... | python | {
"resource": ""
} |
q230545 | RallyModule.mavlink_packet | train | def mavlink_packet(self, m):
'''handle incoming mavlink packet'''
type = m.get_type()
if type in ['COMMAND_ACK']:
if m.command == mavutil.mavlink.MAV_CMD_DO_GO_AROUND:
if (m.result == 0 and self.abort_ack_received == False):
self.say("Landing Abort... | python | {
"resource": ""
} |
q230546 | RallyModule.send_rally_point | train | def send_rally_point(self, i):
'''send rally points from fenceloader'''
p = self.rallyloader.rally_point(i)
p.target_system = self.target_system
p.target_component = self.target_component
self.master.mav.send(p) | python | {
"resource": ""
} |
q230547 | RallyModule.send_rally_points | train | def send_rally_points(self):
'''send rally points from rallyloader'''
self.mav_param.mavset(self.master,'RALLY_TOTAL',self.rallyloader.rally_count(),3)
for i in range(self.rallyloader.rally_count()):
self.send_rally_point(i) | python | {
"resource": ""
} |
q230548 | Bumper.getBumper | train | def getBumper(self):
'''
Returns last Bumper.
@return last JdeRobotTypes Bumper saved
'''
if self.hasproxy():
self.lock.acquire()
bumper = self.bumper
self.lock.release()
return bumper
return None | python | {
"resource": ""
} |
q230549 | imageMsg2Image | train | def imageMsg2Image(img, bridge):
'''
Translates from ROS Image to JderobotTypes Image.
@param img: ROS Image to translate
@param bridge: bridge to do translation
@type img: sensor_msgs.msg.Image
@type brige: CvBridge
@return a JderobotTypes.Image translated from img
'''
image = ... | python | {
"resource": ""
} |
q230550 | Images2Rgbd | train | def Images2Rgbd(rgb, d):
'''
Translates from ROS Images to JderobotTypes Rgbd.
@param rgb: ROS color Image to translate
@param d: ROS depth image to translate
@type rgb: ImageROS
@type d: ImageROS
@return a Rgbd translated from Images
'''
data = Rgbd()
data.color=imageMsg2... | python | {
"resource": ""
} |
q230551 | ListenerRgbd.__callback | train | def __callback (self, rgb, d):
'''
Callback function to receive and save Rgbd Scans.
@param rgb: ROS color Image to translate
@param d: ROS depth image to translate
@type rgb: ImageROS
@type d: ImageROS
'''
data = Images2Rgbd(rgb, d)
self.lo... | python | {
"resource": ""
} |
q230552 | ListenerRgbd.getRgbdData | train | def getRgbdData(self):
'''
Returns last RgbdData.
@return last JdeRobotTypes Rgbd saved
'''
self.lock.acquire()
data = self.data
self.lock.release()
return data | python | {
"resource": ""
} |
q230553 | MAVLink.fence_fetch_point_send | train | def fence_fetch_point_send(self, target_system, target_component, idx, force_mavlink1=False):
'''
Request a current fence point from MAV
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
idx... | python | {
"resource": ""
} |
q230554 | MAVLink.hwstatus_send | train | def hwstatus_send(self, Vcc, I2Cerr, force_mavlink1=False):
'''
Status of key hardware
Vcc : board voltage (mV) (uint16_t)
I2Cerr : I2C error count (uint8_t)
'''
return self.send(se... | python | {
"resource": ""
} |
q230555 | MAVLink.data16_send | train | def data16_send(self, type, len, data, force_mavlink1=False):
'''
Data packet, size 16
type : data type (uint8_t)
len : data length (uint8_t)
data : raw data (uint8_t)
... | python | {
"resource": ""
} |
q230556 | MAVLink.data32_send | train | def data32_send(self, type, len, data, force_mavlink1=False):
'''
Data packet, size 32
type : data type (uint8_t)
len : data length (uint8_t)
data : raw data (uint8_t)
... | python | {
"resource": ""
} |
q230557 | MAVLink.data64_send | train | def data64_send(self, type, len, data, force_mavlink1=False):
'''
Data packet, size 64
type : data type (uint8_t)
len : data length (uint8_t)
data : raw data (uint8_t)
... | python | {
"resource": ""
} |
q230558 | MAVLink.data96_send | train | def data96_send(self, type, len, data, force_mavlink1=False):
'''
Data packet, size 96
type : data type (uint8_t)
len : data length (uint8_t)
data : raw data (uint8_t)
... | python | {
"resource": ""
} |
q230559 | MAVLink.rally_fetch_point_send | train | def rally_fetch_point_send(self, target_system, target_component, idx, force_mavlink1=False):
'''
Request a current rally point from MAV. MAV should respond with a
RALLY_POINT message. MAV should not respond if the
request is invalid.
targ... | python | {
"resource": ""
} |
q230560 | MAVLink.battery2_send | train | def battery2_send(self, voltage, current_battery, force_mavlink1=False):
'''
2nd Battery status
voltage : voltage in millivolts (uint16_t)
current_battery : Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilo... | python | {
"resource": ""
} |
q230561 | MAVLink.gopro_heartbeat_send | train | 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 ... | python | {
"resource": ""
} |
q230562 | MAVLink.gopro_get_request_send | train | 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)
... | python | {
"resource": ""
} |
q230563 | MAVLink.gopro_get_response_send | train | 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 ... | python | {
"resource": ""
} |
q230564 | MAVLink.gopro_set_response_send | train | 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... | python | {
"resource": ""
} |
q230565 | MAVLink.rpm_send | train | 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), ... | python | {
"resource": ""
} |
q230566 | fgFDM.convert | train | 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... | python | {
"resource": ""
} |
q230567 | fgFDM.units | train | 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 | python | {
"resource": ""
} |
q230568 | fgFDM.variables | train | def variables(self):
'''return a list of available variables'''
return sorted(list(self.mapping.vars.keys()),
key = lambda v : self.mapping.vars[v].index) | python | {
"resource": ""
} |
q230569 | fgFDM.get | train | 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... | python | {
"resource": ""
} |
q230570 | fgFDM.set | train | 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... | python | {
"resource": ""
} |
q230571 | fgFDM.parse | train | 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) | python | {
"resource": ""
} |
q230572 | fgFDM.pack | train | 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) | python | {
"resource": ""
} |
q230573 | quat2Yaw | train | 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... | python | {
"resource": ""
} |
q230574 | quat2Pitch | train | 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
... | python | {
"resource": ""
} |
q230575 | odometry2Pose3D | train | 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... | python | {
"resource": ""
} |
q230576 | ListenerPose3d.__callback | train | 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() | python | {
"resource": ""
} |
q230577 | SlipObject.clip | train | 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... | python | {
"resource": ""
} |
q230578 | SlipObject.update_position | train | 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 | python | {
"resource": ""
} |
q230579 | SlipPolygon.clicked | train | 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
... | python | {
"resource": ""
} |
q230580 | SlipThumbnail.clicked | train | 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) | python | {
"resource": ""
} |
q230581 | SlipInfoImage.draw | train | 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() | python | {
"resource": ""
} |
q230582 | SlipInfoText._resize | train | 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 = ... | python | {
"resource": ""
} |
q230583 | SlipInfoText.draw | train | 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, ... | python | {
"resource": ""
} |
q230584 | App.button | train | 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)
... | python | {
"resource": ""
} |
q230585 | App.find_message | train | 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:
... | python | {
"resource": ""
} |
q230586 | App.slew | train | 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() | python | {
"resource": ""
} |
q230587 | GraphFrame.draw_plot | train | 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... | python | {
"resource": ""
} |
q230588 | set_close_on_exec | train | 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 | python | {
"resource": ""
} |
q230589 | mavlink_connection | train | 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... | python | {
"resource": ""
} |
q230590 | is_printable | train | 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 | python | {
"resource": ""
} |
q230591 | auto_detect_serial_win32 | train | 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... | python | {
"resource": ""
} |
q230592 | auto_detect_serial_unix | train | 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... | python | {
"resource": ""
} |
q230593 | auto_detect_serial | train | 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) | python | {
"resource": ""
} |
q230594 | mode_string_v09 | train | 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... | python | {
"resource": ""
} |
q230595 | mode_mapping_bynumber | train | 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... | python | {
"resource": ""
} |
q230596 | mode_string_v10 | train | 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... | python | {
"resource": ""
} |
q230597 | mavfile.auto_mavlink_version | train | 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... | python | {
"resource": ""
} |
q230598 | mavfile.select | train | 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
... | python | {
"resource": ""
} |
q230599 | mavfile.packet_loss | train | 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) | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.