From 0bcea01b5c20fa26077572cdf08f0f5519ffd2db Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Thu, 26 May 2016 13:57:09 -0700 Subject: [PATCH] Use specific component id --- src/AutoPilotPlugins/APM/APMCompassCal.cc | 2 +- src/FactSystem/ParameterLoader.h | 2 ++ src/Vehicle/Vehicle.cc | 8 ++++++-- src/Vehicle/Vehicle.h | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/AutoPilotPlugins/APM/APMCompassCal.cc b/src/AutoPilotPlugins/APM/APMCompassCal.cc index b769142a7..a3bb441e5 100644 --- a/src/AutoPilotPlugins/APM/APMCompassCal.cc +++ b/src/AutoPilotPlugins/APM/APMCompassCal.cc @@ -157,7 +157,7 @@ CalWorkerThread::calibrate_return CalWorkerThread::calibrate(void) sensorId = 6.0f; } if (sensorId != 0.0f) { - _vehicle->doCommandLong(0, MAV_CMD_PREFLIGHT_SET_SENSOR_OFFSETS, sensorId, -sphere_x[cur_mag], -sphere_y[cur_mag], -sphere_z[cur_mag]); + _vehicle->doCommandLong(_vehicle->defaultComponentId(), MAV_CMD_PREFLIGHT_SET_SENSOR_OFFSETS, sensorId, -sphere_x[cur_mag], -sphere_y[cur_mag], -sphere_z[cur_mag]); } } } diff --git a/src/FactSystem/ParameterLoader.h b/src/FactSystem/ParameterLoader.h index 3b1e622c5..6dbd25e15 100644 --- a/src/FactSystem/ParameterLoader.h +++ b/src/FactSystem/ParameterLoader.h @@ -103,6 +103,8 @@ public: /// If this file is newer than anything in the cache, cache it as the latest version static void cacheMetaDataFile(const QString& metaDataFile, MAV_AUTOPILOT firmwareType); + + int defaultComponenentId(void) { return _defaultComponentId; } signals: /// Signalled when the full set of facts are ready diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 961fab555..a26750b32 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -210,7 +210,7 @@ Vehicle::Vehicle(LinkInterface* link, connect(_parameterLoader, &ParameterLoader::parameterListProgress, _autopilotPlugin, &AutoPilotPlugin::parameterListProgress); // Ask the vehicle for firmware version info - doCommandLong(MAV_COMP_ID_ALL, MAV_CMD_REQUEST_AUTOPILOT_CAPABILITIES, 1 /* request firmware version */); + doCommandLong(defaultComponentId(), MAV_CMD_REQUEST_AUTOPILOT_CAPABILITIES, 1 /* request firmware version */); _firmwarePlugin->initializeVehicle(this); @@ -1691,12 +1691,16 @@ QString Vehicle::firmwareVersionTypeString(void) const } } - void Vehicle::rebootVehicle() { doCommandLong(id(), MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); } +int Vehicle::defaultComponentId(void) +{ + return _parameterLoader->defaultComponenentId(); +} + const char* VehicleGPSFactGroup::_hdopFactName = "hdop"; const char* VehicleGPSFactGroup::_vdopFactName = "vdop"; const char* VehicleGPSFactGroup::_courseOverGroundFactName = "courseOverGround"; diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index 43c753498..05afe3df4 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -541,6 +541,8 @@ public: void setFirmwareVersion(int majorVersion, int minorVersion, int patchVersion, FIRMWARE_VERSION_TYPE versionType = FIRMWARE_VERSION_TYPE_OFFICIAL); static const int versionNotSetValue = -1; + int defaultComponentId(void); + public slots: void setLatitude(double latitude); void setLongitude(double longitude); -- 2.22.0