本文整理汇总了Python中cfclient.ui.widgets.ai.AttitudeIndicator.setRollPitch方法的典型用法代码示例。如果您正苦于以下问题:Python AttitudeIndicator.setRollPitch方法的具体用法?Python AttitudeIndicator.setRollPitch怎么用?Python AttitudeIndicator.setRollPitch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cfclient.ui.widgets.ai.AttitudeIndicator
的用法示例。
在下文中一共展示了AttitudeIndicator.setRollPitch方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FlightTab
# 需要导入模块: from cfclient.ui.widgets.ai import AttitudeIndicator [as 别名]
# 或者: from cfclient.ui.widgets.ai.AttitudeIndicator import setRollPitch [as 别名]
#.........这里部分代码省略.........
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):
# 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)
示例2: FlightTab
# 需要导入模块: from cfclient.ui.widgets.ai import AttitudeIndicator [as 别名]
# 或者: from cfclient.ui.widgets.ai.AttitudeIndicator import setRollPitch [as 别名]
#.........这里部分代码省略.........
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")
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()
示例3: FlightTab
# 需要导入模块: from cfclient.ui.widgets.ai import AttitudeIndicator [as 别名]
# 或者: from cfclient.ui.widgets.ai.AttitudeIndicator import setRollPitch [as 别名]
#.........这里部分代码省略.........
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]]
# values generated by calibrate_powered.py
qx = [0.067946222436498283, -0.25034004667098259, 8.3336994198409666, -0.17762637163222378]
qy = [-0.13945102271766135, 2.9074808469097495, 1.6764850422889934, 0.19244505046927501]
qz = [0.018800599305554239, -0.79590273035713055, -3.1033531112103478, 0.13550993988096199]
# matrix by vector multiplication
def mv(a, b):
out = [0,0,0]
for x in range(0, 3):
out[x] = a[x][0] * b[0] + a[x][1] * b[1] + a[x][2] * b[2];
return out
# calculate adjustments related to how much power is sent to the motors
def adj(qs, power):
p = float(power) / float(40000) # 10k * 4 motors
return qs[0]*p**3+qs[1]*p**2+qs[2]*p+qs[3]
x, y, z = data['heading.x'], data['heading.y'], data['heading.z']
x = x - magn_ellipsoid_center[0]
y = y - magn_ellipsoid_center[1]
z = z - magn_ellipsoid_center[2]
示例4: FlightTab
# 需要导入模块: from cfclient.ui.widgets.ai import AttitudeIndicator [as 别名]
# 或者: from cfclient.ui.widgets.ai.AttitudeIndicator import setRollPitch [as 别名]
#.........这里部分代码省略.........
def thrustToPercentage(self, thrust):
return ((thrust / MAX_THRUST) * 100.0)
def percentageToThrust(self, percentage):
return int(MAX_THRUST * (percentage / 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 loggingError(self):
logger.warning("Callback of error in LogEntry :(")
def _motor_data_received(self, data):
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 _imu_data_received(self, data):
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):
lg = LogConfig("Stabalizer", 100)
lg.addVariable(LogVariable("stabilizer.roll", "float"))
lg.addVariable(LogVariable("stabilizer.pitch", "float"))
lg.addVariable(LogVariable("stabilizer.yaw", "float"))
lg.addVariable(LogVariable("stabilizer.thrust", "uint16_t"))
self.log = self.helper.cf.log.create_log_packet(lg)
if (self.log is not None):
self.log.dataReceived.add_callback(self._imu_data_signal.emit)
self.log.error.add_callback(self.loggingError)
self.log.start()
else:
logger.warning("Could not setup logconfiguration after "
"connection!")
lg = LogConfig("Motors", 100)
lg.addVariable(LogVariable("motor.m1", "uint32_t"))
lg.addVariable(LogVariable("motor.m2", "uint32_t"))
lg.addVariable(LogVariable("motor.m3", "uint32_t"))
lg.addVariable(LogVariable("motor.m4", "uint32_t"))
self.log = self.helper.cf.log.create_log_packet(lg)
if (self.log is not None):
self.log.dataReceived.add_callback(self._motor_data_signal.emit)
self.log.error.add_callback(self.loggingError)
self.log.start()
else:
logger.warning("Could not setup logconfiguration after "
"connection!")
示例5: FlightTab
# 需要导入模块: from cfclient.ui.widgets.ai import AttitudeIndicator [as 别名]
# 或者: from cfclient.ui.widgets.ai.AttitudeIndicator import setRollPitch [as 别名]
#.........这里部分代码省略.........
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
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]]
# values generated by calibrate_powered.py
qx = [0.067946222436498283, -0.25034004667098259, 8.3336994198409666, -0.17762637163222378]
qy = [-0.13945102271766135, 2.9074808469097495, 1.6764850422889934, 0.19244505046927501]
qz = [0.018800599305554239, -0.79590273035713055, -3.1033531112103478, 0.13550993988096199]
# matrix by vector multiplication
def mv(a, b):
out = [0,0,0]
for x in range(0, 3):
out[x] = a[x][0] * b[0] + a[x][1] * b[1] + a[x][2] * b[2];
return out
# calculate adjustments related to how much power is sent to the motors
def adj(qs, power):
p = float(power) / float(40000) # 10k * 4 motors
return qs[0]*p**3+qs[1]*p**2+qs[2]*p+qs[3]
x, y, z = data['mag.x'], data['mag.y'], data['mag.z']
x = x - magn_ellipsoid_center[0]
y = y - magn_ellipsoid_center[1]
z = z - magn_ellipsoid_center[2]
x, y, z = mv(magn_ellipsoid_transform, [x, y, z])
示例6: FlightTab
# 需要导入模块: from cfclient.ui.widgets.ai import AttitudeIndicator [as 别名]
# 或者: from cfclient.ui.widgets.ai.AttitudeIndicator import setRollPitch [as 别名]
#.........这里部分代码省略.........
def thrustToPercentage(self, thrust):
return ((thrust/MAX_THRUST)*100.0)
def percentageToThrust(self, percentage):
return int(MAX_THRUST*(percentage/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 loggingError(self):
logger.warning("Callback of error in LogEntry :(")
def _motor_data_received(self, data):
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 _imu_data_received(self, data):
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 _altimeter_data_received(self, data):
pass
def _mag_data_received(self, data):
# 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]]
# values generated by calibrate_powered.py
qx = [0.067946222436498283, -0.25034004667098259, 8.3336994198409666, -0.17762637163222378]
qy = [-0.13945102271766135, 2.9074808469097495, 1.6764850422889934, 0.19244505046927501]
qz = [0.018800599305554239, -0.79590273035713055, -3.1033531112103478, 0.13550993988096199]
# matrix by vector multiplication
def mv(a, b):
out = [0,0,0]
for x in range(0, 3):
out[x] = a[x][0] * b[0] + a[x][1] * b[1] + a[x][2] * b[2];
return out
# calculate adjustments related to how much power is sent to the motors
def adj(qs, power):
p = float(power) / float(40000) # 10k * 4 motors
return qs[0]*p**3+qs[1]*p**2+qs[2]*p+qs[3]
x, y, z = data['mag.x'], data['mag.y'], data['mag.z']
x = x - magn_ellipsoid_center[0]
y = y - magn_ellipsoid_center[1]
z = z - magn_ellipsoid_center[2]
x, y, z = mv(magn_ellipsoid_transform, [x, y, z])
示例7: AutoFlightTab
# 需要导入模块: from cfclient.ui.widgets.ai import AttitudeIndicator [as 别名]
# 或者: from cfclient.ui.widgets.ai.AttitudeIndicator import setRollPitch [as 别名]
#.........这里部分代码省略.........
def thrustToPercentage(self, thrust):
return ((thrust / MAX_THRUST) * 100.0)
def percentageToThrust(self, percentage):
return int(MAX_THRUST * (percentage / 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 loggingError(self):
logger.warning("Callback of error in LogEntry :(")
def _motor_data_received(self, data):
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 _imu_data_received(self, data):
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"])
"""
ADDITION
save reported yaw for coord conversion - ? is there some other way to get this ?
"""
global copter
copter.lastyaw = data["stabilizer.yaw"]
def connected(self, linkURI):
lg = LogConfig("Stabalizer", 100)
lg.addVariable(LogVariable("stabilizer.roll", "float"))
lg.addVariable(LogVariable("stabilizer.pitch", "float"))
lg.addVariable(LogVariable("stabilizer.yaw", "float"))
lg.addVariable(LogVariable("stabilizer.thrust", "uint16_t"))
self.log = self.helper.cf.log.create_log_packet(lg)
if (self.log is not None):
self.log.dataReceived.add_callback(self._imu_data_signal.emit)
self.log.error.add_callback(self.loggingError)
self.log.start()
else:
logger.warning("Could not setup logconfiguration after "
"connection!")
lg = LogConfig("Motors", 100)
lg.addVariable(LogVariable("motor.m1", "uint32_t"))
lg.addVariable(LogVariable("motor.m2", "uint32_t"))
lg.addVariable(LogVariable("motor.m3", "uint32_t"))
lg.addVariable(LogVariable("motor.m4", "uint32_t"))
self.log = self.helper.cf.log.create_log_packet(lg)