6import QGroundControl.Controls
10 pageComponent: pageComponent
13 readonly property int _barHeight: 10
14 readonly property int _barWidth: 5
15 readonly property int _sliderHeight: 10
17 property int neutralValue: 50;
18 property int _lastIndex: 0;
19 property bool canRunManualTest: controller.vehicle.flightMode !== controller.vehicle.motorDetectionFlightMode && controller.vehicle.armed && motorPage.visible && setupView.visible
20 property var shouldRunManualTest: false // Does the operator intend to run the motor test?
22 APMSubMotorComponentController {
26 function setMotorDirection(num, reversed) {
27 var fact = controller.getParameterFact(-1, "MOT_" + num + "_DIRECTION")
28 fact.value = reversed ? -1 : 1;
31 Component.onCompleted: controller.vehicle.armed = false
41 enabled: canRunManualTest && shouldRunManualTest
42 spacing: ScreenTools.defaultFontPixelWidth * 4
45 spacing: ScreenTools.defaultFontPixelWidth * 2
49 spacing: ScreenTools.defaultFontPixelWidth * 4
53 model: controller.vehicle.motorCount == -1 ? 8 : controller.vehicle.motorCount
56 property alias motorSlider: slider
57 spacing: ScreenTools.defaultFontPixelWidth
60 anchors.horizontalCenter: parent.horizontalCenter
66 height: ScreenTools.defaultFontPixelHeight * _sliderHeight
67 orientation: Qt.Vertical
71 // Give slider 'center sprung' behavior
73 if (!slider.pressed) {
74 slider.value = neutralValue
78 // Disable mouse scroll
83 wheel.accepted = true;
85 onPressed: (mouse) => {
87 mouse.accepted = false;
89 onReleased: (mouse) => {
91 mouse.accepted = false;
101 anchors.left: parent.left
102 anchors.right: parent.right
103 wrapMode: Text.WordWrap
104 text: qsTr("Reverse Motor Direction")
105 horizontalAlignment: Text.AlignHCenter
106 verticalAlignment: Text.AlignBottom
109 anchors.margins: ScreenTools.defaultFontPixelWidth * 3
116 anchors.margins: ScreenTools.defaultFontPixelWidth
120 model: controller.vehicle.motorCount == -1 ? 8 : controller.vehicle.motorCount
123 spacing: ScreenTools.defaultFontPixelWidth
126 width: sliderRow.width / (controller.vehicle.motorCount - 0.5)
127 checked: controller.getParameterFact(-1, "MOT_" + (index + 1) + "_DIRECTION").value == -1
129 sliderRepeater.itemAt(index).motorSlider.value = neutralValue
130 setMotorDirection(index + 1, checked)
138 // Display the frame currently in use with motor numbers
140 anchors.top: parent.top
141 anchors.bottom: parent.bottom
143 frameType: controller.getParameterFact(-1, "FRAME_CONFIG").value
148 anchors.left: parent.left
149 anchors.right: parent.right
150 wrapMode: Text.WordWrap
151 text: qsTr("Moving the sliders will cause the motors to spin. Make sure the motors and propellers are clear from obstructions! The direction of the motor rotation is dependent on how the three phases of the motor are physically connected to the ESCs (if any two wires are swapped, the direction of rotation will flip). Because we cannot guarantee what order the phases are connected, the motor directions must be configured in software. When a slider is moved DOWN, the thruster should push air/water TOWARD the cable entering the housing. Click the checkbox to reverse the direction of the corresponding thruster.\n\n"
152 + "Blue Robotics thrusters are lubricated by water and are not designed to be run in air. Testing the thrusters in air is ok at low speeds for short periods of time. Extended operation of Blue Robotics in air may lead to overheating and permanent damage. Without water lubrication, Blue Robotics thrusters may also make some unpleasant noises when operated in air; this is normal.")
156 spacing: ScreenTools.defaultFontPixelWidth
160 if (controller.vehicle.armed) {
161 shouldRunManualTest = false
163 coolDownTimer.start()
166 controller.vehicle.armed = checked
167 checked = controller.vehicle.armed // Makes the switch stay off if it's not possible to arm
171 // Make sure external changes to Armed are reflected on the switch
173 target: controller.vehicle
176 safetySwitch.checked = armed
178 shouldRunManualTest = false
179 safetySwitch.enabled = false
180 coolDownTimer.start()
182 shouldRunManualTest = true
184 for (var sliderIndex=0; sliderIndex<sliderRepeater.count; sliderIndex++) {
185 sliderRepeater.itemAt(sliderIndex).motorSlider.value = neutralValue
191 anchors.verticalCenter: safetySwitch.verticalCenter
192 color: qgcPal.warningText
193 text: coolDownTimer.running
194 ? qsTr("A 10 second coooldown is required before testing again, please stand by...")
195 : qsTr("Slide this switch to arm the vehicle and enable the motor test (CAUTION!)")
200 visible: controller.vehicle.versionCompare(4, 0, 0) >= 0
202 anchors.left: parent.left
203 anchors.right: parent.right
204 font.pointSize: ScreenTools.largeFontPointSize
205 text: qsTr("Automatic Motor Direction Detection")
209 visible: controller.vehicle.versionCompare(4, 0, 0) >= 0
210 anchors.left: parent.left
211 anchors.right: parent.right
212 wrapMode: Text.WordWrap
213 text: qsTr("This will attempt to automatically detect the direction (normal/reversed) of your thrusters.\n"
214 + "Please place your vehicle in water, click the button, and wait. Note that the thrusters still need "
215 + "to be connected to the correct outputs (thrusters 2 and 3 can't be swapped, for example).")
219 visible: controller.vehicle.versionCompare(4, 0, 0) >= 0
220 spacing: ScreenTools.defaultFontPixelWidth
223 spacing: ScreenTools.defaultFontPixelWidth * 2
226 id: startAutoDetection
227 text: "Auto-Detect Directions"
228 enabled: controller.vehicle.flightMode !== controller.vehicle.motorDetectionFlightMode
230 onClicked: function() {
231 controller.vehicle.flightMode = controller.vehicle.motorDetectionFlightMode
232 controller.vehicle.armed = true
237 spacing: ScreenTools.defaultFontPixelWidth * 2
242 height: Math.min(contentHeight, 200)
244 contentHeight: textArea.implicitHeight
251 text: controller.motorDetectionMessages
252 wrapMode: Text.WordWrap
253 background: Rectangle {
256 onTextChanged: function() {
257 flickable.flick(0, -300)
260 ScrollBar.vertical: ScrollBar {}
265 // Repeats the command signal and updates the checkbox every 50 ms
270 running: canRunManualTest && shouldRunManualTest
273 if (controller.vehicle.armed) {
274 var slider = sliderRepeater.itemAt(_lastIndex)
276 var reversed = controller.getParameterFact(-1, "MOT_" + (_lastIndex + 1) + "_DIRECTION").value == -1
279 controller.vehicle.motorTest(_lastIndex, 100 - slider.motorSlider.value, 0, false)
281 controller.vehicle.motorTest(_lastIndex, slider.motorSlider.value, 0, false)
292 safetySwitch.enabled = true