QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
PX4RadioComponent.cc
Go to the documentation of this file.
1#include "PX4RadioComponent.h"
2
3#include "Fact.h"
4#include "ParameterManager.h"
5#include "Vehicle.h"
6
7PX4RadioComponent::PX4RadioComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
8 : VehicleComponent(vehicle, autopilot, AutoPilotPlugin::KnownRadioVehicleComponent, parent)
9 , _name(tr("Radio"))
10{
11}
12
13QString PX4RadioComponent::name(void) const
14{
15 return _name;
16}
17
19{
20 return tr("Configure and calibrate your transmitter and assign control channels.");
21}
22
24{
25 return "/qmlimages/RadioComponentIcon.png";
26}
27
29{
30 return _vehicle->parameterManager()->getParameter(-1, "COM_RC_IN_MODE")->rawValue().toInt() == 1 ? false : true;
31}
32
34{
35 if (_vehicle->parameterManager()->getParameter(-1, "COM_RC_IN_MODE")->rawValue().toInt() != 1) {
36 // The best we can do to detect the need for a radio calibration is look for attitude
37 // controls to be mapped.
38 for(const char* const&mapParam : {"RC_MAP_ROLL", "RC_MAP_PITCH", "RC_MAP_YAW", "RC_MAP_THROTTLE"}) {
39 if (_vehicle->parameterManager()->getParameter(ParameterManager::defaultComponentId, mapParam)->rawValue().toInt() == 0) {
40 return false;
41 }
42 }
43 }
44
45 return true;
46}
47
49{
50 return {"COM_RC_IN_MODE", "RC_MAP_ROLL", "RC_MAP_PITCH", "RC_MAP_YAW", "RC_MAP_THROTTLE"};
51}
52
54{
55 return QUrl::fromUserInput("qrc:/qml/QGroundControl/AutoPilotPlugins/Common/RadioComponent.qml");
56}
57
59{
60 return {"RC_MAP_FLAPS", "RC_MAP_AUX1", "RC_MAP_AUX2"};
61}
62
70
71QList<VehicleSummaryItem> PX4RadioComponent::summaryItems() const
72{
73 // Attitude controls must be mapped, unless the vehicle flies without a transmitter
74 const VehicleSummaryItem::State attitudeState =
75 setupComplete() ? VehicleSummaryItem::Muted : VehicleSummaryItem::Attention;
76
77 QList<VehicleSummaryItem> items;
78 const auto addChannel = [this, &items](const char* param, const QString& caption, const QString& unmappedText,
79 VehicleSummaryItem::State unmappedState) {
80 const Fact* const fact = _parameterFact(QString::fromLatin1(param));
81 if (!fact) {
82 return;
83 }
84 if (fact->rawValue().toInt() != 0) {
85 items.append({caption, fact->cookedValueString(), VehicleSummaryItem::Normal});
86 } else {
87 items.append({caption, unmappedText, unmappedState});
88 }
89 };
90
91 addChannel("RC_MAP_ROLL", tr("Roll"), tr("Setup required"), attitudeState);
92 addChannel("RC_MAP_PITCH", tr("Pitch"), tr("Setup required"), attitudeState);
93 addChannel("RC_MAP_YAW", tr("Yaw"), tr("Setup required"), attitudeState);
94 addChannel("RC_MAP_THROTTLE", tr("Throttle"), tr("Setup required"), attitudeState);
95 if (!_vehicle->multiRotor()) {
96 addChannel("RC_MAP_FLAPS", tr("Flaps"), tr("Disabled"), VehicleSummaryItem::Muted);
97 }
98 addChannel("RC_MAP_AUX1", tr("Aux1"), tr("Disabled"), VehicleSummaryItem::Muted);
99 addChannel("RC_MAP_AUX2", tr("Aux2"), tr("Disabled"), VehicleSummaryItem::Muted);
100
101 return items;
102}
The AutoPilotPlugin class is an abstract base class which represents the methods and objects which ar...
A Fact is used to hold a single value within the system.
Definition Fact.h:15
QString cookedValueString() const
Definition Fact.cc:489
QVariant rawValue() const
Definition Fact.h:87
void valueChanged(const QVariant &value)
This signal is only meant for use by the QT property system. It should not be connected to by client ...
virtual QStringList summaryChangedTriggerList() const
Parameters whose change emits summaryItemsChanged, besides those that change setupComplete.
virtual QUrl setupSource(void) const
virtual bool requiresSetup(void) const
virtual QString iconResource(void) const
virtual void setupTriggerSignals()
PX4RadioComponent(Vehicle *vehicle, AutoPilotPlugin *autopilot, QObject *parent=nullptr)
virtual QString name(void) const
virtual bool setupComplete(void) const
virtual QString description(void) const
virtual QStringList setupCompleteChangedTriggerList(void) const
virtual QList< VehicleSummaryItem > summaryItems() const
Values for this component's card on the Summary page. A component with none falls back to summaryQmlS...
static constexpr int defaultComponentId
VehicleComponent(Vehicle *vehicle, AutoPilotPlugin *autopilot, AutoPilotPlugin::KnownVehicleComponent KnownVehicleComponent, QObject *parent=nullptr)
Fact * _parameterFact(const QString &name) const
Fact of a parameter of the default component, nullptr when the vehicle does not have it.
void requiresSetupChanged()
virtual void setupTriggerSignals()
VehicleSummaryState::State State