Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FollowMe: Re-enable for Ardupilot #11846

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#include "ESP8266Component.h"
#include "APMHeliComponent.h"
#include "APMRemoteSupportComponent.h"
#ifdef QT_DEBUG
#include "APMFollowComponent.h"
#include "ArduCopterFirmwarePlugin.h"
#include "ArduRoverFirmwarePlugin.h"
#endif
#include "QGCApplication.h"
#include "ParameterManager.h"

Expand All @@ -50,10 +55,6 @@ APMAutoPilotPlugin::APMAutoPilotPlugin(Vehicle* vehicle, QObject* parent)
, _esp8266Component (nullptr)
, _heliComponent (nullptr)
, _apmRemoteSupportComponent(nullptr)
#if 0
// Follow me not ready for Stable
, _followComponent (nullptr)
#endif
{
#if !defined(NO_SERIAL_LINK) && !defined(Q_OS_ANDROID)
connect(vehicle->parameterManager(), &ParameterManager::parametersReadyChanged, this, &APMAutoPilotPlugin::_checkForBadCubeBlack);
Expand Down Expand Up @@ -104,14 +105,12 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void)
_safetyComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_safetyComponent));

#if 0
// Follow me not ready for Stable

#ifdef QT_DEBUG
if ((qobject_cast<ArduCopterFirmwarePlugin*>(_vehicle->firmwarePlugin()) || qobject_cast<ArduRoverFirmwarePlugin*>(_vehicle->firmwarePlugin())) &&
_vehicle->parameterManager()->parameterExists(-1, QStringLiteral("FOLL_ENABLE"))) {
_followComponent = new APMFollowComponent(_vehicle, this);
_followComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_followComponent));
(void) _components.append(QVariant::fromValue(qobject_cast<VehicleComponent*>(_followComponent)));
}
#endif

Expand Down
5 changes: 1 addition & 4 deletions src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ class APMAutoPilotPlugin : public AutoPilotPlugin
ESP8266Component* _esp8266Component;
APMHeliComponent* _heliComponent;
APMRemoteSupportComponent* _apmRemoteSupportComponent;
#if 0
// Follow me not ready for Stable
APMFollowComponent* _followComponent;
#endif
APMFollowComponent *_followComponent = nullptr;

#if !defined(NO_SERIAL_LINK) && !defined(Q_OS_ANDROID)
private slots:
Expand Down
42 changes: 21 additions & 21 deletions src/AutoPilotPlugins/APM/APMFollowComponent.FactMetaData.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
{
"version": 1,
"fileType": "FactMetaData",
"version": 1,
"fileType": "FactMetaData",
"QGC.MetaData.Facts":
[
{
"name": "angle",
"name": "angle",
"shortDesc": "Angle from ground station to vehicle",
"type": "double",
"min": 0,
"max": 360,
"decimalPlaces": 1,
"units": "deg",
"default": 45
"type": "double",
"min": 0,
"max": 360,
"decimalPlaces": 1,
"units": "deg",
"default": 45
},
{
"name": "distance",
"name": "distance",
"shortDesc": "Horizontal distance from ground station to vehicle",
"type": "double",
"min": 0,
"decimalPlaces": 1,
"units": "m",
"default": 5
"type": "double",
"min": 0,
"decimalPlaces": 1,
"units": "m",
"default": 5
},
{
"name": "height",
"name": "height",
"shortDesc": "Vertical distance from Launch (home) position to vehicle",
"type": "double",
"min": 0,
"decimalPlaces": 1,
"units": "m",
"default": 5
"type": "double",
"min": 0,
"decimalPlaces": 1,
"units": "m",
"default": 5
}
]
}
29 changes: 5 additions & 24 deletions src/AutoPilotPlugins/APM/APMFollowComponent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,14 @@
#include "APMFollowComponent.h"
#include "APMAutoPilotPlugin.h"

APMFollowComponent::APMFollowComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
APMFollowComponent::APMFollowComponent(Vehicle *vehicle, AutoPilotPlugin *autopilot, QObject *parent)
: VehicleComponent(vehicle, autopilot, parent),
_name(tr("Follow Me"))
_name(QStringLiteral("Follow Me"))
{
// qCDebug() << Q_FUNC_INFO << this;
}

QString APMFollowComponent::name(void) const
APMFollowComponent::~APMFollowComponent()
{
return _name;
}

QString APMFollowComponent::description(void) const
{
return tr("Follow Me Setup is used to configure support for the vehicle following the ground station location.");
}

QString APMFollowComponent::iconResource(void) const
{
return QStringLiteral("/qmlimages/FollowComponentIcon.png");
}

QUrl APMFollowComponent::setupSource(void) const
{
return QUrl::fromUserInput(QStringLiteral("qrc:/qml/APMFollowComponent.qml"));
}

QUrl APMFollowComponent::summaryQmlSource(void) const
{
return QUrl::fromUserInput(QStringLiteral("qrc:/qml/APMFollowComponentSummary.qml"));
// qCDebug() << Q_FUNC_INFO << this;
}
34 changes: 16 additions & 18 deletions src/AutoPilotPlugins/APM/APMFollowComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,23 @@
class APMFollowComponent : public VehicleComponent
{
Q_OBJECT

public:
APMFollowComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = nullptr);

// Overrides from VehicleComponent
QStringList setupCompleteChangedTriggerList(void) const override { return QStringList(); }

// Virtuals from VehicleComponent
QString name (void) const override;
QString description (void) const override;
QString iconResource (void) const override;
bool requiresSetup (void) const override { return false; }
bool setupComplete (void) const override { return true; }
QUrl setupSource (void) const override;
QUrl summaryQmlSource (void) const override;
bool allowSetupWhileArmed (void) const override { return true; }
bool allowSetupWhileFlying (void) const override { return true; }
APMFollowComponent(Vehicle *vehicle, AutoPilotPlugin *autopilot, QObject *parent = nullptr);
~APMFollowComponent();

QString name() const final { return _name; }
QString description() const final { return QStringLiteral("Follow Me Setup is used to configure support for the vehicle following the ground station location."); }
QString iconResource() const final { return QStringLiteral("/qmlimages/FollowComponentIcon.png"); }
bool requiresSetup() const final { return false; }
bool setupComplete() const final { return true; }
QUrl setupSource() const final { return QUrl::fromUserInput(QStringLiteral("qrc:/qml/APMFollowComponent.qml")); }
QUrl summaryQmlSource() const final { return QUrl::fromUserInput(QStringLiteral("qrc:/qml/APMFollowComponentSummary.qml")); }
bool allowSetupWhileArmed() const final { return true; }
bool allowSetupWhileFlying() const final { return true; }

QStringList setupCompleteChangedTriggerList() const final { return QStringList(); }

private:
const QString _name;
QVariantList _summaryItems;
const QString _name;
};
16 changes: 11 additions & 5 deletions src/AutoPilotPlugins/APM/APMFollowComponentController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@
#include "ArduRoverFirmwarePlugin.h"
#include "Vehicle.h"

APMFollowComponentController::APMFollowComponentController(void)
: _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/APMFollowComponent.FactMetaData.json"), this))
, _angleFact (settingsGroup, _metaDataMap[angleName])
, _distanceFact (settingsGroup, _metaDataMap[distanceName])
, _heightFact (settingsGroup, _metaDataMap[heightName])
APMFollowComponentController::APMFollowComponentController(QObject *parent)
: FactPanelController(parent)
, _metaDataMap(FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/APMFollowComponent.FactMetaData.json"), this))
, _angleFact(new SettingsFact(_settingsGroup, _metaDataMap[_angleName], this))
, _distanceFact(new SettingsFact(_settingsGroup, _metaDataMap[_distanceName], this))
, _heightFact(new SettingsFact(_settingsGroup, _metaDataMap[_heightName], this))
{
// qCDebug() << Q_FUNC_INFO << this;
}

APMFollowComponentController::~APMFollowComponentController()
{
// qCDebug() << Q_FUNC_INFO << this;
}

bool APMFollowComponentController::roverFirmware()
Expand Down
37 changes: 19 additions & 18 deletions src/AutoPilotPlugins/APM/APMFollowComponentController.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,30 @@
class APMFollowComponentController : public FactPanelController
{
Q_OBJECT

public:
APMFollowComponentController(void);

Q_PROPERTY(Fact* angle READ angleFact CONSTANT)
Q_PROPERTY(Fact* distance READ distanceFact CONSTANT)
Q_PROPERTY(Fact* height READ heightFact CONSTANT)
Q_PROPERTY(bool roverFirmware READ roverFirmware CONSTANT)
Q_PROPERTY(Fact *angle READ angleFact CONSTANT)
Q_PROPERTY(Fact *distance READ distanceFact CONSTANT)
Q_PROPERTY(Fact *height READ heightFact CONSTANT)
Q_PROPERTY(bool roverFirmware READ roverFirmware CONSTANT)

Fact* angleFact (void) { return &_angleFact; }
Fact* distanceFact (void) { return &_distanceFact; }
Fact* heightFact (void) { return &_heightFact; }
bool roverFirmware (void);
public:
APMFollowComponentController(QObject *parent = nullptr);
~APMFollowComponentController();

static constexpr const char* settingsGroup = "APMFollow";
static constexpr const char* angleName = "angle";
static constexpr const char* distanceName = "distance";
static constexpr const char* heightName = "height";
Fact *angleFact() { return _angleFact; }
Fact *distanceFact() { return _distanceFact; }
Fact *heightFact() { return _heightFact; }
bool roverFirmware();

private:
QMap<QString, FactMetaData*> _metaDataMap;

SettingsFact _angleFact;
SettingsFact _distanceFact;
SettingsFact _heightFact;
SettingsFact *_angleFact = nullptr;
SettingsFact *_distanceFact = nullptr;
SettingsFact *_heightFact = nullptr;

static constexpr const char *_settingsGroup = "APMFollow";
static constexpr const char *_angleName = "angle";
static constexpr const char *_distanceName = "distance";
static constexpr const char *_heightName = "height";
};
75 changes: 53 additions & 22 deletions src/AutoPilotPlugins/APM/APMFollowComponentSummary.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,77 @@ import QtQuick.Controls
import QGroundControl.FactSystem
import QGroundControl.FactControls
import QGroundControl.Controls
import QGroundControl.Palette

Item {
anchors.fill: parent
anchors.fill: parent

FactPanelController { id: controller; }

property Fact _batt1Monitor: controller.getParameterFact(-1, "BATT_MONITOR")
property Fact _batt2Monitor: controller.getParameterFact(-1, "BATT2_MONITOR", false /* reportMissing */)
property bool _batt2MonitorAvailable: controller.parameterExists(-1, "BATT2_MONITOR")
property bool _batt1MonitorEnabled: _batt1Monitor.rawValue !== 0
property bool _batt2MonitorEnabled: _batt2MonitorAvailable && _batt2Monitor.rawValue !== 0
property Fact _battCapacity: controller.getParameterFact(-1, "BATT_CAPACITY", false /* reportMissing */)
property Fact _batt2Capacity: controller.getParameterFact(-1, "BATT2_CAPACITY", false /* reportMissing */)
property bool _battCapacityAvailable: controller.parameterExists(-1, "BATT_CAPACITY")
property Fact _followEnabled: controller.getParameterFact(-1, "FOLL_ENABLE")
property bool _followParamsAvailable: controller.parameterExists(-1, "FOLL_SYSID")
property Fact _followDistanceMax: controller.getParameterFact(-1, "FOLL_DIST_MAX", false /* reportMissing */)
property Fact _followSysId: controller.getParameterFact(-1, "FOLL_SYSID", false /* reportMissing */)
property Fact _followOffsetX: controller.getParameterFact(-1, "FOLL_OFS_X", false /* reportMissing */)
property Fact _followOffsetY: controller.getParameterFact(-1, "FOLL_OFS_Y", false /* reportMissing */)
property Fact _followOffsetZ: controller.getParameterFact(-1, "FOLL_OFS_Z", false /* reportMissing */)
property Fact _followOffsetType: controller.getParameterFact(-1, "FOLL_OFS_TYPE", false /* reportMissing */)
property Fact _followAltitudeType: controller.getParameterFact(-1, "FOLL_ALT_TYPE", false /* reportMissing */)
property Fact _followYawBehavior: controller.getParameterFact(-1, "FOLL_YAW_BEHAVE", false /* reportMissing */)

Column {
anchors.fill: parent
anchors.fill: parent

VehicleSummaryRow {
labelText: qsTr("Batt1 monitor")
valueText: _batt1Monitor.enumStringValue
labelText: qsTr("Follow Enabled")
valueText: _followEnabled.enumStringValue
}

VehicleSummaryRow {
labelText: qsTr("Batt1 capacity")
valueText: _batt1MonitorEnabled ? _battCapacity.valueString + " " + _battCapacity.units : ""
visible: _batt1MonitorEnabled
labelText: qsTr("Follow System ID")
valueText: _followSysId.valueString
visible: _followParamsAvailable
}

VehicleSummaryRow {
labelText: qsTr("Batt2 monitor")
valueText: _batt2MonitorAvailable ? _batt2Monitor.enumStringValue : ""
visible: _batt2MonitorAvailable
labelText: qsTr("Follow Max Distance")
valueText: _followDistanceMax.valueString + " " + _followDistanceMax.units
visible: _followParamsAvailable
}

VehicleSummaryRow {
labelText: qsTr("Batt2 capacity")
valueText: _batt2MonitorEnabled ? _batt2Capacity.valueString + " " + _batt2Capacity.units : ""
visible: _batt2MonitorEnabled
labelText: qsTr("Follow Offset X")
valueText: _followOffsetX.valueString + " " + _followOffsetX.units
visible: _followParamsAvailable
}

VehicleSummaryRow {
labelText: qsTr("Follow Offset Y")
valueText: _followOffsetY.valueString + " " + _followOffsetY.units
visible: _followParamsAvailable
}

VehicleSummaryRow {
labelText: qsTr("Follow Offset Z")
valueText: _followOffsetZ.valueString + " " + _followOffsetZ.units
visible: _followParamsAvailable
}

VehicleSummaryRow {
labelText: qsTr("Follow Offset Type")
valueText: _followOffsetType.enumStringValue
visible: _followParamsAvailable
}

VehicleSummaryRow {
labelText: qsTr("Follow Altitude Type")
valueText: _followAltitudeType.enumStringValue
visible: _followParamsAvailable
}

VehicleSummaryRow {
labelText: qsTr("Follow Yaw Behavior")
valueText: _followYawBehavior.enumStringValue
visible: _followParamsAvailable
}
}
}
2 changes: 1 addition & 1 deletion src/Comms/MAVLinkProtocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ void MAVLinkProtocol::setSystemId(int id)
}

/** @return Component id of this application */
int MAVLinkProtocol::getComponentId()
int MAVLinkProtocol::getComponentId() const
{
return MAV_COMP_ID_MISSIONPLANNER;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Comms/MAVLinkProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MAVLinkProtocol : public QGCTool
/** @brief Get the system id of this application */
int getSystemId() const;
/** @brief Get the component id of this application */
int getComponentId();
int getComponentId() const;

/** @brief Get protocol version check state */
bool versionCheckEnabled() const {
Expand Down
3 changes: 2 additions & 1 deletion src/FactSystem/FactControls/FactPanelController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

QGC_LOGGING_CATEGORY(FactPanelControllerLog, "FactPanelControllerLog")

FactPanelController::FactPanelController()
FactPanelController::FactPanelController(QObject *parent)
: QObject(parent)
{
_vehicle = qgcApp()->toolbox()->multiVehicleManager()->activeVehicle();
if (_vehicle) {
Expand Down
Loading
Loading