Commit 8591b855 authored by Mariano Lizarraga's avatar Mariano Lizarraga

Still working on having independent builds for each MAV, most of the work is...

Still working on having independent builds for each MAV, most of the work is done, only Central Widgets remain to be instantiated and menu-controlled based on the autopilot
parent 18b0e07e
...@@ -159,7 +159,13 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -159,7 +159,13 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
switch (heartbeat.autopilot) switch (heartbeat.autopilot)
{ {
case MAV_AUTOPILOT_GENERIC: case MAV_AUTOPILOT_GENERIC:
uas = new UAS(this, message.sysid); uas = new UAS(this, message.sysid);
// Set the autopilot type
uas->setAutopilotType((int)heartbeat.autopilot);
// Connect this robot to the UAS object // Connect this robot to the UAS object
connect(this, SIGNAL(messageReceived(LinkInterface*, mavlink_message_t)), uas, SLOT(receiveMessage(LinkInterface*, mavlink_message_t))); connect(this, SIGNAL(messageReceived(LinkInterface*, mavlink_message_t)), uas, SLOT(receiveMessage(LinkInterface*, mavlink_message_t)));
break; break;
...@@ -167,6 +173,10 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -167,6 +173,10 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
{ {
// Fixme differentiate between quadrotor and coaxial here // Fixme differentiate between quadrotor and coaxial here
PxQuadMAV* mav = new PxQuadMAV(this, message.sysid); PxQuadMAV* mav = new PxQuadMAV(this, message.sysid);
// Set the autopilot type
//mav->setAutopilotType((int)heartbeat.autopilot);
// Connect this robot to the UAS object // Connect this robot to the UAS object
// it is IMPORTANT here to use the right object type, // it is IMPORTANT here to use the right object type,
// else the slot of the parent object is called (and thus the special // else the slot of the parent object is called (and thus the special
...@@ -178,6 +188,10 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -178,6 +188,10 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
case MAV_AUTOPILOT_SLUGS: case MAV_AUTOPILOT_SLUGS:
{ {
SlugsMAV* mav = new SlugsMAV(this, message.sysid); SlugsMAV* mav = new SlugsMAV(this, message.sysid);
// Set the autopilot type
mav->setAutopilotType((int)heartbeat.autopilot);
// Connect this robot to the UAS object // Connect this robot to the UAS object
// it is IMPORTANT here to use the right object type, // it is IMPORTANT here to use the right object type,
// else the slot of the parent object is called (and thus the special // else the slot of the parent object is called (and thus the special
...@@ -189,6 +203,10 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -189,6 +203,10 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
case MAV_AUTOPILOT_ARDUPILOTMEGA: case MAV_AUTOPILOT_ARDUPILOTMEGA:
{ {
ArduPilotMegaMAV* mav = new ArduPilotMegaMAV(this, message.sysid); ArduPilotMegaMAV* mav = new ArduPilotMegaMAV(this, message.sysid);
// Set the autopilot type
mav->setAutopilotType((int)heartbeat.autopilot);
// Connect this robot to the UAS object // Connect this robot to the UAS object
// it is IMPORTANT here to use the right object type, // it is IMPORTANT here to use the right object type,
// else the slot of the parent object is called (and thus the special // else the slot of the parent object is called (and thus the special
...@@ -202,11 +220,21 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -202,11 +220,21 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
break; break;
} }
// Set the autopilot type
uas->setAutopilotType((int)heartbeat.autopilot);
// Make UAS aware that this link can be used to communicate with the actual robot // Make UAS aware that this link can be used to communicate with the actual robot
uas->addLink(link); uas->addLink(link);
// Now add UAS to "official" list, which makes the whole application aware of it // Now add UAS to "official" list, which makes the whole application aware of it
UASManager::instance()->addUAS(uas); UASManager::instance()->addUAS(uas);
qDebug() << "++===============================";
qDebug() << uas->getAutopilotType();
qDebug() << "++===============================";
} }
// Only count message if UAS exists for this message // Only count message if UAS exists for this message
......
...@@ -44,12 +44,13 @@ This file is part of the QGROUNDCONTROL project ...@@ -44,12 +44,13 @@ This file is part of the QGROUNDCONTROL project
#include "MAVLinkProtocol.h" #include "MAVLinkProtocol.h"
#include "QGCMAVLink.h" #include "QGCMAVLink.h"
UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(), UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
uasId(id), uasId(id),
startTime(MG::TIME::getGroundTimeNow()), startTime(MG::TIME::getGroundTimeNow()),
commStatus(COMM_DISCONNECTED), commStatus(COMM_DISCONNECTED),
name(""), name(""),
autopilot(0), autopilot(-1),
links(new QList<LinkInterface*>()), links(new QList<LinkInterface*>()),
unknownPackets(), unknownPackets(),
mavlink(protocol), mavlink(protocol),
...@@ -153,6 +154,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) ...@@ -153,6 +154,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
this->autopilot = mavlink_msg_heartbeat_get_autopilot(&message); this->autopilot = mavlink_msg_heartbeat_get_autopilot(&message);
emit systemTypeSet(this, type); emit systemTypeSet(this, type);
} }
break; break;
case MAVLINK_MSG_ID_BOOT: case MAVLINK_MSG_ID_BOOT:
getStatusForCode((int)MAV_STATE_BOOT, uasState, stateDescription); getStatusForCode((int)MAV_STATE_BOOT, uasState, stateDescription);
......
...@@ -98,7 +98,7 @@ protected: ...@@ -98,7 +98,7 @@ protected:
quint64 startTime; ///< The time the UAS was switched on quint64 startTime; ///< The time the UAS was switched on
CommStatus commStatus; ///< Communication status CommStatus commStatus; ///< Communication status
QString name; ///< Human-friendly name of the vehicle, e.g. bravo QString name; ///< Human-friendly name of the vehicle, e.g. bravo
int autopilot; ///< Type of the Autopilot: 0: Generic, 1: PIXHAWK, 2: SLUGS, 3: Ardupilot (up to 15 types), defined in MAV_AUTOPILOT_TYPE ENUM int autopilot; ///< Type of the Autopilot: -1: None, 0: Generic, 1: PIXHAWK, 2: SLUGS, 3: Ardupilot (up to 15 types), defined in MAV_AUTOPILOT_TYPE ENUM
QList<LinkInterface*>* links; ///< List of links this UAS can be reached by QList<LinkInterface*>* links; ///< List of links this UAS can be reached by
QList<int> unknownPackets; ///< Packet IDs which are unknown and have been received QList<int> unknownPackets; ///< Packet IDs which are unknown and have been received
MAVLinkProtocol* mavlink; ///< Reference to the MAVLink instance MAVLinkProtocol* mavlink; ///< Reference to the MAVLink instance
...@@ -165,7 +165,8 @@ protected: ...@@ -165,7 +165,8 @@ protected:
public: public:
UASWaypointManager &getWaypointManager(void) { return waypointManager; } UASWaypointManager &getWaypointManager(void) { return waypointManager; }
int getSystemType(); int getSystemType();
unsigned char getAutopilotType() {return autopilot;} int getAutopilotType() {return autopilot;}
void setAutopilotType(int apType) { autopilot = apType;}
public slots: public slots:
/** @brief Launches the system **/ /** @brief Launches the system **/
......
...@@ -157,7 +157,9 @@ public: ...@@ -157,7 +157,9 @@ public:
return color; return color;
} }
virtual unsigned char getAutopilotType() = 0; virtual int getAutopilotType() = 0;
virtual void setAutopilotType(int apType)= 0;
public slots: public slots:
/** @brief Launches the system/Liftof **/ /** @brief Launches the system/Liftof **/
......
...@@ -96,6 +96,11 @@ UASInterface* UASManager::getActiveUAS() ...@@ -96,6 +96,11 @@ UASInterface* UASManager::getActiveUAS()
return activeUAS; ///< Return zero pointer if no UAS has been loaded return activeUAS; ///< Return zero pointer if no UAS has been loaded
} }
UASInterface* UASManager::silentGetActiveUAS()
{
return activeUAS; ///< Return zero pointer if no UAS has been loaded
}
bool UASManager::launchActiveUAS() bool UASManager::launchActiveUAS()
{ {
// If the active UAS is set, execute command // If the active UAS is set, execute command
......
...@@ -57,6 +57,7 @@ public: ...@@ -57,6 +57,7 @@ public:
* @return NULL pointer if no UAS exists, active UAS else * @return NULL pointer if no UAS exists, active UAS else
**/ **/
UASInterface* getActiveUAS(); UASInterface* getActiveUAS();
UASInterface* silentGetActiveUAS();
/** /**
* @brief Get the UAS with this id * @brief Get the UAS with this id
* *
......
This diff is collapsed.
...@@ -146,11 +146,14 @@ public slots: ...@@ -146,11 +146,14 @@ public slots:
void loadPixhawkEngineerView(); void loadPixhawkEngineerView();
void loadSlugsEngineerView(); void loadSlugsEngineerView();
void presentView();
/** @brief Reload the CSS style sheet */ /** @brief Reload the CSS style sheet */
void reloadStylesheet(); void reloadStylesheet();
void showToolWidget(); void showToolWidget();
void showCentralWidget();
void updateVisibilitySettings (bool vis); void updateVisibilitySettings (bool vis);
void updateLocationSettings (Qt::DockWidgetArea location); void updateLocationSettings (Qt::DockWidgetArea location);
protected: protected:
...@@ -179,7 +182,7 @@ protected: ...@@ -179,7 +182,7 @@ protected:
MENU_SLUGS_PID, MENU_SLUGS_PID,
MENU_SLUGS_HIL, MENU_SLUGS_HIL,
MENU_SLUGS_CAMERA, MENU_SLUGS_CAMERA,
CENTRAL_LINECHART = 255, // Separation from dockwidgets and central widgets CENTRAL_LINECHART = 255, // do not change
CENTRAL_PROTOCOL, CENTRAL_PROTOCOL,
CENTRAL_MAP, CENTRAL_MAP,
CENTRAL_3D_LOCAL, CENTRAL_3D_LOCAL,
...@@ -187,18 +190,22 @@ protected: ...@@ -187,18 +190,22 @@ protected:
CENTRAL_GOOGLE_EARTH, CENTRAL_GOOGLE_EARTH,
CENTRAL_HUD, CENTRAL_HUD,
CENTRAL_DATA_PLOT, CENTRAL_DATA_PLOT,
CENTRAL_SEPARATOR,
}TOOLS_WIDGET_NAMES; }TOOLS_WIDGET_NAMES;
typedef enum _SETTINGS_SECTIONS { typedef enum _SETTINGS_SECTIONS {
SECTION_MENU, SECTION_MENU,
VIEW_ENGINEER,
VIEW_OPERATOR,
VIEW_CALIBRATION,
VIEW_MAVLINK,
SUB_SECTION_CHECKED, SUB_SECTION_CHECKED,
SUB_SECTION_LOCATION, SUB_SECTION_LOCATION,
} SETTINGS_SECTIONS; } SETTINGS_SECTIONS;
typedef enum _VIEW_SECTIONS {
VIEW_ENGINEER,
VIEW_OPERATOR,
VIEW_PILOT,
VIEW_MAVLINK,
} VIEW_SECTIONS;
QHash<int, QAction*> toolsMenuActions; // Holds ptr to the Menu Actions QHash<int, QAction*> toolsMenuActions; // Holds ptr to the Menu Actions
QHash<int, QWidget*> dockWidgets; // Holds ptr to the Actual Dock widget QHash<int, QWidget*> dockWidgets; // Holds ptr to the Actual Dock widget
...@@ -206,9 +213,11 @@ protected: ...@@ -206,9 +213,11 @@ protected:
void addToToolsMenu (QWidget* widget, const QString title, const char * slotName, TOOLS_WIDGET_NAMES tool, Qt::DockWidgetArea location); void addToToolsMenu (QWidget* widget, const QString title, const char * slotName, TOOLS_WIDGET_NAMES tool, Qt::DockWidgetArea location);
void showTheWidget (TOOLS_WIDGET_NAMES widget); void showTheWidget (TOOLS_WIDGET_NAMES widget, VIEW_SECTIONS view = VIEW_MAVLINK);
void showCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SECTIONS view);
void addToCentralWidgetsMenu ( QWidget* widget, const QString title,const char * slotName, TOOLS_WIDGET_NAMES centralWidget);
int currentView; VIEW_SECTIONS currentView;
int aboutToQuit; int aboutToQuit;
//QHash<int, QString> settingsSections; //QHash<int, QString> settingsSections;
...@@ -250,7 +259,9 @@ protected: ...@@ -250,7 +259,9 @@ protected:
// Center widgets // Center widgets
QPointer<Linecharts> linechartWidget; QPointer<Linecharts> linechartWidget;
QPointer<HUD> hudWidget; QPointer<HUD> hudWidget;
QPointer<MapWidget> mapWidget; QPointer<MapWidget> mapWidget;
QPointer<XMLCommProtocolWidget> protocolWidget; QPointer<XMLCommProtocolWidget> protocolWidget;
QPointer<QGCDataPlot2D> dataplotWidget; QPointer<QGCDataPlot2D> dataplotWidget;
...@@ -273,7 +284,9 @@ protected: ...@@ -273,7 +284,9 @@ protected:
QPointer<QDockWidget> headDown1DockWidget; QPointer<QDockWidget> headDown1DockWidget;
QPointer<QDockWidget> headDown2DockWidget; QPointer<QDockWidget> headDown2DockWidget;
QPointer<QDockWidget> watchdogControlDockWidget; QPointer<QDockWidget> watchdogControlDockWidget;
QPointer<QDockWidget> headUpDockWidget; QPointer<QDockWidget> headUpDockWidget;
QPointer<QDockWidget> hsiDockWidget; QPointer<QDockWidget> hsiDockWidget;
QPointer<QDockWidget> rcViewDockWidget; QPointer<QDockWidget> rcViewDockWidget;
QPointer<QDockWidget> slugsDataWidget; QPointer<QDockWidget> slugsDataWidget;
...@@ -304,7 +317,7 @@ protected: ...@@ -304,7 +317,7 @@ protected:
private: private:
Ui::MainWindow ui; Ui::MainWindow ui;
QString buildMenuKey (SETTINGS_SECTIONS section , TOOLS_WIDGET_NAMES tool); QString buildMenuKey (SETTINGS_SECTIONS section , TOOLS_WIDGET_NAMES tool, VIEW_SECTIONS view);
}; };
......
...@@ -80,7 +80,6 @@ ...@@ -80,7 +80,6 @@
<property name="title"> <property name="title">
<string>Tools</string> <string>Tools</string>
</property> </property>
<addaction name="separator"/>
</widget> </widget>
<widget class="QMenu" name="menuHelp"> <widget class="QMenu" name="menuHelp">
<property name="title"> <property name="title">
...@@ -94,9 +93,9 @@ ...@@ -94,9 +93,9 @@
<property name="title"> <property name="title">
<string>Perspectives</string> <string>Perspectives</string>
</property> </property>
<addaction name="actionFlightView"/> <addaction name="actionOperatorsView"/>
<addaction name="actionEngineersView"/> <addaction name="actionEngineersView"/>
<addaction name="actionCalibrationView"/> <addaction name="actionPilotsView"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionMavlinkView"/> <addaction name="actionMavlinkView"/>
<addaction name="actionReloadStyle"/> <addaction name="actionReloadStyle"/>
...@@ -393,13 +392,13 @@ ...@@ -393,13 +392,13 @@
<string>Developer Credits</string> <string>Developer Credits</string>
</property> </property>
</action> </action>
<action name="actionFlightView"> <action name="actionOperatorsView">
<property name="icon"> <property name="icon">
<iconset resource="../../mavground.qrc"> <iconset resource="../../mavground.qrc">
<normaloff>:/images/status/weather-overcast.svg</normaloff>:/images/status/weather-overcast.svg</iconset> <normaloff>:/images/status/weather-overcast.svg</normaloff>:/images/status/weather-overcast.svg</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Flight</string> <string>Operator</string>
</property> </property>
</action> </action>
<action name="actionEngineersView"> <action name="actionEngineersView">
...@@ -429,13 +428,13 @@ ...@@ -429,13 +428,13 @@
<string>Reload Style</string> <string>Reload Style</string>
</property> </property>
</action> </action>
<action name="actionCalibrationView"> <action name="actionPilotsView">
<property name="icon"> <property name="icon">
<iconset resource="../../mavground.qrc"> <iconset resource="../../mavground.qrc">
<normaloff>:/images/status/network-wireless-encrypted.svg</normaloff>:/images/status/network-wireless-encrypted.svg</iconset> <normaloff>:/images/status/network-wireless-encrypted.svg</normaloff>:/images/status/network-wireless-encrypted.svg</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Calibration</string> <string>Pilot</string>
</property> </property>
</action> </action>
</widget> </widget>
......
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