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