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


Python AttitudeIndicator.setBaro方法代码示例

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


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

示例1: FlightTab

# 需要导入模块: from cfclient.ui.widgets.ai import AttitudeIndicator [as 别名]
# 或者: from cfclient.ui.widgets.ai.AttitudeIndicator import setBaro [as 别名]

#.........这里部分代码省略.........
        self.slewEnableLimit.setEnabled(thrust_limiting_enabled)
        self.thrustLoweringSlewRateLimit.setEnabled(thrust_limiting_enabled)

    def _set_neffect(self, n):
        self._ledring_nbr_effects = n

    def thrustToPercentage(self, thrust):
        return ((thrust / MAX_THRUST) * 100.0)

    def uiSetupReady(self):
        flightComboIndex = self.flightModeCombo.findText(
                             Config().get("flightmode"), Qt.MatchFixedString)
        if (flightComboIndex < 0):
            self.flightModeCombo.setCurrentIndex(0)
            self.flightModeCombo.currentIndexChanged.emit(0)
        else:
            self.flightModeCombo.setCurrentIndex(flightComboIndex)
            self.flightModeCombo.currentIndexChanged.emit(flightComboIndex)

    def _logging_error(self, log_conf, msg):
        QMessageBox.about(self, "Log error", "Error when starting log config"
                " [%s]: %s" % (log_conf.name, msg))

    def _motor_data_received(self, timestamp, data, logconf):
        if self.isVisible():
            self.actualM1.setValue(data["motor.m1"])
            self.actualM2.setValue(data["motor.m2"])
            self.actualM3.setValue(data["motor.m3"])
            self.actualM4.setValue(data["motor.m4"])
        
    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")
开发者ID:cstanke,项目名称:crazyflie-clients-python,代码行数:70,代码来源:FlightTab.py

示例2: FlightTab

# 需要导入模块: from cfclient.ui.widgets.ai import AttitudeIndicator [as 别名]
# 或者: from cfclient.ui.widgets.ai.AttitudeIndicator import setBaro [as 别名]

#.........这里部分代码省略.........
        self.targetCalPitch.setValue(GuiConfig().get("trim_pitch"))
        self.targetCalRoll.setValue(GuiConfig().get("trim_roll"))
        
        self.apitch = 0
        self.aroll = 0
        self.motor_power = 0

    def thrustToPercentage(self, thrust):
        return ((thrust / MAX_THRUST) * 100.0)

    def uiSetupReady(self):
        flightComboIndex = self.flightModeCombo.findText(
                             GuiConfig().get("flightmode"), Qt.MatchFixedString)
        if (flightComboIndex < 0):
            self.flightModeCombo.setCurrentIndex(0)
            self.flightModeCombo.currentIndexChanged.emit(0)
        else:
            self.flightModeCombo.setCurrentIndex(flightComboIndex)
            self.flightModeCombo.currentIndexChanged.emit(flightComboIndex)

    def _logging_error(self, log_conf, msg):
        QMessageBox.about(self, "Log error", "Error when starting log config"
                " [%s]: %s" % (log_conf.getName(), msg))

    def _motor_data_received(self, data, timestamp):
        self.actualM1.setValue(data["motor.m1"])
        self.actualM2.setValue(data["motor.m2"])
        self.actualM3.setValue(data["motor.m3"])
        self.actualM4.setValue(data["motor.m4"])
        self.motor_power = data["motor.m1"] + data["motor.m2"] + data["motor.m3"] + data["motor.m4"]
        
    def _baro_data_received(self, data, timestamp):
        self.actualASL.setText(("%.2f" % data["baro.aslLong"]))
        self.ai.setBaro(data["baro.aslLong"])
        
    def _althold_data_received(self, data, timestamp):       
        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, data, timestamp):
        self.aroll = data["stabilizer.roll"]
        self.apitch = data["stabilizer.pitch"]
        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 _heading_data_received(self, data, timestamp):
    # hard and soft correction values generated by Processing Magnetometer_calibration script + calibrate_hardsoft.py
        # magn_ellipsoid_center = [1341.66, -537.690, 41.1584]
        # magn_ellipsoid_transform = [[0.934687, 0.0222809, 0.0151145], [0.0222809, 0.919365, -0.00622367], [0.0151145, -0.00622367, 0.996487]]                                
        magn_ellipsoid_center = [-170.956, -1056.30, 19.4655]
        magn_ellipsoid_transform = [[0.852266, 0.00526498, 0.0195745], [0.00526498, 0.888268, -0.00355351], [0.0195745, -0.00355351, 0.997333]]
开发者ID:djvolz,项目名称:Self-Navigating-Crazyflie-Quadcopter,代码行数:70,代码来源:FlightTab.py

示例3: FlightTab

# 需要导入模块: from cfclient.ui.widgets.ai import AttitudeIndicator [as 别名]
# 或者: from cfclient.ui.widgets.ai.AttitudeIndicator import setBaro [as 别名]

#.........这里部分代码省略.........

    def _motor_data_received(self, timestamp, data, logconf):
        if self.isVisible():
            self.actualM1.setValue(data["motor.m1"])
            self.actualM2.setValue(data["motor.m2"])
            self.actualM3.setValue(data["motor.m3"])
            self.actualM4.setValue(data["motor.m4"])
            d = MotorData()
            d.m1 = data["motor.m1"]
            d.m2 = data["motor.m2"]
            d.m3 = data["motor.m3"]
            d.m4 = data["motor.m4"]
            self.motor_pub.publish(d)

    def _gyro_data_received(self, timestamp, data, logconf):
        if self.isVisible():
             d = GyroData()
             d.x = data["gyro.x"]
             d.y = data["gyro.y"]
             d.z = data["gyro.z"]
             self.gyro_pub.publish(d)
   
    def _accel_data_received(self, timestamp, data, logconf):
         if self.isVisible():
             d = AccelData() 
             d.x = data["acc.x"]
             d.y = data["acc.y"]
             d.z = data["acc.z"]
             self.acc_pub.publish(d)

    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"])
            d = StabData()
            d.pitch = data["stabilizer.pitch"]
            d.roll = data["stabilizer.roll"]
            d.yaw = data["stabilizer.yaw"]
            self.stab_pub.publish(d)

    def connected(self, linkURI):
开发者ID:WSCU,项目名称:crazyflie_ros,代码行数:70,代码来源:FlightTab.py

示例4: FlightTab

# 需要导入模块: from cfclient.ui.widgets.ai import AttitudeIndicator [as 别名]
# 或者: from cfclient.ui.widgets.ai.AttitudeIndicator import setBaro [as 别名]

#.........这里部分代码省略.........
               
            # Select last one (eg the one we just plugged in)          
            self.comboBox_camera.setCurrentIndex(max(0, len(devices) - 1)) 

    def thrustToPercentage(self, thrust):
        return ((thrust / MAX_THRUST) * 100.0)

    def uiSetupReady(self):
        flightComboIndex = self.flightModeCombo.findText(
                             GuiConfig().get("flightmode"), Qt.MatchFixedString)
        if (flightComboIndex < 0):
            self.flightModeCombo.setCurrentIndex(0)
            self.flightModeCombo.currentIndexChanged.emit(0)
        else:
            self.flightModeCombo.setCurrentIndex(flightComboIndex)
            self.flightModeCombo.currentIndexChanged.emit(flightComboIndex)

    def _logging_error(self, log_conf, msg):
        QMessageBox.about(self, "Log error", "Error when starting log config"
                " [%s]: %s" % (log_conf.name, msg))

    def _motor_data_received(self, timestamp, data, logconf):
        self.motor_power = data["motor.m1"] + data["motor.m2"] + data["motor.m3"] + data["motor.m4"]
        if self.isVisible():
            self.actualM1.setValue(data["motor.m1"])
            self.actualM2.setValue(data["motor.m2"])
            self.actualM3.setValue(data["motor.m3"])
            self.actualM4.setValue(data["motor.m4"])
        
    def _baro_data_received(self, timestamp, data, logconf):
        self.helper.inputDeviceReader.setCurrentAltitude(data["baro.aslLong"])
        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):
        self.aroll = data["stabilizer.roll"]  
        self.apitch = data["stabilizer.pitch"]
        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"])
            self.compass.setAngle(-data["stabilizer.yaw"])
            # self.helper.cf.commander.setActualPoint(data)
            
    def _mag_data_received(self, timestamp, data, logconf):              
        # hard and soft correction values generated by Processing Magnetometer_calibration script + calibrate_hardsoft.py
开发者ID:capriele,项目名称:crazyflie-clients-python,代码行数:70,代码来源:FlightTab.py


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