Commit ca8ee3ad authored by Gus Grubba's avatar Gus Grubba

Merge branch 'master' of https://github.com/mavlink/qgroundcontrol into qgc4

# Conflicts:
#	src/FlightDisplay/VirtualJoystick.qml
#	src/ui/preferences/GeneralSettings.qml
parents 26fdfb7f 5be9accf
......@@ -446,46 +446,55 @@ void APMFirmwarePlugin::_handleIncomingHeartbeat(Vehicle* vehicle, mavlink_messa
{
bool flying = false;
// We pull Vehicle::flying state from HEARTBEAT on ArduPilot. This is a firmware specific test.
mavlink_heartbeat_t heartbeat;
mavlink_msg_heartbeat_decode(message, &heartbeat);
if (vehicle->armed()) {
mavlink_heartbeat_t heartbeat;
mavlink_msg_heartbeat_decode(message, &heartbeat);
if (message->compid == MAV_COMP_ID_AUTOPILOT1) {
// We pull Vehicle::flying state from HEARTBEAT on ArduPilot. This is a firmware specific test.
if (vehicle->armed()) {
flying = heartbeat.system_status == MAV_STATE_ACTIVE;
if (!flying && vehicle->flying()) {
// If we were previously flying, and we go into critical or emergency assume we are still flying
flying = heartbeat.system_status == MAV_STATE_CRITICAL || heartbeat.system_status == MAV_STATE_EMERGENCY;
flying = heartbeat.system_status == MAV_STATE_ACTIVE;
if (!flying && vehicle->flying()) {
// If we were previously flying, and we go into critical or emergency assume we are still flying
flying = heartbeat.system_status == MAV_STATE_CRITICAL || heartbeat.system_status == MAV_STATE_EMERGENCY;
}
}
vehicle->_setFlying(flying);
}
vehicle->_setFlying(flying);
// We need to know whether this component is part of the ArduPilot stack code or not so we can adjust mavlink quirks appropriately.
// If the component sends a heartbeat we can know that. If it's doesn't there is pretty much no way to know.
_ardupilotComponentMap[message->sysid][message->compid] = heartbeat.autopilot == MAV_AUTOPILOT_ARDUPILOTMEGA;
// Force the ESP8266 to be non-ArduPilot code (it doesn't send heartbeats)
_ardupilotComponentMap[message->sysid][MAV_COMP_ID_UDP_BRIDGE] = false;
}
bool APMFirmwarePlugin::adjustIncomingMavlinkMessage(Vehicle* vehicle, mavlink_message_t* message)
{
// Only translate messages which come from the autopilot. All other components are expected to follow current mavlink spec.
if (message->compid != MAV_COMP_ID_AUTOPILOT1) {
if (message->msgid == MAVLINK_MSG_ID_HEARTBEAT) {
// We need to look at all heartbeats that go by from any component
_handleIncomingHeartbeat(vehicle, message);
return true;
}
switch (message->msgid) {
case MAVLINK_MSG_ID_PARAM_VALUE:
_handleIncomingParamValue(vehicle, message);
break;
case MAVLINK_MSG_ID_STATUSTEXT:
return _handleIncomingStatusText(vehicle, message, false /* longVersion */);
case MAVLINK_MSG_ID_STATUSTEXT_LONG:
return _handleIncomingStatusText(vehicle, message, true /* longVersion */);
case MAVLINK_MSG_ID_HEARTBEAT:
_handleIncomingHeartbeat(vehicle, message);
break;
case MAVLINK_MSG_ID_RC_CHANNELS:
_handleRCChannels(vehicle, message);
break;
case MAVLINK_MSG_ID_RC_CHANNELS_RAW:
_handleRCChannelsRaw(vehicle, message);
break;
// Only translate messages which come from ArduPilot code. All other components are expected to follow current mavlink spec.
if (_ardupilotComponentMap[vehicle->id()][message->compid]) {
switch (message->msgid) {
case MAVLINK_MSG_ID_PARAM_VALUE:
_handleIncomingParamValue(vehicle, message);
break;
case MAVLINK_MSG_ID_STATUSTEXT:
return _handleIncomingStatusText(vehicle, message, false /* longVersion */);
case MAVLINK_MSG_ID_STATUSTEXT_LONG:
return _handleIncomingStatusText(vehicle, message, true /* longVersion */);
case MAVLINK_MSG_ID_RC_CHANNELS:
_handleRCChannels(vehicle, message);
break;
case MAVLINK_MSG_ID_RC_CHANNELS_RAW:
_handleRCChannelsRaw(vehicle, message);
break;
}
}
return true;
......@@ -493,15 +502,13 @@ bool APMFirmwarePlugin::adjustIncomingMavlinkMessage(Vehicle* vehicle, mavlink_m
void APMFirmwarePlugin::adjustOutgoingMavlinkMessage(Vehicle* vehicle, LinkInterface* outgoingLink, mavlink_message_t* message)
{
//-- Don't process messages to/from UDP Bridge. It doesn't suffer from these issues
if (message->compid == MAV_COMP_ID_UDP_BRIDGE) {
return;
}
switch (message->msgid) {
case MAVLINK_MSG_ID_PARAM_SET:
_handleOutgoingParamSet(vehicle, outgoingLink, message);
break;
// Only translate messages which come from ArduPilot code. All other components are expected to follow current mavlink spec.
if (_ardupilotComponentMap[vehicle->id()][message->compid]) {
switch (message->msgid) {
case MAVLINK_MSG_ID_PARAM_SET:
_handleOutgoingParamSet(vehicle, outgoingLink, message);
break;
}
}
}
......
......@@ -137,6 +137,7 @@ private:
// Vehicle specific data should go into APMFirmwarePluginInstanceData
QList<APMCustomMode> _supportedModes;
QMap<int /* vehicle id */, QMap<int /* componentId */, bool /* true: component is part of ArduPilot stack */>> _ardupilotComponentMap;
static const char* _artooIP;
static const int _artooVideoHandshakePort;
......
......@@ -559,8 +559,11 @@ Item {
active: (_virtualJoystick ? _virtualJoystick.value : false) && !(activeVehicle ? activeVehicle.highLatencyLink : false)
property bool useLightColors: isBackgroundDark
// The default behaviour is not centralized throttle
property bool centralizeThrottle: _virtualJoystickCentralized ? _virtualJoystickCentralized.value : false
property Fact _virtualJoystick: QGroundControl.settingsManager.appSettings.virtualJoystick
property Fact _virtualJoystickCentralized: QGroundControl.settingsManager.appSettings.virtualJoystickCentralized
}
ToolStrip {
......
......@@ -85,6 +85,10 @@ Item {
target: QGroundControl.settingsManager.appSettings.virtualJoystick
onValueChanged: _setInstrumentWidget()
}
Connections {
target: QGroundControl.settingsManager.appSettings.virtualJoystickCentralized
onValueChanged: _setInstrumentWidget()
}
Connections {
target: QGroundControl.settingsManager.appSettings.showLargeCompass
......
......@@ -17,8 +17,8 @@ import QGroundControl.Palette 1.0
import QGroundControl.Vehicle 1.0
Item {
//property bool useLightColors - Must be passed in from loader
//property bool useLightColors - Must be passed in from loaded
//property bool centralizeThrottle - Must be passed in from loaded
Timer {
interval: 40 // 25Hz, same as real joystick rate
running: QGroundControl.settingsManager.appSettings.virtualJoystick.value && activeVehicle
......@@ -39,8 +39,8 @@ Item {
width: parent.height
height: parent.height
yAxisThrottle: true
yAxisThrottleCentered: centralizeThrottle
lightColors: useLightColors
throttle: true
}
JoystickThumbPad {
......
......@@ -11,26 +11,36 @@ Item {
property real xAxis: 0 ///< Value range [-1,1], negative values left stick, positive values right stick
property real yAxis: 0 ///< Value range [-1,1], negative values up stick, positive values down stick
property bool yAxisThrottle: false ///< true: yAxis used for throttle, range [1,0], positive value are stick up
property bool yAxisThrottleCentered: false ///< false: center yAxis in throttle for reverser and forward
property real xPositionDelta: 0 ///< Amount to move the control on x axis
property real yPositionDelta: 0 ///< Amount to move the control on y axis
property bool throttle: false
property real _centerXY: width / 2
property bool _processTouchPoints: false
property bool _stickCenteredOnce: false
property real stickPositionX: _centerXY
property real stickPositionY: yAxisThrottle ? height : _centerXY
property real stickPositionY: yAxisThrottleCentered ? _centerXY : height
QGCMapPalette { id: mapPal }
onStickPositionXChanged: {
onWidthChanged: calculateXAxis()
onStickPositionXChanged: calculateXAxis()
onHeightChanged: calculateYAxis()
onStickPositionYChanged: calculateYAxis()
function calculateXAxis() {
if(!_joyRoot.visible) {
return;
}
var xAxisTemp = stickPositionX / width
xAxisTemp *= 2.0
xAxisTemp -= 1.0
xAxis = xAxisTemp
}
onStickPositionYChanged: {
function calculateYAxis() {
if(!_joyRoot.visible) {
return;
}
var yAxisTemp = stickPositionY / height
yAxisTemp *= 2.0
yAxisTemp -= 1.0
......@@ -40,8 +50,7 @@ Item {
yAxis = yAxisTemp
}
function reCenter()
{
function reCenter() {
_processTouchPoints = false
// Move control back to original position
......@@ -50,13 +59,12 @@ Item {
// Center sticks
stickPositionX = _centerXY
if (!yAxisThrottle) {
if (yAxisThrottleCentered) {
stickPositionY = _centerXY
}
}
function thumbDown(touchPoints)
{
function thumbDown(touchPoints) {
// Position the control around the initial thumb position
xPositionDelta = touchPoints[0].x - _centerXY
if (yAxisThrottle) {
......@@ -86,7 +94,7 @@ Item {
QGCColoredImage {
color: lightColors ? "white" : "black"
visible: throttle
visible: yAxisThrottle
height: ScreenTools.defaultFontPixelHeight
width: height
sourceSize.height: height
......@@ -100,7 +108,7 @@ Item {
QGCColoredImage {
color: lightColors ? "white" : "black"
visible: throttle
visible: yAxisThrottle
height: ScreenTools.defaultFontPixelHeight
width: height
sourceSize.height: height
......@@ -114,7 +122,7 @@ Item {
QGCColoredImage {
color: lightColors ? "white" : "black"
visible: throttle
visible: yAxisThrottle
height: ScreenTools.defaultFontPixelHeight
width: height
sourceSize.height: height
......@@ -128,7 +136,7 @@ Item {
QGCColoredImage {
color: lightColors ? "white" : "black"
visible: throttle
visible: yAxisThrottle
height: ScreenTools.defaultFontPixelHeight
width: height
sourceSize.height: height
......
......@@ -103,6 +103,13 @@
"type": "bool",
"defaultValue": false
},
{
"name": "virtualJoystickCentralized",
"shortDescription": "Set virtual joystick to be centralize throttle (spring-loaded).",
"longDescription": "If this option is enabled the virtual joystick throttle stick will be centralized.",
"type": "bool",
"defaultValue": false
},
{
"name": "gstDebugLevel",
"shortDescription": "Video streaming debug",
......
......@@ -78,6 +78,7 @@ DECLARE_SETTINGSFACT(AppSettings, telemetrySave)
DECLARE_SETTINGSFACT(AppSettings, telemetrySaveNotArmed)
DECLARE_SETTINGSFACT(AppSettings, audioMuted)
DECLARE_SETTINGSFACT(AppSettings, virtualJoystick)
DECLARE_SETTINGSFACT(AppSettings, virtualJoystickCentralized)
DECLARE_SETTINGSFACT(AppSettings, appFontPointSize)
DECLARE_SETTINGSFACT(AppSettings, showLargeCompass)
DECLARE_SETTINGSFACT(AppSettings, savePath)
......
......@@ -33,6 +33,7 @@ public:
DEFINE_SETTINGFACT(telemetrySaveNotArmed)
DEFINE_SETTINGFACT(audioMuted)
DEFINE_SETTINGFACT(virtualJoystick)
DEFINE_SETTINGFACT(virtualJoystickCentralized)
DEFINE_SETTINGFACT(appFontPointSize)
DEFINE_SETTINGFACT(indoorPalette)
DEFINE_SETTINGFACT(showLargeCompass)
......
......@@ -818,20 +818,24 @@ SetupPage {
MouseArea {
id: deadbandMouseArea
anchors.fill: parent.item
enabled: controller.deadbandToggle
id: deadbandMouseArea
anchors.fill: parent.item
enabled: controller.deadbandToggle
preventStealing: true
property real startY
property real startX
property real direction
onPressed: {
startY = mouseY
startX = mouseX
direction = startX > width/2 ? 1 : -1
parent.item.deadbandColor = "#3C6315"
}
onPositionChanged: {
var newValue = parent.item.deadbandValue + (startY - mouseY)*15
var mouseToDeadband = 32768/(width/2) // Factor to have deadband follow the mouse movement
var newValue = parent.item.deadbandValue + direction*(mouseX - startX)*mouseToDeadband
if ((newValue > 0) && (newValue <32768)){parent.item.deadbandValue=newValue;}
startY = mouseY
startX = mouseX
}
onReleased: {
controller.setDeadbandValue(modelData,parent.item.deadbandValue)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment