当前位置: 首页>>代码示例>>Python>>正文


Python LogConfig.add_variable方法代码示例

本文整理汇总了Python中cflib.crazyflie.log.LogConfig.add_variable方法的典型用法代码示例。如果您正苦于以下问题:Python LogConfig.add_variable方法的具体用法?Python LogConfig.add_variable怎么用?Python LogConfig.add_variable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cflib.crazyflie.log.LogConfig的用法示例。


在下文中一共展示了LogConfig.add_variable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _read_config_files

# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import add_variable [as 别名]
    def _read_config_files(self):
        """Read and parse log configurations"""
        configsfound = [os.path.basename(f) for f in
                        glob.glob(sys.path[1] + "/log/[A-Za-z_-]*.json")]
        new_dsList = []
        for conf in configsfound:
            try:
                logger.info("Parsing [%s]", conf)
                json_data = open(sys.path[1] + "/log/%s" % conf)
                self.data = json.load(json_data)
                infoNode = self.data["logconfig"]["logblock"]

                logConf = LogConfig(infoNode["name"],
                                    int(infoNode["period"]))
                for v in self.data["logconfig"]["logblock"]["variables"]:
                    if v["type"] == "TOC":
                        logConf.add_variable(str(v["name"]), v["fetch_as"])
                    else:
                        logConf.add_variable("Mem", v["fetch_as"],
                                             v["stored_as"],
                                             int(v["address"], 16))
                new_dsList.append(logConf)
                json_data.close()
            except Exception as e:
                logger.warning("Exception while parsing logconfig file: %s", e)
        self.dsList = new_dsList
开发者ID:cstanke,项目名称:crazyflie-clients-python,代码行数:28,代码来源:logconfigreader.py

示例2: _handle_logging

# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import add_variable [as 别名]
    def _handle_logging(self, data):
        resp = {"version": 1}
        if data["action"] == "create":
            lg = LogConfig(data["name"], data["period"])
            for v in data["variables"]:
                lg.add_variable(v)
            lg.started_cb.add_callback(self._logging_started)
            lg.added_cb.add_callback(self._logging_added)
            try:
                lg.data_received_cb.add_callback(self._logdata_callback)
                self._logging_configs[data["name"]] = lg
                self._cf.log.add_config(lg)
                lg.create()
                self._log_added_queue.get(block=True, timeout=LOG_TIMEOUT)
                resp["status"] = 0
            except KeyError as e:
                resp["status"] = 1
                resp["msg"] = str(e)
            except AttributeError as e:
                resp["status"] = 2
                resp["msg"] = str(e)
            except queue.Empty:
                resp["status"] = 3
                resp["msg"] = "Log configuration did not start"
        if data["action"] == "start":
            try:
                self._logging_configs[data["name"]].start()
                self._log_started_queue.get(block=True, timeout=LOG_TIMEOUT)
                resp["status"] = 0
            except KeyError as e:
                resp["status"] = 1
                resp["msg"] = "{} config not found".format(str(e))
            except queue.Empty:
                resp["status"] = 2
                resp["msg"] = "Log configuration did not stop"
        if data["action"] == "stop":
            try:
                self._logging_configs[data["name"]].stop()
                self._log_started_queue.get(block=True, timeout=LOG_TIMEOUT)
                resp["status"] = 0
            except KeyError as e:
                resp["status"] = 1
                resp["msg"] = "{} config not found".format(str(e))
            except queue.Empty:
                resp["status"] = 2
                resp["msg"] = "Log configuration did not stop"
        if data["action"] == "delete":
            try:
                self._logging_configs[data["name"]].delete()
                self._log_added_queue.get(block=True, timeout=LOG_TIMEOUT)
                resp["status"] = 0
            except KeyError as e:
                resp["status"] = 1
                resp["msg"] = "{} config not found".format(str(e))
            except queue.Empty:
                resp["status"] = 2
                resp["msg"] = "Log configuration did not stop"

        return resp
开发者ID:Mitteau,项目名称:crazyflie-clients-python,代码行数:61,代码来源:__init__.py

示例3: start_position_printing

# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import add_variable [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()
开发者ID:bitcraze,项目名称:crazyflie-lib-python,代码行数:11,代码来源:autonomousSequence.py

示例4: createConfigFromSelection

# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import add_variable [as 别名]
 def createConfigFromSelection(self):
     logconfig = LogConfig(str(self.configNameCombo.currentText()),
                           self.period)
     for node in self.getNodeChildren(self.varTree.invisibleRootItem()):
         parentName = node.text(NAME_FIELD)
         for leaf in self.getNodeChildren(node):
             varName = leaf.text(NAME_FIELD)
             varType = str(leaf.text(CTYPE_FIELD))
             completeName = "%s.%s" % (parentName, varName)
             logconfig.add_variable(completeName, varType)
     return logconfig
开发者ID:AnthonyLeonardoGracio,项目名称:crazyflie-clients-python,代码行数:13,代码来源:logconfigdialogue.py

示例5: _create_log_config

# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import add_variable [as 别名]
    def _create_log_config(self, rate_ms):
        log_config = LogConfig('multiranger', rate_ms)
        log_config.add_variable(self.FRONT)
        log_config.add_variable(self.BACK)
        log_config.add_variable(self.LEFT)
        log_config.add_variable(self.RIGHT)
        log_config.add_variable(self.UP)
        log_config.add_variable(self.DOWN)

        log_config.data_received_cb.add_callback(self._data_received)

        return log_config
开发者ID:bitcraze,项目名称:crazyflie-lib-python,代码行数:14,代码来源:multiranger.py

示例6: connectionDone

# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import add_variable [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!")
开发者ID:VTR-Records,项目名称:crazyflie-clients-python,代码行数:16,代码来源:main.py

示例7: _connected

# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import add_variable [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))
开发者ID:Venris,项目名称:crazyflie-multilink,代码行数:16,代码来源:main.py

示例8: _register_logblock

# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import add_variable [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
开发者ID:bitcraze,项目名称:crazyflie-clients-python,代码行数:17,代码来源:locopositioning_tab.py

示例9: _connected

# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import add_variable [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)
开发者ID:cstanke,项目名称:crazyflie-clients-python,代码行数:19,代码来源:main.py

示例10: _connected

# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import add_variable [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)
开发者ID:Mitteau,项目名称:crazyflie-clients-python,代码行数:22,代码来源:main.py

示例11: wait_for_position_estimator

# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import add_variable [as 别名]
def wait_for_position_estimator(scf):
    print('Waiting for estimator to find position...')

    log_config = LogConfig(name='Kalman Variance', period_in_ms=500)
    log_config.add_variable('kalman.varPX', 'float')
    log_config.add_variable('kalman.varPY', 'float')
    log_config.add_variable('kalman.varPZ', 'float')

    var_y_history = [1000] * 10
    var_x_history = [1000] * 10
    var_z_history = [1000] * 10

    threshold = 0.001

    with SyncLogger(scf, log_config) as logger:
        for log_entry in logger:
            data = log_entry[1]

            var_x_history.append(data['kalman.varPX'])
            var_x_history.pop(0)
            var_y_history.append(data['kalman.varPY'])
            var_y_history.pop(0)
            var_z_history.append(data['kalman.varPZ'])
            var_z_history.pop(0)

            min_x = min(var_x_history)
            max_x = max(var_x_history)
            min_y = min(var_y_history)
            max_y = max(var_y_history)
            min_z = min(var_z_history)
            max_z = max(var_z_history)

            # print("{} {} {}".
            #       format(max_x - min_x, max_y - min_y, max_z - min_z))

            if (max_x - min_x) < threshold and (
                    max_y - min_y) < threshold and (
                    max_z - min_z) < threshold:
                break
开发者ID:bitcraze,项目名称:crazyflie-lib-python,代码行数:41,代码来源:swarmSequence.py

示例12: _connected

# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import add_variable [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!")
开发者ID:Shedino,项目名称:crazyflie-clients-python,代码行数:14,代码来源:GpsTab.py

示例13: _connected

# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import add_variable [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
开发者ID:jackemoore,项目名称:New-GPS-Additions,代码行数:24,代码来源:GpsTab.py

示例14: _connected

# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import add_variable [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
开发者ID:sytelus,项目名称:crazyflie-clients-python,代码行数:21,代码来源:GpsTab.py

示例15: FlightTab

# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import add_variable [as 别名]

#.........这里部分代码省略.........
    def _baro_data_received(self, timestamp, data, logconf):
        if self.isVisible():
            self.actualASL.setText(("%.2f" % data["baro.aslLong"]))
            self.ai.setBaro(data["baro.aslLong"])
        
    def _althold_data_received(self, timestamp, data, logconf):
        if self.isVisible():
            target = data["altHold.target"]
            if target>0:
                if not self.targetASL.isEnabled():
                    self.targetASL.setEnabled(True) 
                self.targetASL.setText(("%.2f" % target))
                self.ai.setHover(target)    
            elif self.targetASL.isEnabled():
                self.targetASL.setEnabled(False)
                self.targetASL.setText("Not set")   
                self.ai.setHover(0)    
        
    def _imu_data_received(self, timestamp, data, logconf):
        if self.isVisible():
            self.actualRoll.setText(("%.2f" % data["stabilizer.roll"]))
            self.actualPitch.setText(("%.2f" % data["stabilizer.pitch"]))
            self.actualYaw.setText(("%.2f" % data["stabilizer.yaw"]))
            self.actualThrust.setText("%.2f%%" %
                                      self.thrustToPercentage(
                                                      data["stabilizer.thrust"]))
    
            self.ai.setRollPitch(-data["stabilizer.roll"],
                                 data["stabilizer.pitch"])

    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))

        if self.helper.cf.mem.ow_search(vid=0xBC, pid=0x01):
开发者ID:cstanke,项目名称:crazyflie-clients-python,代码行数:70,代码来源:FlightTab.py


注:本文中的cflib.crazyflie.log.LogConfig.add_variable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。