Commit 893f4194 authored by Gus Grubba's avatar Gus Grubba

Allow manual control of when to send FOLLOW_TARGET messages.

parent b9247f0e
...@@ -19,37 +19,48 @@ ...@@ -19,37 +19,48 @@
FollowMe::FollowMe(QGCApplication* app, QGCToolbox* toolbox) FollowMe::FollowMe(QGCApplication* app, QGCToolbox* toolbox)
: QGCTool(app, toolbox), estimatation_capabilities(0) : QGCTool(app, toolbox), estimatation_capabilities(0)
, _manualControl(false)
{ {
memset(&_motionReport, 0, sizeof(motionReport_s)); memset(&_motionReport, 0, sizeof(motionReport_s));
runTime.start(); runTime.start();
_gcsMotionReportTimer.setSingleShot(false); _gcsMotionReportTimer.setSingleShot(false);
connect(&_gcsMotionReportTimer, &QTimer::timeout, this, &FollowMe::_sendGCSMotionReport); connect(&_gcsMotionReportTimer, &QTimer::timeout, this, &FollowMe::_sendGCSMotionReport);
} }
void FollowMe::followMeHandleManager(const QString&) void FollowMe::followMeHandleManager(const QString&)
{ {
if(!_manualControl) {
QmlObjectListModel & vehicles = *_toolbox->multiVehicleManager()->vehicles(); QmlObjectListModel & vehicles = *_toolbox->multiVehicleManager()->vehicles();
for (int i=0; i< vehicles.count(); i++) { for (int i=0; i< vehicles.count(); i++) {
Vehicle* vehicle = qobject_cast<Vehicle*>(vehicles[i]); Vehicle* vehicle = qobject_cast<Vehicle*>(vehicles[i]);
if (vehicle->px4Firmware() && vehicle->flightMode().compare(FirmwarePlugin::px4FollowMeFlightMode, Qt::CaseInsensitive) == 0) { if (vehicle->px4Firmware() && vehicle->flightMode().compare(FirmwarePlugin::px4FollowMeFlightMode, Qt::CaseInsensitive) == 0) {
_enable(); _enable(_toolbox->qgcPositionManager()->updateInterval());
return; return;
} }
} }
_disable();
}
}
void FollowMe::manualEnable(int interval)
{
_manualControl = true;
_enable(interval);
}
void FollowMe::manualDisable()
{
_manualControl = false;
_disable(); _disable();
} }
void FollowMe::_enable() void FollowMe::_enable(int interval)
{ {
connect(_toolbox->qgcPositionManager(), connect(_toolbox->qgcPositionManager(),
SIGNAL(positionInfoUpdated(QGeoPositionInfo)), SIGNAL(positionInfoUpdated(QGeoPositionInfo)),
this, this,
SLOT(_setGPSLocation(QGeoPositionInfo))); SLOT(_setGPSLocation(QGeoPositionInfo)));
_gcsMotionReportTimer.setInterval(interval);
_gcsMotionReportTimer.setInterval(_toolbox->qgcPositionManager()->updateInterval());
_gcsMotionReportTimer.start(); _gcsMotionReportTimer.start();
} }
...@@ -59,7 +70,6 @@ void FollowMe::_disable() ...@@ -59,7 +70,6 @@ void FollowMe::_disable()
SIGNAL(positionInfoUpdated(QGeoPositionInfo)), SIGNAL(positionInfoUpdated(QGeoPositionInfo)),
this, this,
SLOT(_setGPSLocation(QGeoPositionInfo))); SLOT(_setGPSLocation(QGeoPositionInfo)));
_gcsMotionReportTimer.stop(); _gcsMotionReportTimer.stop();
} }
...@@ -133,7 +143,7 @@ void FollowMe::_sendGCSMotionReport(void) ...@@ -133,7 +143,7 @@ void FollowMe::_sendGCSMotionReport(void)
for (int i=0; i< vehicles.count(); i++) { for (int i=0; i< vehicles.count(); i++) {
Vehicle* vehicle = qobject_cast<Vehicle*>(vehicles[i]); Vehicle* vehicle = qobject_cast<Vehicle*>(vehicles[i]);
if(vehicle->flightMode().compare(FirmwarePlugin::px4FollowMeFlightMode, Qt::CaseInsensitive) == 0) { if(_manualControl || vehicle->flightMode().compare(FirmwarePlugin::px4FollowMeFlightMode, Qt::CaseInsensitive) == 0) {
mavlink_message_t message; mavlink_message_t message;
mavlink_msg_follow_target_encode_chan(mavlinkProtocol->getSystemId(), mavlink_msg_follow_target_encode_chan(mavlinkProtocol->getSystemId(),
mavlinkProtocol->getComponentId(), mavlinkProtocol->getComponentId(),
......
...@@ -29,6 +29,9 @@ class FollowMe : public QGCTool ...@@ -29,6 +29,9 @@ class FollowMe : public QGCTool
public: public:
FollowMe(QGCApplication* app, QGCToolbox* toolbox); FollowMe(QGCApplication* app, QGCToolbox* toolbox);
void manualEnable (int interval);
void manualDisable ();
public slots: public slots:
void followMeHandleManager(const QString&); void followMeHandleManager(const QString&);
...@@ -65,8 +68,10 @@ private: ...@@ -65,8 +68,10 @@ private:
uint8_t estimatation_capabilities; uint8_t estimatation_capabilities;
void _disable(); void _disable ();
void _enable(); void _enable (int interval);
double _degreesToRadian(double deg); double _degreesToRadian(double deg);
bool _manualControl;
}; };
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