Commit 35dca1d0 authored by Bryant's avatar Bryant

Improved MAVLink dialect selection.

MAVLink dialects can now be specified as a list, so multiple dialects can be compiled in simultaneously (may result in conflicts between dialects).
MAVLink dialects are checked for existance before support is added.
Users are notified of which dialects are used and which cannot be added and why.
The README now has info about specifying MAVLink dialects.
parent 29ef19a6
...@@ -70,33 +70,70 @@ else { ...@@ -70,33 +70,70 @@ else {
} }
# #
# MAVLink # Add support for MAVLink. This is a required dependency for QGC.
# # Some logic is involved here in selecting the proper dialect for
# the selected autopilot system.
MAVLINK_CONF = "" #
MAVLINKPATH = $$BASEDIR/libs/mavlink/include/mavlink/v1.0 # If the user config file exists, it will be included. If this file
# specifies the MAVLINK_CONF variable with a list of MAVLink
# dialects, support for them will be compiled in to QGC. It will also
# create a QGC_USE_{AUTOPILOT_NAME}_MESSAGES macro for use within
# the actual code.
#
MAVLINKPATH_REL = libs/mavlink/include/mavlink/v1.0
MAVLINKPATH = $$BASEDIR/$$MAVLINKPATH_REL
DEFINES += MAVLINK_NO_DATA DEFINES += MAVLINK_NO_DATA
# If the user config file exists, it will be included. # First we select the dialect, checking for valid user selection
# if the variable MAVLINK_CONF contains the name of an # Users can override all other settings by specifying MAVLINK_CONF as an argument to qmake
# additional project, QGroundControl includes the support !isEmpty(MAVLINK_CONF) {
# of custom MAVLink messages of this project. It will also for(dialect, MAVLINK_CONF) {
# create a QGC_USE_{AUTOPILOT_NAME}_MESSAGES macro for use exists($$MAVLINKPATH/$$dialect) {
# within the actual code. MAVLINK_DIALECTS += $$dialect
exists(user_config.pri) { message($$sprintf("Using MAVLink dialect '%1' specified at the command line.", $$dialect))
} else {
error($$sprintf("MAVLink dialect '%1' specified at the command line does not exist at '%2'!", $$dialect, $$MAVLINKPATH_REL))
}
}
}
# Otherwise they can specify MAVLINK_CONF within user_config.pri
else:exists(user_config.pri) {
include(user_config.pri) include(user_config.pri)
message("----- USING CUSTOM USER QGROUNDCONTROL CONFIG FROM user_config.pri -----") !isEmpty(MAVLINK_CONF) {
message("Adding support for additional MAVLink messages for: " $$MAVLINK_CONF) for(dialect, MAVLINK_CONF) {
message("------------------------------------------------------------------------") exists($$MAVLINKPATH/$$dialect) {
} else { MAVLINK_DIALECTS += $$dialect
MAVLINK_CONF += ardupilotmega message($$sprintf("Using MAVLink dialect '%1' specified in user_config.pri", $$dialect))
} else {
error($$sprintf("MAVLink dialect '%1' specified in user_config.pri does not exist at '%2'!", $$dialect, $$MAVLINKPATH_REL))
}
}
}
} }
# If no valid user selection is found, default to the ardupilotmega if it's available.
# Note: This can be a list of several dialects.
else {
DEFAULT_MAVLINK_DIALECTS=ardupilotmega
for(dialect, DEFAULT_MAVLINK_DIALECTS) {
exists($$MAVLINKPATH/$$dialect) {
MAVLINK_DIALECTS += $$dialect
message($$sprintf("Using default MAVLink dialect '%1'.", $$dialect))
} else {
warning($$sprintf("Default MAVLink dialect '%1' does not exist at '%2'!", $$dialect, $$MAVLINKPATH_REL))
}
}
}
# Then we add the proper include paths dependent on the dialects and notify
# the user of the current dialect.
INCLUDEPATH += $$MAVLINKPATH INCLUDEPATH += $$MAVLINKPATH
isEmpty(MAVLINK_CONF) { !isEmpty(MAVLINK_DIALECTS) {
INCLUDEPATH += $$MAVLINKPATH/common for(dialect, MAVLINK_DIALECTS) {
INCLUDEPATH += $$MAVLINKPATH/$$dialect
DEFINES += $$sprintf('QGC_USE_%1_MESSAGES', $$upper($$dialect))
}
} else { } else {
INCLUDEPATH += $$MAVLINKPATH/$$MAVLINK_CONF message("No valid MAVLink dialects found, only common messages supported.")
DEFINES += $$sprintf('QGC_USE_%1_MESSAGES', $$upper($$MAVLINK_CONF)) INCLUDEPATH += $$MAVLINKPATH/common
} }
# #
...@@ -238,7 +275,7 @@ MacBuild | WindowsBuild { ...@@ -238,7 +275,7 @@ MacBuild | WindowsBuild {
# Protcol Buffers for PixHawk # Protcol Buffers for PixHawk
# #
LinuxBuild : contains(MAVLINK_CONF, pixhawk) { LinuxBuild : contains(MAVLINK_DIALECT, pixhawk) {
exists(/usr/local/include/google/protobuf) | exists(/usr/include/google/protobuf) { exists(/usr/local/include/google/protobuf) | exists(/usr/include/google/protobuf) {
message("Including support for Protocol Buffers") message("Including support for Protocol Buffers")
......
...@@ -29,6 +29,11 @@ To include QUpgrade functionality run the following (only needs to be done once ...@@ -29,6 +29,11 @@ To include QUpgrade functionality run the following (only needs to be done once
The QUpgrade module relies on `libudev` on Linux platforms. The QUpgrade module relies on `libudev` on Linux platforms.
### Specifying MAVLink dialects
The MAVLink dialect compiled by default by QGC is for the ardupilotmega. This will happen if no other dialects are specified. To override this create a `user_config.pri` file in the root directory and set the `MAVLINK_CONF` variable using qmake's variable notation syntax: `MAVLINK_CONF=sensesoar`. This variable can be a list of dialects that should all be supported like `MAVLINK_CONF=sensesoar ardupilotmega`. Note that doing this may result in compilation errors as certain dialects may conflict with each other!
The `MAVLINK_CONF` variable can also be specified at the command line as an argument to qmake to allow for easy one-off compilations: `qmake MAVLINK_CONF="sensesoar ardupilotmega"`
# Build on Mac OSX # Build on Mac OSX
To build on Mac OSX (10.6 or later): To build on Mac OSX (10.6 or later):
......
...@@ -28,6 +28,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -28,6 +28,7 @@ This file is part of the QGROUNDCONTROL project
#include "ArduPilotMegaMAV.h" #include "ArduPilotMegaMAV.h"
#ifdef QGC_USE_ARDUPILOTMEGA_MESSAGES
#ifndef MAVLINK_MSG_ID_MOUNT_CONFIGURE #ifndef MAVLINK_MSG_ID_MOUNT_CONFIGURE
#include "ardupilotmega/mavlink_msg_mount_configure.h" #include "ardupilotmega/mavlink_msg_mount_configure.h"
#endif #endif
...@@ -35,6 +36,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -35,6 +36,7 @@ This file is part of the QGROUNDCONTROL project
#ifndef MAVLINK_MSG_ID_MOUNT_CONTROL #ifndef MAVLINK_MSG_ID_MOUNT_CONTROL
#include "ardupilotmega/mavlink_msg_mount_control.h" #include "ardupilotmega/mavlink_msg_mount_control.h"
#endif #endif
#endif
ArduPilotMegaMAV::ArduPilotMegaMAV(MAVLinkProtocol* mavlink, int id) : ArduPilotMegaMAV::ArduPilotMegaMAV(MAVLinkProtocol* mavlink, int id) :
UAS(mavlink, id)//, UAS(mavlink, id)//,
...@@ -96,13 +98,16 @@ void ArduPilotMegaMAV::receiveMessage(LinkInterface* link, mavlink_message_t mes ...@@ -96,13 +98,16 @@ void ArduPilotMegaMAV::receiveMessage(LinkInterface* link, mavlink_message_t mes
} }
void ArduPilotMegaMAV::setMountConfigure(unsigned char mode, bool stabilize_roll,bool stabilize_pitch,bool stabilize_yaw) void ArduPilotMegaMAV::setMountConfigure(unsigned char mode, bool stabilize_roll,bool stabilize_pitch,bool stabilize_yaw)
{ {
#ifdef QGC_USE_ARDUPILOTMEGA_MESSAGES
//Only supported by APM //Only supported by APM
mavlink_message_t msg; mavlink_message_t msg;
mavlink_msg_mount_configure_pack(255,1,&msg,this->uasId,1,mode,stabilize_roll,stabilize_pitch,stabilize_yaw); mavlink_msg_mount_configure_pack(255,1,&msg,this->uasId,1,mode,stabilize_roll,stabilize_pitch,stabilize_yaw);
sendMessage(msg); sendMessage(msg);
#endif
} }
void ArduPilotMegaMAV::setMountControl(double pa,double pb,double pc,bool islatlong) void ArduPilotMegaMAV::setMountControl(double pa,double pb,double pc,bool islatlong)
{ {
#ifdef QGC_USE_ARDUPILOTMEGA_MESSAGES
mavlink_message_t msg; mavlink_message_t msg;
if (islatlong) if (islatlong)
{ {
...@@ -113,4 +118,5 @@ void ArduPilotMegaMAV::setMountControl(double pa,double pb,double pc,bool islatl ...@@ -113,4 +118,5 @@ void ArduPilotMegaMAV::setMountControl(double pa,double pb,double pc,bool islatl
mavlink_msg_mount_control_pack(255,1,&msg,this->uasId,1,pa,pb,pc,0); mavlink_msg_mount_control_pack(255,1,&msg,this->uasId,1,pa,pb,pc,0);
} }
sendMessage(msg); sendMessage(msg);
#endif
} }
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