本文整理汇总了Python中cflib.crazyflie.log.LogConfig.start方法的典型用法代码示例。如果您正苦于以下问题:Python LogConfig.start方法的具体用法?Python LogConfig.start怎么用?Python LogConfig.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cflib.crazyflie.log.LogConfig
的用法示例。
在下文中一共展示了LogConfig.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connected
# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import start [as 别名]
def connected(self, linkURI):
# IMU & THRUST
lg = LogConfig("Stabalizer", GuiConfig().get("ui_update_period"))
lg.add_variable("stabilizer.roll", "float")
lg.add_variable("stabilizer.pitch", "float")
lg.add_variable("stabilizer.yaw", "float")
lg.add_variable("stabilizer.thrust", "uint16_t")
self.helper.cf.log.add_config(lg)
if (lg.valid):
lg.data_received_cb.add_callback(self._imu_data_signal.emit)
lg.error_cb.add_callback(self._log_error_signal.emit)
lg.start()
else:
logger.warning("Could not setup logconfiguration after "
"connection!")
# MOTOR
lg = LogConfig("Motors", GuiConfig().get("ui_update_period"))
lg.add_variable("motor.m1")
lg.add_variable("motor.m2")
lg.add_variable("motor.m3")
lg.add_variable("motor.m4")
self.helper.cf.log.add_config(lg)
if lg.valid:
lg.data_received_cb.add_callback(self._motor_data_signal.emit)
lg.error_cb.add_callback(self._log_error_signal.emit)
lg.start()
else:
logger.warning("Could not setup logconfiguration after "
"connection!")
示例2: connected
# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import start [as 别名]
def connected(self, linkURI):
# IMU & THRUST
lg = LogConfig("Stabilizer", Config().get("ui_update_period"))
lg.add_variable("stabilizer.roll", "float")
lg.add_variable("stabilizer.pitch", "float")
lg.add_variable("stabilizer.yaw", "float")
lg.add_variable("stabilizer.thrust", "uint16_t")
try:
self.helper.cf.log.add_config(lg)
lg.data_received_cb.add_callback(self._imu_data_signal.emit)
lg.error_cb.add_callback(self._log_error_signal.emit)
lg.start()
except KeyError as e:
logger.warning(str(e))
except AttributeError as e:
logger.warning(str(e))
# MOTOR
lg = LogConfig("Motors", Config().get("ui_update_period"))
lg.add_variable("motor.m1")
lg.add_variable("motor.m2")
lg.add_variable("motor.m3")
lg.add_variable("motor.m4")
try:
self.helper.cf.log.add_config(lg)
lg.data_received_cb.add_callback(self._motor_data_signal.emit)
lg.error_cb.add_callback(self._log_error_signal.emit)
lg.start()
except KeyError as e:
logger.warning(str(e))
except AttributeError as e:
logger.warning(str(e))
示例3: start_position_printing
# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import start [as 别名]
def start_position_printing(scf):
log_conf = LogConfig(name='Position', period_in_ms=500)
log_conf.add_variable('kalman.stateX', 'float')
log_conf.add_variable('kalman.stateY', 'float')
log_conf.add_variable('kalman.stateZ', 'float')
scf.cf.log.add_config(log_conf)
log_conf.data_received_cb.add_callback(position_callback)
log_conf.start()
示例4: _connected
# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import start [as 别名]
def _connected(self, link_uri):
lg = LogConfig("GPS", 1000)
lg.add_variable("gps.lat", "float")
lg.add_variable("gps.long", "float")
lg.add_variable("gps.alt", "float")
self._cf.log.add_config(lg)
if lg.valid:
lg.data_received_cb.add_callback(self._log_data_signal.emit)
lg.error_cb.add_callback(self._log_error_signal.emit)
lg.start()
else:
logger.warning("Could not setup logging block for GPS!")
示例5: __init__
# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import start [as 别名]
class CFLog:
def __init__(self):
self.status = CFStatus()
def start(self, cf):
self._lc_stab = LogConfig(name="Log-Stab", period_in_ms=50)
self._lc_stab.add_variable("stabilizer.roll", "float")
self._lc_stab.add_variable("stabilizer.pitch", "float")
self._lc_stab.add_variable("stabilizer.yaw", "float")
self._lc_stab.add_variable("stabilizer.thrust", "float")
self._lc_motor = LogConfig(name="Log-Motor", period_in_ms=50)
self._lc_motor.add_variable("pm.vbat", "float")
self._lc_motor.add_variable("motor.m1", "float") # Front (green)
self._lc_motor.add_variable("motor.m2", "float") # Right
self._lc_motor.add_variable("motor.m3", "float") # Back (red)
self._lc_motor.add_variable("motor.m4", "float") # Left
cf.log.add_config(self._lc_stab)
cf.log.add_config(self._lc_motor)
if self._lc_stab.valid and self._lc_motor.valid:
self._lc_stab.data_received_cb.add_callback(self._log_data)
self._lc_stab.error_cb.add_callback(self._log_error)
self._lc_stab.start()
self._lc_motor.data_received_cb.add_callback(self._log_data)
self._lc_motor.error_cb.add_callback(self._log_error)
self._lc_motor.start()
logger.info("Starting CFLog")
else:
logger.error("Could not add logconfig since some variables are not in TOC")
def stop(self):
self._lc_stab.stop()
def _log_error(self, logconf, msg):
"""Callback from the log API when an error occurs"""
logger.info("Error when logging %s: %s" % (logconf.name, msg))
def _log_data(self, timestamp, data, logconf):
"""Callback froma the log API when data arrives"""
if logconf.name == "Log-Stab":
self.status.pitch = data["stabilizer.pitch"]
self.status.roll = data["stabilizer.roll"]
self.status.yaw = data["stabilizer.yaw"]
self.status.thrust = data["stabilizer.thrust"]
else:
self.status.bat = data["pm.vbat"]
self.status.motor_1 = data["motor.m1"]
self.status.motor_2 = data["motor.m2"]
self.status.motor_3 = data["motor.m3"]
self.status.motor_4 = data["motor.m4"]
logger.info("%s" % self.status)
示例6: _connected
# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import start [as 别名]
def _connected(self, linkURI):
self._update_ui_state(UIState.CONNECTED, linkURI)
Config().set("link_uri", str(linkURI))
lg = LogConfig("Battery", 1000)
lg.add_variable("pm.vbat", "float")
try:
self.cf.log.add_config(lg)
lg.data_received_cb.add_callback(self.batteryUpdatedSignal.emit)
lg.error_cb.add_callback(self._log_error_signal.emit)
lg.start()
except KeyError as e:
logger.warning(str(e))
示例7: connectionDone
# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import start [as 别名]
def connectionDone(self, linkURI):
self.setUIState(UIState.CONNECTED, linkURI)
GuiConfig().set("link_uri", linkURI)
lg = LogConfig("Battery", 1000)
lg.add_variable("pm.vbat", "float")
self.cf.log.add_config(lg)
if lg.valid:
lg.data_received_cb.add_callback(self.batteryUpdatedSignal.emit)
lg.error_cb.add_callback(self._log_error_signal.emit)
lg.start()
else:
logger.warning("Could not setup loggingblock!")
示例8: connected
# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import start [as 别名]
def connected(self, linkURI):
# IMU & THRUST
lg = LogConfig("Stabalizer", GuiConfig().get("ui_update_period"))
lg.add_variable("stabilizer.roll", "float")
lg.add_variable("stabilizer.pitch", "float")
lg.add_variable("stabilizer.yaw", "float")
lg.add_variable("stabilizer.thrust", "uint16_t")
lg.add_variable("acc.x", "float")
lg.add_variable("acc.y", "float")
lg.add_variable("acc.z", "float")
self.helper.cf.log.add_config(lg)
if (lg.valid):
lg.data_received_cb.add_callback(self._imu_data_signal.emit)
lg.error_cb.add_callback(self._log_error_signal.emit)
lg.start()
else:
logger.warning("Could not setup logconfiguration after "
"connection!")
# MOTOR
lg = LogConfig("Motors", GuiConfig().get("ui_update_period"))
lg.add_variable("motor.m1")
lg.add_variable("motor.m2")
lg.add_variable("motor.m3")
lg.add_variable("motor.m4")
self.helper.cf.log.add_config(lg)
if lg.valid:
lg.data_received_cb.add_callback(self._motor_data_signal.emit)
lg.error_cb.add_callback(self._log_error_signal.emit)
lg.start()
else:
logger.warning("Could not setup logconfiguration after "
"connection!")
# Acc for freefall
lg = LogConfig("Acc", 10) # Yes we need this at 100hz for freefall detection!!
lg.add_variable("acc.zw", "float")
self.helper.cf.log.add_config(lg)
if lg.valid:
lg.data_received_cb.add_callback(self._acc_data_signal.emit)
lg.error_cb.add_callback(self._log_error_signal.emit)
lg.start()
else:
logger.warning("Could not setup logconfiguration after connection [ACC]!")
lg = LogConfig("Magnetometer", 100)
lg.add_variable("mag.x", "int16_t")
lg.add_variable("mag.y", "int16_t")
lg.add_variable("mag.z", "int16_t")
self.helper.cf.log.add_config(lg)
if lg.valid:
lg.data_received_cb.add_callback(self._mag_data_signal.emit)
lg.error_cb.add_callback(self._log_error_signal.emit)
lg.start()
else:
logger.warning("Could not setup logconfiguration after connection!")
示例9: _register_logblock
# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import start [as 别名]
def _register_logblock(self, logblock_name, variables, data_cb, error_cb,
update_period=UPDATE_PERIOD_LOG):
"""Register log data to listen for. One logblock can contain a limited
number of parameters (6 for floats)."""
lg = LogConfig(logblock_name, update_period)
for variable in variables:
if self._is_in_log_toc(variable):
lg.add_variable('{}.{}'.format(variable[0], variable[1]),
variable[2])
self._helper.cf.log.add_config(lg)
lg.data_received_cb.add_callback(data_cb)
lg.error_cb.add_callback(error_cb)
lg.start()
return lg
示例10: _connected
# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import start [as 别名]
def _connected(self, linkURI):
self._update_ui_state(UIState.CONNECTED, linkURI)
Config().set("link_uri", str(linkURI))
lg = LogConfig("Battery", 1000)
lg.add_variable("pm.vbat", "float")
try:
self.cf.log.add_config(lg)
lg.data_received_cb.add_callback(self.batteryUpdatedSignal.emit)
lg.error_cb.add_callback(self._log_error_signal.emit)
lg.start()
except KeyError as e:
logger.warning(str(e))
mem = self.cf.mem.get_mems(MemoryElement.TYPE_DRIVER_LED)[0]
mem.write_data(self._led_write_done)
示例11: _connected
# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import start [as 别名]
def _connected(self, link_uri):
lg = LogConfig("GPS", 100)
lg.add_variable("gps.lat")
lg.add_variable("gps.lon")
lg.add_variable("gps.hMSL")
lg.add_variable("gps.heading")
lg.add_variable("gps.gSpeed")
lg.add_variable("gps.hAcc")
lg.add_variable("gps.fixType")
self._cf.log.add_config(lg)
if lg.valid:
lg.data_received_cb.add_callback(self._log_data_signal.emit)
lg.error_cb.add_callback(self._log_error_signal.emit)
lg.start()
else:
logger.warning("Could not setup logging block for GPS!")
self._max_speed = 0.0
示例12: _connected
# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import start [as 别名]
def _connected(self, link_uri):
lg = LogConfig("GPS", 100)
lg.add_variable("gps.lat")
lg.add_variable("gps.lon")
lg.add_variable("gps.hMSL")
lg.add_variable("gps.heading")
lg.add_variable("gps.gSpeed")
lg.add_variable("gps.hAcc")
lg.add_variable("gps.fixType")
try:
self._cf.log.add_config(lg)
lg.data_received_cb.add_callback(self._log_data_signal.emit)
lg.error_cb.add_callback(self._log_error_signal.emit)
lg.start()
except KeyError as e:
logger.warning(str(e))
except AttributeError as e:
logger.warning(str(e))
self._max_speed = 0.0
示例13: _connected
# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import start [as 别名]
def _connected(self):
self.uiState = UIState.CONNECTED
self._update_ui_state()
Config().set("link_uri", str(self._selected_interface))
lg = LogConfig("Battery", 1000)
lg.add_variable("pm.vbat", "float")
lg.add_variable("pm.state", "int8_t")
try:
self.cf.log.add_config(lg)
lg.data_received_cb.add_callback(self.batteryUpdatedSignal.emit)
lg.error_cb.add_callback(self._log_error_signal.emit)
lg.start()
except KeyError as e:
logger.warning(str(e))
mems = self.cf.mem.get_mems(MemoryElement.TYPE_DRIVER_LED)
if len(mems) > 0:
mems[0].write_data(self._led_write_done)
示例14: connected
# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import start [as 别名]
def connected(self, URI):
print('We are now connected to {}'.format(URI))
# The definition of the logconfig can be made before connecting
lpos = LogConfig(name='Position', period_in_ms=100)
lpos.add_variable('stateEstimate.x')
lpos.add_variable('stateEstimate.y')
lpos.add_variable('stateEstimate.z')
try:
self.cf.log.add_config(lpos)
lpos.data_received_cb.add_callback(self.pos_data)
lpos.start()
except KeyError as e:
print('Could not start log configuration,'
'{} not found in TOC'.format(str(e)))
except AttributeError:
print('Could not add Position log config, bad configuration.')
lmeas = LogConfig(name='Meas', period_in_ms=100)
lmeas.add_variable('range.front')
lmeas.add_variable('range.back')
lmeas.add_variable('range.up')
lmeas.add_variable('range.left')
lmeas.add_variable('range.right')
lmeas.add_variable('range.zrange')
lmeas.add_variable('stabilizer.roll')
lmeas.add_variable('stabilizer.pitch')
lmeas.add_variable('stabilizer.yaw')
try:
self.cf.log.add_config(lmeas)
lmeas.data_received_cb.add_callback(self.meas_data)
lmeas.start()
except KeyError as e:
print('Could not start log configuration,'
'{} not found in TOC'.format(str(e)))
except AttributeError:
print('Could not add Measurement log config, bad configuration.')
示例15: _connected
# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import start [as 别名]
def _connected(self, link_uri):
lg = LogConfig("GPS", 1000)
lg.add_variable("gps.lat")
lg.add_variable("gps.lon")
lg.add_variable("gps.hMSL")
lg.add_variable("gps.hAcc")
lg.add_variable("gps.nsat")
lg.add_variable("gps.fixType")
self._cf.log.add_config(lg)
"""When heading & speed are included in the above logging variables, """
""" the CF2 logging becomes overloaded and freezes up. """
# lg.add_variable("gps.gSpeed")
# lg.add_variable("gps.heading")
if lg.valid:
lg.data_received_cb.add_callback(self._log_data_signal.emit)
lg.error_cb.add_callback(self._log_error_signal.emit)
lg.start()
else:
logger.warning("Could not setup logging block for GPS!")
self._max_speed = 0.0