diff --git a/src/uas/ArduPilotMegaMAV.cc b/src/uas/ArduPilotMegaMAV.cc index 767c084ce1c32626f0acf35c92c53ff41d7dd989..61dfced8b1a653349db4646f91eebcea8ee3307c 100644 --- a/src/uas/ArduPilotMegaMAV.cc +++ b/src/uas/ArduPilotMegaMAV.cc @@ -27,7 +27,6 @@ This file is part of the QGROUNDCONTROL project */ #include "ArduPilotMegaMAV.h" - ArduPilotMegaMAV::ArduPilotMegaMAV(MAVLinkProtocol* mavlink, int id) : UAS(mavlink, id)//, // place other initializers here @@ -63,3 +62,23 @@ void ArduPilotMegaMAV::receiveMessage(LinkInterface* link, mavlink_message_t mes } } } +void ArduPilotMegaMAV::setMountConfigure(unsigned char mode, bool stabilize_roll,bool stabilize_pitch,bool stabilize_yaw) +{ + //Only supported by APM + mavlink_message_t msg; + mavlink_msg_mount_configure_pack(255,1,&msg,this->uasId,1,mode,stabilize_roll,stabilize_pitch,stabilize_yaw); + sendMessage(msg); +} +void ArduPilotMegaMAV::setMountControl(double pa,double pb,double pc,bool islatlong) +{ + mavlink_message_t msg; + if (islatlong) + { + mavlink_msg_mount_control_pack(255,1,&msg,this->uasId,1,pa*10000000.0,pb*10000000.0,pc*10000000.0,0); + } + else + { + mavlink_msg_mount_control_pack(255,1,&msg,this->uasId,1,pa,pb,pc,0); + } + sendMessage(msg); +} diff --git a/src/uas/ArduPilotMegaMAV.h b/src/uas/ArduPilotMegaMAV.h index 00866830defc5fd9f9d559670f609ebb95151e0e..9137c4931725de87396346575963840b71dd258c 100644 --- a/src/uas/ArduPilotMegaMAV.h +++ b/src/uas/ArduPilotMegaMAV.h @@ -25,12 +25,18 @@ This file is part of the QGROUNDCONTROL project #define ARDUPILOTMEGAMAV_H #include "UAS.h" - +#include "ardupilotmega/mavlink_msg_mount_configure.h" +#include "ardupilotmega/mavlink_msg_mount_control.h" +#include "ardupilotmega/mavlink_msg_mount_status.h" class ArduPilotMegaMAV : public UAS { Q_OBJECT public: ArduPilotMegaMAV(MAVLinkProtocol* mavlink, int id = 0); + /** @brief Set camera mount stabilization modes */ + void setMountConfigure(unsigned char mode, bool stabilize_roll,bool stabilize_pitch,bool stabilize_yaw); + /** @brief Set camera mount control */ + void setMountControl(double pa,double pb,double pc,bool islatlong); public slots: /** @brief Receive a MAVLink message from this MAV */ void receiveMessage(LinkInterface* link, mavlink_message_t message); diff --git a/src/ui/map/QGCMapWidget.cc b/src/ui/map/QGCMapWidget.cc index fe224aa3a092607773ab9b0fb4bc3efcd8943f8b..bafbab988688a3ee719803fe90d6ec49c08a1d7a 100644 --- a/src/ui/map/QGCMapWidget.cc +++ b/src/ui/map/QGCMapWidget.cc @@ -5,6 +5,7 @@ #include "MAV2DIcon.h" #include "Waypoint2DIcon.h" #include "UASWaypointManager.h" +#include "ArduPilotMegaMAV.h" QGCMapWidget::QGCMapWidget(QWidget *parent) : mapcontrol::OPMapWidget(parent), @@ -59,6 +60,16 @@ bool QGCMapWidget::guidedAltActionTriggered() guidedActionTriggered(); return true; } +void QGCMapWidget::cameraActionTriggered() +{ + ArduPilotMegaMAV *newmav = qobject_cast(this->uas); + if (newmav) + { + newmav->setMountConfigure(4,true,true,true); + internals::PointLatLng pos = map->FromLocalToLatLng(mousePressPos.x(), mousePressPos.y()); + newmav->setMountControl(pos.Lat(),pos.Lng(),100,true); + } +} void QGCMapWidget::mousePressEvent(QMouseEvent *event) { @@ -237,6 +248,7 @@ void QGCMapWidget::activeUASSet(UASInterface* uas) { // Only execute if proper UAS is set if (!uas) return; + this->uas = uas; // Disconnect old MAV manager if (currWPManager) @@ -251,6 +263,12 @@ void QGCMapWidget::activeUASSet(UASInterface* uas) if (uas) { currWPManager = uas->getWaypointManager(); + QList actionList = this->actions(); + for (int i=0;iremoveAction(actionList[i]); + actionList[i]->deleteLater(); + } if (currWPManager->guidedModeSupported()) { QAction *guidedaction = new QAction(this); @@ -261,6 +279,14 @@ void QGCMapWidget::activeUASSet(UASInterface* uas) guidedaction->setText("Go To Here Alt (Guided Mode)"); connect(guidedaction,SIGNAL(triggered()),this,SLOT(guidedAltActionTriggered())); this->addAction(guidedaction); + + if (uas->getAutopilotType() == MAV_AUTOPILOT_ARDUPILOTMEGA) + { + QAction *cameraaction = new QAction(this); + cameraaction->setText("Point Camera Here"); + connect(cameraaction,SIGNAL(triggered()),this,SLOT(cameraActionTriggered())); + this->addAction(cameraaction); + } } // Connect the waypoint manager / data storage to the UI diff --git a/src/ui/map/QGCMapWidget.h b/src/ui/map/QGCMapWidget.h index e6dc6e632224052ed25248978a037ef81ba42966..997976c2febe6ca821e4e2f27d7e49f388dd8496 100644 --- a/src/ui/map/QGCMapWidget.h +++ b/src/ui/map/QGCMapWidget.h @@ -40,6 +40,8 @@ signals: void waypointChanged(Waypoint* wp); public slots: + /** @brief Action triggered with point-camera action is selected from the context menu */ + void cameraActionTriggered(); /** @brief Action triggered when guided action is selected from the context menu */ void guidedActionTriggered(); /** @brief Action triggered when guided action is selected from the context menu, allows for altitude selection */ @@ -158,6 +160,7 @@ protected: float homeAltitude; ///< Home altitude QPoint mousePressPos; ///< Mouse position when the button is released. int defaultGuidedAlt; ///< Default altitude for guided mode + UASInterface *uas; ///< Currently selected UAS. };