Commit e67c357c authored by Gus Grubba's avatar Gus Grubba

Allow disabling the Ardupilot dialect (and using either common or a different dialect altogether).

parent f58fe001
...@@ -7,20 +7,35 @@ WindowsBuild { ...@@ -7,20 +7,35 @@ WindowsBuild {
# #
# [REQUIRED] Add support for the MAVLink communications protocol. # [REQUIRED] Add support for the MAVLink communications protocol.
# Mavlink dialect is hardwired to arudpilotmega for now. The reason being #
# By default MAVLink dialect is hardwired to arudpilotmega. The reason being
# the current codebase supports both PX4 and APM flight stack. PX4 flight stack # the current codebase supports both PX4 and APM flight stack. PX4 flight stack
# only usese common mavlink specifications, whereas APM flight stack uses custom # only uses common MAVLink specifications, whereas APM flight stack uses custom
# mavlink specifications which add to common. So by using the adupilotmega dialect # MAVLink specifications which adds to common. So by using the adupilotmega dialect
# QGC can support both in the same codebase. # QGC can support both in the same codebase.
#
# Once the mavlink helper routines include support for multiple dialects within # Once the mavlink helper routines include support for multiple dialects within
# a single compiled codebase this hardwiring of dialect can go away. But until then # a single compiled codebase this hardwiring of dialect can go away. But until then
# this "workaround" is needed. # this "workaround" is needed.
MAVLINKPATH_REL = libs/mavlink/include/mavlink/v2.0 # In the mean time, it’s possible to define a completely different dialect by defining the
MAVLINKPATH = $$BASEDIR/$$MAVLINKPATH_REL # location and name below.
MAVLINK_CONF = ardupilotmega
DEFINES += MAVLINK_NO_DATA isEmpty(MAVLINKPATH_REL) {
MAVLINKPATH_REL = libs/mavlink/include/mavlink/v2.0
}
isEmpty(MAVLINKPATH) {
MAVLINKPATH = $$BASEDIR/$$MAVLINKPATH_REL
}
isEmpty(MAVLINK_CONF) {
MAVLINK_CONF = ardupilotmega
}
# If defined, all APM specific MAVLink messages are disabled
contains (CONFIG, QGC_DISABLE_APM_MAVLINK) {
message("Disable APM MAVLink support")
DEFINES += NO_ARDUPILOT_DIALECT
}
# First we select the dialect, checking for valid user selection # First we select the dialect, checking for valid user selection
# Users can override all other settings by specifying MAVLINK_CONF as an argument to qmake # Users can override all other settings by specifying MAVLINK_CONF as an argument to qmake
......
...@@ -674,9 +674,6 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes ...@@ -674,9 +674,6 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes
case MAVLINK_MSG_ID_SCALED_PRESSURE3: case MAVLINK_MSG_ID_SCALED_PRESSURE3:
_handleScaledPressure3(message); _handleScaledPressure3(message);
break; break;
case MAVLINK_MSG_ID_CAMERA_FEEDBACK:
_handleCameraFeedback(message);
break;
case MAVLINK_MSG_ID_CAMERA_IMAGE_CAPTURED: case MAVLINK_MSG_ID_CAMERA_IMAGE_CAPTURED:
_handleCameraImageCaptured(message); _handleCameraImageCaptured(message);
break; break;
...@@ -691,11 +688,16 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes ...@@ -691,11 +688,16 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes
emit mavlinkSerialControl(ser.device, ser.flags, ser.timeout, ser.baudrate, QByteArray(reinterpret_cast<const char*>(ser.data), ser.count)); emit mavlinkSerialControl(ser.device, ser.flags, ser.timeout, ser.baudrate, QByteArray(reinterpret_cast<const char*>(ser.data), ser.count));
} }
break; break;
// Following are ArduPilot dialect messages
// Following are ArduPilot dialect messages
#if !defined(NO_ARDUPILOT_DIALECT)
case MAVLINK_MSG_ID_CAMERA_FEEDBACK:
_handleCameraFeedback(message);
break;
case MAVLINK_MSG_ID_WIND: case MAVLINK_MSG_ID_WIND:
_handleWind(message); _handleWind(message);
break; break;
#endif
} }
// This must be emitted after the vehicle processes the message. This way the vehicle state is up to date when anyone else // This must be emitted after the vehicle processes the message. This way the vehicle state is up to date when anyone else
...@@ -706,6 +708,7 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes ...@@ -706,6 +708,7 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes
} }
#if !defined(NO_ARDUPILOT_DIALECT)
void Vehicle::_handleCameraFeedback(const mavlink_message_t& message) void Vehicle::_handleCameraFeedback(const mavlink_message_t& message)
{ {
mavlink_camera_feedback_t feedback; mavlink_camera_feedback_t feedback;
...@@ -716,6 +719,7 @@ void Vehicle::_handleCameraFeedback(const mavlink_message_t& message) ...@@ -716,6 +719,7 @@ void Vehicle::_handleCameraFeedback(const mavlink_message_t& message)
qCDebug(VehicleLog) << "_handleCameraFeedback coord:index" << imageCoordinate << feedback.img_idx; qCDebug(VehicleLog) << "_handleCameraFeedback coord:index" << imageCoordinate << feedback.img_idx;
_cameraTriggerPoints.append(new QGCQGeoCoordinate(imageCoordinate, this)); _cameraTriggerPoints.append(new QGCQGeoCoordinate(imageCoordinate, this));
} }
#endif
void Vehicle::_handleCameraImageCaptured(const mavlink_message_t& message) void Vehicle::_handleCameraImageCaptured(const mavlink_message_t& message)
{ {
...@@ -1014,6 +1018,7 @@ void Vehicle::_handleWindCov(mavlink_message_t& message) ...@@ -1014,6 +1018,7 @@ void Vehicle::_handleWindCov(mavlink_message_t& message)
_windFactGroup.verticalSpeed()->setRawValue(0); _windFactGroup.verticalSpeed()->setRawValue(0);
} }
#if !defined(NO_ARDUPILOT_DIALECT)
void Vehicle::_handleWind(mavlink_message_t& message) void Vehicle::_handleWind(mavlink_message_t& message)
{ {
mavlink_wind_t wind; mavlink_wind_t wind;
...@@ -1023,6 +1028,7 @@ void Vehicle::_handleWind(mavlink_message_t& message) ...@@ -1023,6 +1028,7 @@ void Vehicle::_handleWind(mavlink_message_t& message)
_windFactGroup.speed()->setRawValue(wind.speed); _windFactGroup.speed()->setRawValue(wind.speed);
_windFactGroup.verticalSpeed()->setRawValue(wind.speed_z); _windFactGroup.verticalSpeed()->setRawValue(wind.speed_z);
} }
#endif
void Vehicle::_handleSysStatus(mavlink_message_t& message) void Vehicle::_handleSysStatus(mavlink_message_t& message)
{ {
......
...@@ -891,7 +891,6 @@ private: ...@@ -891,7 +891,6 @@ private:
void _handleBatteryStatus(mavlink_message_t& message); void _handleBatteryStatus(mavlink_message_t& message);
void _handleSysStatus(mavlink_message_t& message); void _handleSysStatus(mavlink_message_t& message);
void _handleWindCov(mavlink_message_t& message); void _handleWindCov(mavlink_message_t& message);
void _handleWind(mavlink_message_t& message);
void _handleVibration(mavlink_message_t& message); void _handleVibration(mavlink_message_t& message);
void _handleExtendedSysState(mavlink_message_t& message); void _handleExtendedSysState(mavlink_message_t& message);
void _handleCommandAck(mavlink_message_t& message); void _handleCommandAck(mavlink_message_t& message);
...@@ -906,7 +905,11 @@ private: ...@@ -906,7 +905,11 @@ private:
void _handleScaledPressure(mavlink_message_t& message); void _handleScaledPressure(mavlink_message_t& message);
void _handleScaledPressure2(mavlink_message_t& message); void _handleScaledPressure2(mavlink_message_t& message);
void _handleScaledPressure3(mavlink_message_t& message); void _handleScaledPressure3(mavlink_message_t& message);
// ArduPilot dialect messages
#if !defined(NO_ARDUPILOT_DIALECT)
void _handleCameraFeedback(const mavlink_message_t& message); void _handleCameraFeedback(const mavlink_message_t& message);
void _handleWind(mavlink_message_t& message);
#endif
void _handleCameraImageCaptured(const mavlink_message_t& message); void _handleCameraImageCaptured(const mavlink_message_t& message);
void _handleADSBVehicle(const mavlink_message_t& message); void _handleADSBVehicle(const mavlink_message_t& message);
void _missionManagerError(int errorCode, const QString& errorMsg); void _missionManagerError(int errorCode, const QString& errorMsg);
......
...@@ -883,18 +883,21 @@ void MockLink::_respondWithAutopilotVersion(void) ...@@ -883,18 +883,21 @@ void MockLink::_respondWithAutopilotVersion(void)
uint8_t customVersion[8] = { }; uint8_t customVersion[8] = { };
uint32_t flightVersion = 0; uint32_t flightVersion = 0;
#if !defined(NO_ARDUPILOT_DIALECT)
if (_firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA) { if (_firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA) {
flightVersion |= 3 << (8*3); flightVersion |= 3 << (8*3);
flightVersion |= 5 << (8*2); flightVersion |= 5 << (8*2);
flightVersion |= 0 << (8*1); flightVersion |= 0 << (8*1);
flightVersion |= FIRMWARE_VERSION_TYPE_DEV << (8*0); flightVersion |= FIRMWARE_VERSION_TYPE_DEV << (8*0);
} else if (_firmwareType == MAV_AUTOPILOT_PX4) { } else if (_firmwareType == MAV_AUTOPILOT_PX4) {
#endif
flightVersion |= 1 << (8*3); flightVersion |= 1 << (8*3);
flightVersion |= 4 << (8*2); flightVersion |= 4 << (8*2);
flightVersion |= 1 << (8*1); flightVersion |= 1 << (8*1);
flightVersion |= FIRMWARE_VERSION_TYPE_DEV << (8*0); flightVersion |= FIRMWARE_VERSION_TYPE_DEV << (8*0);
#if !defined(NO_ARDUPILOT_DIALECT)
} }
#endif
mavlink_msg_autopilot_version_pack_chan(_vehicleSystemId, mavlink_msg_autopilot_version_pack_chan(_vehicleSystemId,
_vehicleComponentId, _vehicleComponentId,
_mavlinkChannel, _mavlinkChannel,
...@@ -909,7 +912,12 @@ void MockLink::_respondWithAutopilotVersion(void) ...@@ -909,7 +912,12 @@ void MockLink::_respondWithAutopilotVersion(void)
(uint8_t *)&customVersion, // os_custom_version, (uint8_t *)&customVersion, // os_custom_version,
0, // vendor_id, 0, // vendor_id,
0, // product_id, 0, // product_id,
0); // uid 0 // uid
#if defined(NO_ARDUPILOT_DIALECT)
//-- Once the MAVLink module is updated, this should show up. In the mean time, it's disabled.
,0 // uid2
#endif
);
respondWithMavlinkMessage(msg); respondWithMavlinkMessage(msg);
} }
......
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