Browse Source

Merge pull request #3520 from DonLakeFlyer/SensorsSmallScreen

Sensors small screen
QGC4.4
Don Gagne 9 years ago committed by GitHub
parent
commit
87551cf212
  1. 447
      src/AutoPilotPlugins/PX4/SensorsComponent.qml
  2. 2
      src/QmlControls/VehicleRotationCal.qml
  3. 207
      src/comm/MockLink.cc
  4. 1
      src/comm/MockLink.h

447
src/AutoPilotPlugins/PX4/SensorsComponent.qml

@ -36,7 +36,7 @@ QGCView {
readonly property string levelHelp: qsTr("To level the horizon you need to place the vehicle in its level flight position and press OK.") readonly property string levelHelp: qsTr("To level the horizon you need to place the vehicle in its level flight position and press OK.")
readonly property string airspeedHelp: qsTr("For Airspeed calibration you will need to keep your airspeed sensor out of any wind and then blow across the sensor.") readonly property string airspeedHelp: qsTr("For Airspeed calibration you will need to keep your airspeed sensor out of any wind and then blow across the sensor.")
readonly property string statusTextAreaDefaultText: qsTr("Start the individual calibration steps by clicking one of the buttons above.") readonly property string statusTextAreaDefaultText: qsTr("Start the individual calibration steps by clicking one of the buttons to the left.")
// Used to pass what type of calibration is being performed to the preCalibrationDialog // Used to pass what type of calibration is being performed to the preCalibrationDialog
property string preCalibrationDialogType property string preCalibrationDialogType
@ -44,7 +44,7 @@ QGCView {
// Used to pass help text to the preCalibrationDialog dialog // Used to pass help text to the preCalibrationDialog dialog
property string preCalibrationDialogHelp property string preCalibrationDialogHelp
readonly property int rotationColumnWidth: 250 readonly property int rotationColumnWidth: ScreenTools.defaultFontPixelWidth * 30
readonly property var rotations: [ readonly property var rotations: [
"ROTATION_NONE", "ROTATION_NONE",
"ROTATION_YAW_45", "ROTATION_YAW_45",
@ -114,7 +114,7 @@ QGCView {
onSetCompassRotations: { onSetCompassRotations: {
if (showCompass0Rot || showCompass1Rot || showCompass2Rot) { if (showCompass0Rot || showCompass1Rot || showCompass2Rot) {
showDialog(compassRotationDialogComponent, qsTr("Set Compass Rotation(s)"), qgcView.showDialogDefaultWidth, StandardButton.Ok) showDialog(setOrientationsDialogComponent, qsTr("Set Compass Rotation(s)"), qgcView.showDialogDefaultWidth, StandardButton.Ok)
} }
} }
@ -187,183 +187,232 @@ QGCView {
} }
Component { Component {
id: compassRotationDialogComponent id: setOrientationsDialogComponent
QGCViewDialog { QGCViewDialog {
id: compassRotationDialog id: setOrientationsDialog
Column { QGCFlickable {
anchors.fill: parent anchors.fill: parent
spacing: ScreenTools.defaultFontPixelHeight contentHeight: columnLayout.height
clip: true
QGCLabel {
width: parent.width
wrapMode: Text.WordWrap
text: compassRotationText
}
// Compass 0 rotation Column {
Component { id: columnLayout
id: compass0ComponentLabel anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
spacing: ScreenTools.defaultFontPixelHeight
QGCLabel { QGCLabel {
text: qsTr("External Compass Orientation") width: parent.width
wrapMode: Text.WordWrap
text: boardRotationText
} }
} Column {
Component { QGCLabel {
id: compass0ComponentCombo text: qsTr("Autopilot Orientation:")
}
FactComboBox {
id: compass0RotationCombo FactComboBox {
width: rotationColumnWidth id: boardRotationCombo
model: rotations width: rotationColumnWidth;
fact: cal_mag0_rot model: rotations
fact: sens_board_rot
}
} }
}
Loader { sourceComponent: showCompass0Rot ? compass0ComponentLabel : null }
Loader { sourceComponent: showCompass0Rot ? compass0ComponentCombo : null }
// Compass 1 rotation
Component {
id: compass1ComponentLabel
QGCLabel { text: qsTr("Compass 1 Orientation") } Column {
} // Compass 0 rotation
Component { Component {
id: compass1ComponentCombo id: compass0ComponentLabel2
FactComboBox { QGCLabel {
id: compass1RotationCombo text: qsTr("External Compass Orientation:")
width: rotationColumnWidth }
model: rotations }
fact: cal_mag1_rot
Component {
id: compass0ComponentCombo2
FactComboBox {
id: compass0RotationCombo
width: rotationColumnWidth
model: rotations
fact: cal_mag0_rot
}
}
Loader { sourceComponent: showCompass0Rot ? compass0ComponentLabel2 : null }
Loader { sourceComponent: showCompass0Rot ? compass0ComponentCombo2 : null }
} }
}
Loader { sourceComponent: showCompass1Rot ? compass1ComponentLabel : null }
Loader { sourceComponent: showCompass1Rot ? compass1ComponentCombo : null }
// Compass 2 rotation Column {
Component { // Compass 1 rotation
id: compass2ComponentLabel Component {
id: compass1ComponentLabel2
QGCLabel { text: qsTr("Compass 2 Orientation") } QGCLabel {
} text: qsTr("External Compass 1 Orientation:")
Component { }
id: compass2ComponentCombo }
FactComboBox { Component {
id: compass1RotationCombo id: compass1ComponentCombo2
width: rotationColumnWidth
model: rotations FactComboBox {
fact: cal_mag2_rot id: compass1RotationCombo
width: rotationColumnWidth
model: rotations
fact: cal_mag1_rot
}
}
Loader { sourceComponent: showCompass1Rot ? compass1ComponentLabel2 : null }
Loader { sourceComponent: showCompass1Rot ? compass1ComponentCombo2 : null }
} }
}
Loader { sourceComponent: showCompass2Rot ? compass2ComponentLabel : null } Column {
Loader { sourceComponent: showCompass2Rot ? compass2ComponentCombo : null } spacing: ScreenTools.defaultFontPixelWidth
} // Column
// Compass 2 rotation
Component {
id: compass2ComponentLabel2
QGCLabel {
text: qsTr("Compass 2 Orientation")
}
}
Component {
id: compass2ComponentCombo2
FactComboBox {
id: compass1RotationCombo
width: rotationColumnWidth
model: rotations
fact: cal_mag2_rot
}
}
Loader { sourceComponent: showCompass2Rot ? compass2ComponentLabel2 : null }
Loader { sourceComponent: showCompass2Rot ? compass2ComponentCombo2 : null }
}
} // Column
} // QGCFlickable
} // QGCViewDialog } // QGCViewDialog
} // Component - compassRotationDialogComponent } // Component - setOrientationsDialogComponent
QGCViewPanel { QGCViewPanel {
id: panel id: panel
anchors.fill: parent anchors.fill: parent
Column { Column {
anchors.fill: parent id: buttonColumn
spacing: ScreenTools.defaultFontPixelHeight / 2
Row {
readonly property int buttonWidth: ScreenTools.defaultFontPixelWidth * 15
spacing: ScreenTools.defaultFontPixelWidth readonly property int buttonWidth: ScreenTools.defaultFontPixelWidth * 15
QGCLabel { text: qsTr("Calibrate:"); anchors.baseline: compassButton.baseline } IndicatorButton {
id: compassButton
width: parent.buttonWidth
text: qsTr("Compass")
indicatorGreen: cal_mag0_id.value != 0
IndicatorButton { onClicked: {
id: compassButton preCalibrationDialogType = "compass"
width: parent.buttonWidth preCalibrationDialogHelp = compassHelp
text: qsTr("Compass") showDialog(preCalibrationDialogComponent, qsTr("Calibrate Compass"), qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok)
indicatorGreen: cal_mag0_id.value != 0
onClicked: {
preCalibrationDialogType = "compass"
preCalibrationDialogHelp = compassHelp
showDialog(preCalibrationDialogComponent, qsTr("Calibrate Compass"), qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok)
}
} }
}
IndicatorButton { IndicatorButton {
id: gyroButton id: gyroButton
width: parent.buttonWidth width: parent.buttonWidth
text: qsTr("Gyroscope") text: qsTr("Gyroscope")
indicatorGreen: cal_gyro0_id.value != 0 indicatorGreen: cal_gyro0_id.value != 0
onClicked: { onClicked: {
preCalibrationDialogType = "gyro" preCalibrationDialogType = "gyro"
preCalibrationDialogHelp = gyroHelp preCalibrationDialogHelp = gyroHelp
showDialog(preCalibrationDialogComponent, qsTr("Calibrate Gyro"), qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) showDialog(preCalibrationDialogComponent, qsTr("Calibrate Gyro"), qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok)
}
} }
}
IndicatorButton { IndicatorButton {
id: accelButton id: accelButton
width: parent.buttonWidth width: parent.buttonWidth
text: qsTr("Accelerometer") text: qsTr("Accelerometer")
indicatorGreen: cal_acc0_id.value != 0 indicatorGreen: cal_acc0_id.value != 0
onClicked: { onClicked: {
preCalibrationDialogType = "accel" preCalibrationDialogType = "accel"
preCalibrationDialogHelp = accelHelp preCalibrationDialogHelp = accelHelp
showDialog(preCalibrationDialogComponent, qsTr("Calibrate Accelerometer"), qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) showDialog(preCalibrationDialogComponent, qsTr("Calibrate Accelerometer"), qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok)
}
} }
}
IndicatorButton { IndicatorButton {
id: levelButton id: levelButton
width: parent.buttonWidth width: parent.buttonWidth
text: qsTr("Level Horizon") text: qsTr("Level Horizon")
indicatorGreen: sens_board_x_off.value != 0 indicatorGreen: sens_board_x_off.value != 0
enabled: cal_acc0_id.value != 0 && cal_gyro0_id.value != 0 enabled: cal_acc0_id.value != 0 && cal_gyro0_id.value != 0
onClicked: { onClicked: {
preCalibrationDialogType = "level" preCalibrationDialogType = "level"
preCalibrationDialogHelp = levelHelp preCalibrationDialogHelp = levelHelp
showDialog(preCalibrationDialogComponent, qsTr("Level Horizon"), qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) showDialog(preCalibrationDialogComponent, qsTr("Level Horizon"), qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok)
}
} }
}
IndicatorButton { IndicatorButton {
id: airspeedButton id: airspeedButton
width: parent.buttonWidth width: parent.buttonWidth
text: qsTr("Airspeed") text: qsTr("Airspeed")
visible: (controller.vehicle.fixedWing || controller.vehicle.vtol) && controller.getParameterFact(-1, "CBRK_AIRSPD_CHK").value != 162128 visible: (controller.vehicle.fixedWing || controller.vehicle.vtol) && controller.getParameterFact(-1, "CBRK_AIRSPD_CHK").value != 162128
indicatorGreen: sens_dpres_off.value != 0 indicatorGreen: sens_dpres_off.value != 0
onClicked: { onClicked: {
preCalibrationDialogType = "airspeed" preCalibrationDialogType = "airspeed"
preCalibrationDialogHelp = airspeedHelp preCalibrationDialogHelp = airspeedHelp
showDialog(preCalibrationDialogComponent, qsTr("Calibrate Airspeed"), qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) showDialog(preCalibrationDialogComponent, qsTr("Calibrate Airspeed"), qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok)
}
} }
}
QGCButton { QGCButton {
id: cancelButton id: cancelButton
text: qsTr("Cancel") width: parent.buttonWidth
enabled: false text: qsTr("Cancel")
onClicked: controller.cancelCalibration() enabled: false
} onClicked: controller.cancelCalibration()
} }
Item { height: ScreenTools.defaultFontPixelHeight; width: 10 } // spacer QGCButton {
width: parent.buttonWidth
text: qsTr("Set Orientations")
onClicked: showDialog(setOrientationsDialogComponent, qsTr("Set Orientations"), qgcView.showDialogDefaultWidth, StandardButton.Ok)
}
} // Column - Buttons
Column {
anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
anchors.left: buttonColumn.right
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
ProgressBar { ProgressBar {
id: progressBar id: progressBar
width: parent.width - rotationColumnWidth anchors.left: parent.left
anchors.right: parent.right
} }
Item { height: ScreenTools.defaultFontPixelHeight; width: 10 } // spacer Item { height: ScreenTools.defaultFontPixelHeight; width: 10 } // spacer
Item { Item {
property int calDisplayAreaWidth: parent.width - rotationColumnWidth property int calDisplayAreaWidth: parent.width
width: parent.width width: parent.width
height: parent.height - y height: parent.height - y
@ -402,12 +451,19 @@ QGCView {
Flow { Flow {
anchors.topMargin: ScreenTools.defaultFontPixelWidth anchors.topMargin: ScreenTools.defaultFontPixelWidth
anchors.top: orientationCalAreaHelpText.bottom anchors.top: orientationCalAreaHelpText.bottom
anchors.left: orientationCalAreaHelpText.left anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
width: parent.width width: parent.width
height: parent.height - orientationCalAreaHelpText.implicitHeight height: parent.height - orientationCalAreaHelpText.implicitHeight
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth / 2
property real indicatorWidth: (width / 3) - (spacing * 2)
property real indicatorHeight: (height / 2) - spacing
VehicleRotationCal { VehicleRotationCal {
width: parent.indicatorWidth
height: parent.indicatorHeight
visible: controller.orientationCalDownSideVisible visible: controller.orientationCalDownSideVisible
calValid: controller.orientationCalDownSideDone calValid: controller.orientationCalDownSideDone
calInProgress: controller.orientationCalDownSideInProgress calInProgress: controller.orientationCalDownSideInProgress
@ -415,6 +471,8 @@ QGCView {
imageSource: controller.orientationCalDownSideRotate ? "qrc:///qmlimages/VehicleDownRotate.png" : "qrc:///qmlimages/VehicleDown.png" imageSource: controller.orientationCalDownSideRotate ? "qrc:///qmlimages/VehicleDownRotate.png" : "qrc:///qmlimages/VehicleDown.png"
} }
VehicleRotationCal { VehicleRotationCal {
width: parent.indicatorWidth
height: parent.indicatorHeight
visible: controller.orientationCalUpsideDownSideVisible visible: controller.orientationCalUpsideDownSideVisible
calValid: controller.orientationCalUpsideDownSideDone calValid: controller.orientationCalUpsideDownSideDone
calInProgress: controller.orientationCalUpsideDownSideInProgress calInProgress: controller.orientationCalUpsideDownSideInProgress
@ -422,6 +480,8 @@ QGCView {
imageSource: controller.orientationCalUpsideDownSideRotate ? "qrc:///qmlimages/VehicleUpsideDownRotate.png" : "qrc:///qmlimages/VehicleUpsideDown.png" imageSource: controller.orientationCalUpsideDownSideRotate ? "qrc:///qmlimages/VehicleUpsideDownRotate.png" : "qrc:///qmlimages/VehicleUpsideDown.png"
} }
VehicleRotationCal { VehicleRotationCal {
width: parent.indicatorWidth
height: parent.indicatorHeight
visible: controller.orientationCalNoseDownSideVisible visible: controller.orientationCalNoseDownSideVisible
calValid: controller.orientationCalNoseDownSideDone calValid: controller.orientationCalNoseDownSideDone
calInProgress: controller.orientationCalNoseDownSideInProgress calInProgress: controller.orientationCalNoseDownSideInProgress
@ -429,6 +489,8 @@ QGCView {
imageSource: controller.orientationCalNoseDownSideRotate ? "qrc:///qmlimages/VehicleNoseDownRotate.png" : "qrc:///qmlimages/VehicleNoseDown.png" imageSource: controller.orientationCalNoseDownSideRotate ? "qrc:///qmlimages/VehicleNoseDownRotate.png" : "qrc:///qmlimages/VehicleNoseDown.png"
} }
VehicleRotationCal { VehicleRotationCal {
width: parent.indicatorWidth
height: parent.indicatorHeight
visible: controller.orientationCalTailDownSideVisible visible: controller.orientationCalTailDownSideVisible
calValid: controller.orientationCalTailDownSideDone calValid: controller.orientationCalTailDownSideDone
calInProgress: controller.orientationCalTailDownSideInProgress calInProgress: controller.orientationCalTailDownSideInProgress
@ -436,6 +498,8 @@ QGCView {
imageSource: controller.orientationCalTailDownSideRotate ? "qrc:///qmlimages/VehicleTailDownRotate.png" : "qrc:///qmlimages/VehicleTailDown.png" imageSource: controller.orientationCalTailDownSideRotate ? "qrc:///qmlimages/VehicleTailDownRotate.png" : "qrc:///qmlimages/VehicleTailDown.png"
} }
VehicleRotationCal { VehicleRotationCal {
width: parent.indicatorWidth
height: parent.indicatorHeight
visible: controller.orientationCalLeftSideVisible visible: controller.orientationCalLeftSideVisible
calValid: controller.orientationCalLeftSideDone calValid: controller.orientationCalLeftSideDone
calInProgress: controller.orientationCalLeftSideInProgress calInProgress: controller.orientationCalLeftSideInProgress
@ -443,6 +507,8 @@ QGCView {
imageSource: controller.orientationCalLeftSideRotate ? "qrc:///qmlimages/VehicleLeftRotate.png" : "qrc:///qmlimages/VehicleLeft.png" imageSource: controller.orientationCalLeftSideRotate ? "qrc:///qmlimages/VehicleLeftRotate.png" : "qrc:///qmlimages/VehicleLeft.png"
} }
VehicleRotationCal { VehicleRotationCal {
width: parent.indicatorWidth
height: parent.indicatorHeight
visible: controller.orientationCalRightSideVisible visible: controller.orientationCalRightSideVisible
calValid: controller.orientationCalRightSideDone calValid: controller.orientationCalRightSideDone
calInProgress: controller.orientationCalRightSideInProgress calInProgress: controller.orientationCalRightSideInProgress
@ -451,113 +517,6 @@ QGCView {
} }
} }
} }
Column {
anchors.leftMargin: ScreenTools.defaultFontPixelWidth
anchors.left: orientationCalArea.right
x: parent.width - rotationColumnWidth
spacing: ScreenTools.defaultFontPixelHeight
QGCLabel {
font.pointSize: ScreenTools.mediumFontPointSize
text: qsTr("Set Orientations")
}
QGCLabel {
width: parent.width
wrapMode: Text.WordWrap
text: boardRotationText
}
Column {
QGCLabel {
text: qsTr("Autpilot Orientation:")
}
FactComboBox {
id: boardRotationCombo
width: rotationColumnWidth;
model: rotations
fact: sens_board_rot
}
}
Column {
// Compass 0 rotation
Component {
id: compass0ComponentLabel2
QGCLabel {
text: qsTr("External Compass Orientation:")
}
}
Component {
id: compass0ComponentCombo2
FactComboBox {
id: compass0RotationCombo
width: rotationColumnWidth
model: rotations
fact: cal_mag0_rot
}
}
Loader { sourceComponent: showCompass0Rot ? compass0ComponentLabel2 : null }
Loader { sourceComponent: showCompass0Rot ? compass0ComponentCombo2 : null }
}
Column {
// Compass 1 rotation
Component {
id: compass1ComponentLabel2
QGCLabel {
text: qsTr("External Compass 1 Orientation:")
}
}
Component {
id: compass1ComponentCombo2
FactComboBox {
id: compass1RotationCombo
width: rotationColumnWidth
model: rotations
fact: cal_mag1_rot
}
}
Loader { sourceComponent: showCompass1Rot ? compass1ComponentLabel2 : null }
Loader { sourceComponent: showCompass1Rot ? compass1ComponentCombo2 : null }
}
Column {
spacing: ScreenTools.defaultFontPixelWidth
// Compass 2 rotation
Component {
id: compass2ComponentLabel2
QGCLabel {
text: qsTr("Compass 2 Orientation")
}
}
Component {
id: compass2ComponentCombo2
FactComboBox {
id: compass1RotationCombo
width: rotationColumnWidth
model: rotations
fact: cal_mag2_rot
}
}
Loader { sourceComponent: showCompass2Rot ? compass2ComponentLabel2 : null }
Loader { sourceComponent: showCompass2Rot ? compass2ComponentCombo2 : null }
}
}
} }
} }
} // QGCViewPanel } // QGCViewPanel

2
src/QmlControls/VehicleRotationCal.qml

@ -30,8 +30,6 @@ Rectangle {
property var __qgcPal: QGCPalette { colorGroupEnabled: enabled } property var __qgcPal: QGCPalette { colorGroupEnabled: enabled }
width: 200
height: 200
color: calInProgress ? "yellow" : (calValid ? "green" : "red") color: calInProgress ? "yellow" : (calValid ? "green" : "red")
Rectangle { Rectangle {

207
src/comm/MockLink.cc

@ -28,13 +28,13 @@ QGC_LOGGING_CATEGORY(MockLinkVerboseLog, "MockLinkVerboseLog")
enum PX4_CUSTOM_MAIN_MODE { enum PX4_CUSTOM_MAIN_MODE {
PX4_CUSTOM_MAIN_MODE_MANUAL = 1, PX4_CUSTOM_MAIN_MODE_MANUAL = 1,
PX4_CUSTOM_MAIN_MODE_ALTCTL, PX4_CUSTOM_MAIN_MODE_ALTCTL,
PX4_CUSTOM_MAIN_MODE_POSCTL, PX4_CUSTOM_MAIN_MODE_POSCTL,
PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_MAIN_MODE_AUTO,
PX4_CUSTOM_MAIN_MODE_ACRO, PX4_CUSTOM_MAIN_MODE_ACRO,
PX4_CUSTOM_MAIN_MODE_OFFBOARD, PX4_CUSTOM_MAIN_MODE_OFFBOARD,
PX4_CUSTOM_MAIN_MODE_STABILIZED, PX4_CUSTOM_MAIN_MODE_STABILIZED,
PX4_CUSTOM_MAIN_MODE_RATTITUDE PX4_CUSTOM_MAIN_MODE_RATTITUDE
}; };
enum PX4_CUSTOM_SUB_MODE_AUTO { enum PX4_CUSTOM_SUB_MODE_AUTO {
@ -226,31 +226,31 @@ void MockLink::_loadParams(void)
QVariant paramValue; QVariant paramValue;
switch (paramType) { switch (paramType) {
case MAV_PARAM_TYPE_REAL32: case MAV_PARAM_TYPE_REAL32:
paramValue = QVariant(valStr.toFloat()); paramValue = QVariant(valStr.toFloat());
break; break;
case MAV_PARAM_TYPE_UINT32: case MAV_PARAM_TYPE_UINT32:
paramValue = QVariant(valStr.toUInt()); paramValue = QVariant(valStr.toUInt());
break; break;
case MAV_PARAM_TYPE_INT32: case MAV_PARAM_TYPE_INT32:
paramValue = QVariant(valStr.toInt()); paramValue = QVariant(valStr.toInt());
break; break;
case MAV_PARAM_TYPE_UINT16: case MAV_PARAM_TYPE_UINT16:
paramValue = QVariant((quint16)valStr.toUInt()); paramValue = QVariant((quint16)valStr.toUInt());
break; break;
case MAV_PARAM_TYPE_INT16: case MAV_PARAM_TYPE_INT16:
paramValue = QVariant((qint16)valStr.toInt()); paramValue = QVariant((qint16)valStr.toInt());
break; break;
case MAV_PARAM_TYPE_UINT8: case MAV_PARAM_TYPE_UINT8:
paramValue = QVariant((quint8)valStr.toUInt()); paramValue = QVariant((quint8)valStr.toUInt());
break; break;
case MAV_PARAM_TYPE_INT8: case MAV_PARAM_TYPE_INT8:
paramValue = QVariant((qint8)valStr.toUInt()); paramValue = QVariant((qint8)valStr.toUInt());
break; break;
default: default:
qCritical() << "Unknown type" << paramType; qCritical() << "Unknown type" << paramType;
paramValue = QVariant(valStr.toInt()); paramValue = QVariant(valStr.toInt());
break; break;
} }
qCDebug(MockLinkVerboseLog) << "Loading param" << paramName << paramValue; qCDebug(MockLinkVerboseLog) << "Loading param" << paramName << paramValue;
@ -359,40 +359,40 @@ void MockLink::_handleIncomingMavlinkBytes(const uint8_t* bytes, int cBytes)
} }
switch (msg.msgid) { switch (msg.msgid) {
case MAVLINK_MSG_ID_HEARTBEAT: case MAVLINK_MSG_ID_HEARTBEAT:
_handleHeartBeat(msg); _handleHeartBeat(msg);
break; break;
case MAVLINK_MSG_ID_PARAM_REQUEST_LIST: case MAVLINK_MSG_ID_PARAM_REQUEST_LIST:
_handleParamRequestList(msg); _handleParamRequestList(msg);
break; break;
case MAVLINK_MSG_ID_SET_MODE: case MAVLINK_MSG_ID_SET_MODE:
_handleSetMode(msg); _handleSetMode(msg);
break; break;
case MAVLINK_MSG_ID_PARAM_SET: case MAVLINK_MSG_ID_PARAM_SET:
_handleParamSet(msg); _handleParamSet(msg);
break; break;
case MAVLINK_MSG_ID_PARAM_REQUEST_READ: case MAVLINK_MSG_ID_PARAM_REQUEST_READ:
_handleParamRequestRead(msg); _handleParamRequestRead(msg);
break; break;
case MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL: case MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL:
_handleFTP(msg); _handleFTP(msg);
break; break;
case MAVLINK_MSG_ID_COMMAND_LONG: case MAVLINK_MSG_ID_COMMAND_LONG:
_handleCommandLong(msg); _handleCommandLong(msg);
break; break;
case MAVLINK_MSG_ID_MANUAL_CONTROL: case MAVLINK_MSG_ID_MANUAL_CONTROL:
_handleManualControl(msg); _handleManualControl(msg);
break; break;
default: default:
break; break;
} }
} }
} }
@ -489,7 +489,7 @@ float MockLink::_floatUnionForParam(int componentId, const QString& paramName)
switch (paramType) { switch (paramType) {
case MAV_PARAM_TYPE_REAL32: case MAV_PARAM_TYPE_REAL32:
valueUnion.param_float = paramVar.toFloat(); valueUnion.param_float = paramVar.toFloat();
break; break;
case MAV_PARAM_TYPE_UINT32: case MAV_PARAM_TYPE_UINT32:
@ -747,24 +747,24 @@ void MockLink::emitRemoteControlChannelRawChanged(int channel, uint16_t raw)
0, // time since boot, ignored 0, // time since boot, ignored
18, // channel count 18, // channel count
chanRaw[0], // channel raw value chanRaw[0], // channel raw value
chanRaw[1], // channel raw value chanRaw[1], // channel raw value
chanRaw[2], // channel raw value chanRaw[2], // channel raw value
chanRaw[3], // channel raw value chanRaw[3], // channel raw value
chanRaw[4], // channel raw value chanRaw[4], // channel raw value
chanRaw[5], // channel raw value chanRaw[5], // channel raw value
chanRaw[6], // channel raw value chanRaw[6], // channel raw value
chanRaw[7], // channel raw value chanRaw[7], // channel raw value
chanRaw[8], // channel raw value chanRaw[8], // channel raw value
chanRaw[9], // channel raw value chanRaw[9], // channel raw value
chanRaw[10], // channel raw value chanRaw[10], // channel raw value
chanRaw[11], // channel raw value chanRaw[11], // channel raw value
chanRaw[12], // channel raw value chanRaw[12], // channel raw value
chanRaw[13], // channel raw value chanRaw[13], // channel raw value
chanRaw[14], // channel raw value chanRaw[14], // channel raw value
chanRaw[15], // channel raw value chanRaw[15], // channel raw value
chanRaw[16], // channel raw value chanRaw[16], // channel raw value
chanRaw[17], // channel raw value chanRaw[17], // channel raw value
0); // rss 0); // rss
respondWithMavlinkMessage(responseMsg); respondWithMavlinkMessage(responseMsg);
} }
@ -791,6 +791,9 @@ void MockLink::_handleCommandLong(const mavlink_message_t& msg)
commandResult = MAV_RESULT_ACCEPTED; commandResult = MAV_RESULT_ACCEPTED;
break; break;
case MAV_CMD_PREFLIGHT_CALIBRATION: case MAV_CMD_PREFLIGHT_CALIBRATION:
_handlePreFlightCalibration(request);
commandResult = MAV_RESULT_ACCEPTED;
break;
case MAV_CMD_PREFLIGHT_STORAGE: case MAV_CMD_PREFLIGHT_STORAGE:
commandResult = MAV_RESULT_ACCEPTED; commandResult = MAV_RESULT_ACCEPTED;
break; break;
@ -889,16 +892,16 @@ void MockLink::_sendStatusTextMessages(void)
}; };
static const struct StatusMessage rgMessages[] = { static const struct StatusMessage rgMessages[] = {
{ MAV_SEVERITY_INFO, "#Testing audio output" }, { MAV_SEVERITY_INFO, "#Testing audio output" },
{ MAV_SEVERITY_EMERGENCY, "Status text emergency" }, { MAV_SEVERITY_EMERGENCY, "Status text emergency" },
{ MAV_SEVERITY_ALERT, "Status text alert" }, { MAV_SEVERITY_ALERT, "Status text alert" },
{ MAV_SEVERITY_CRITICAL, "Status text critical" }, { MAV_SEVERITY_CRITICAL, "Status text critical" },
{ MAV_SEVERITY_ERROR, "Status text error" }, { MAV_SEVERITY_ERROR, "Status text error" },
{ MAV_SEVERITY_WARNING, "Status text warning" }, { MAV_SEVERITY_WARNING, "Status text warning" },
{ MAV_SEVERITY_NOTICE, "Status text notice" }, { MAV_SEVERITY_NOTICE, "Status text notice" },
{ MAV_SEVERITY_INFO, "Status text info" }, { MAV_SEVERITY_INFO, "Status text info" },
{ MAV_SEVERITY_DEBUG, "Status text debug" }, { MAV_SEVERITY_DEBUG, "Status text debug" },
}; };
for (size_t i=0; i<sizeof(rgMessages)/sizeof(rgMessages[0]); i++) { for (size_t i=0; i<sizeof(rgMessages)/sizeof(rgMessages[0]); i++) {
mavlink_message_t msg; mavlink_message_t msg;
@ -1053,3 +1056,33 @@ void MockLink::_sendRCChannels(void)
respondWithMavlinkMessage(msg); respondWithMavlinkMessage(msg);
} }
void MockLink::_handlePreFlightCalibration(const mavlink_command_long_t& request)
{
const char* pCalMessage;
static const char* gyroCalResponse = "[cal] calibration started: 2 gyro";
static const char* magCalResponse = "[cal] calibration started: 2 mag";
static const char* accelCalResponse = "[cal] calibration started: 2 accel";
if (request.param1 == 1) {
// Gyro cal
pCalMessage = gyroCalResponse;
} else if (request.param2 == 1) {
// Mag cal
pCalMessage = magCalResponse;
} else if (request.param5 == 1) {
// Accel cal
pCalMessage = accelCalResponse;
} else {
return;
}
mavlink_message_t msg;
mavlink_msg_statustext_pack(_vehicleSystemId,
_vehicleComponentId,
&msg,
MAV_SEVERITY_INFO,
pCalMessage);
respondWithMavlinkMessage(msg);
}

1
src/comm/MockLink.h

@ -166,6 +166,7 @@ private:
void _handleFTP(const mavlink_message_t& msg); void _handleFTP(const mavlink_message_t& msg);
void _handleCommandLong(const mavlink_message_t& msg); void _handleCommandLong(const mavlink_message_t& msg);
void _handleManualControl(const mavlink_message_t& msg); void _handleManualControl(const mavlink_message_t& msg);
void _handlePreFlightCalibration(const mavlink_command_long_t& request);
float _floatUnionForParam(int componentId, const QString& paramName); float _floatUnionForParam(int componentId, const QString& paramName);
void _setParamFloatUnionIntoMap(int componentId, const QString& paramName, float paramFloat); void _setParamFloatUnionIntoMap(int componentId, const QString& paramName, float paramFloat);
void _sendHomePosition(void); void _sendHomePosition(void);

Loading…
Cancel
Save