diff --git a/src/AutoPilotPlugins/AutoPilotPlugin.cc b/src/AutoPilotPlugins/AutoPilotPlugin.cc index 6107fd4551bded99871d1979c2ce16527213e38c..0feb2f33fb877410dfde150a5e4c36727dbd3ee2 100644 --- a/src/AutoPilotPlugins/AutoPilotPlugin.cc +++ b/src/AutoPilotPlugins/AutoPilotPlugin.cc @@ -13,8 +13,6 @@ #include "AutoPilotPlugin.h" #include "QGCApplication.h" -#include "ParameterManager.h" -#include "UAS.h" #include "FirmwarePlugin.h" AutoPilotPlugin::AutoPilotPlugin(Vehicle* vehicle, QObject* parent) @@ -28,7 +26,7 @@ AutoPilotPlugin::AutoPilotPlugin(Vehicle* vehicle, QObject* parent) AutoPilotPlugin::~AutoPilotPlugin() { - + } void AutoPilotPlugin::_recalcSetupComplete(void) diff --git a/src/AutoPilotPlugins/AutoPilotPlugin.h b/src/AutoPilotPlugins/AutoPilotPlugin.h index 66728f885bfd6b0e0030ef9277828149bf8c11d1..39fd1f78686c330d9a5c260fdc3a8bc881ce52b8 100644 --- a/src/AutoPilotPlugins/AutoPilotPlugin.h +++ b/src/AutoPilotPlugins/AutoPilotPlugin.h @@ -19,7 +19,6 @@ #include "FactSystem.h" #include "Vehicle.h" -class ParameterManager; class Vehicle; class FirmwarePlugin; diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 5f3f37468521d4b430dbc867f7d88d4d3abdaf9a..ac98acd514e90635bb4dc8a301f79b10b71e6243 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -2255,12 +2255,34 @@ void Vehicle::_rallyPointLoadComplete(void) void Vehicle::_parametersReady(bool parametersReady) { + // Try to set current unix time to the vehicle + _sendQGCTimeToVehicle(); + // Send time twice, more likely to get to the vehicle on a noisy link + _sendQGCTimeToVehicle(); if (parametersReady) { _setupAutoDisarmSignalling(); _startPlanRequest(); } } +void Vehicle::_sendQGCTimeToVehicle(void) +{ + mavlink_message_t msg; + mavlink_system_time_t cmd; + + // Timestamp of the master clock in microseconds since UNIX epoch. + cmd.time_unix_usec = QDateTime::currentDateTime().currentMSecsSinceEpoch()*1000; + // Timestamp of the component clock since boot time in milliseconds (Not necessary). + cmd.time_boot_ms = 0; + mavlink_msg_system_time_encode_chan(_mavlink->getSystemId(), + _mavlink->getComponentId(), + priorityLink()->mavlinkChannel(), + &msg, + &cmd); + + sendMessageOnLink(priorityLink(), msg); +} + void Vehicle::disconnectInactiveVehicle(void) { // Vehicle is no longer communicating with us, disconnect all links diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index 4070ac17b5fb05e77da9f898b3a87a558b7d5cf4..0109af25cd0278bfb79a56b6d70c5167d77dc2d7 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -11,7 +11,6 @@ #include #include -#include #include "FactGroup.h" #include "LinkInterface.h" @@ -994,6 +993,7 @@ private slots: void _updateDistanceToHome(void); void _updateHobbsMeter(void); void _vehicleParamLoaded(bool ready); + void _sendQGCTimeToVehicle(void); private: bool _containsLink(LinkInterface* link);