Browse Source

actuators: disable motor assignment button if geometry does not have motors

QGC4.4
Beat Küng 3 years ago
parent
commit
25fc5ffc01
  1. 3
      src/AutoPilotPlugins/PX4/ActuatorComponent.qml
  2. 11
      src/Vehicle/Actuators/Actuators.cc
  3. 4
      src/Vehicle/Actuators/Actuators.h
  4. 11
      src/Vehicle/Actuators/GeometryImage.cc
  5. 2
      src/Vehicle/Actuators/GeometryImage.h

3
src/AutoPilotPlugins/PX4/ActuatorComponent.qml

@ -286,7 +286,7 @@ SetupPage { @@ -286,7 +286,7 @@ SetupPage {
model: actionGroup.actions
QGCMenuItem {
text: object.label
onTriggered: object.trigger()
onTriggered: object.trigger()
}
onObjectAdded: actionMenu.insertItem(index, object)
onObjectRemoved: actionMenu.removeItem(object)
@ -354,6 +354,7 @@ SetupPage { @@ -354,6 +354,7 @@ SetupPage {
QGCButton {
text: qsTr("Identify & Assign Motors")
visible: !actuators.motorAssignmentActive && selActuatorOutput.actuatorOutput.groupsVisible
enabled: actuators.motorAssignmentEnabled
onClicked: {
var success = actuators.initMotorAssignment()
if (success) {

11
src/Vehicle/Actuators/Actuators.cc

@ -103,6 +103,9 @@ void Actuators::updateGeometryImage() @@ -103,6 +103,9 @@ void Actuators::updateGeometryImage()
_imageRefreshFlag = !_imageRefreshFlag;
emit imageRefreshFlagChanged();
_motorAssignmentEnabled = provider->numMotors() > 0;
emit motorAssignmentEnabledChanged();
}
bool Actuators::isMultirotor() const
@ -674,13 +677,7 @@ bool Actuators::showUi() const @@ -674,13 +677,7 @@ bool Actuators::showUi() const
bool Actuators::initMotorAssignment()
{
GeometryImage::VehicleGeometryImageProvider* provider = GeometryImage::VehicleGeometryImageProvider::instance();
int numMotors = 0;
QList<ActuatorGeometry>& actuators = provider->actuators();
for (const auto& actuator : actuators) {
if (actuator.type == ActuatorGeometry::Type::Motor) {
++numMotors;
}
}
int numMotors = provider->numMotors();
// get the minimum function for motors
bool ret = false;

4
src/Vehicle/Actuators/Actuators.h

@ -33,6 +33,7 @@ public: @@ -33,6 +33,7 @@ public:
Q_PROPERTY(bool imageRefreshFlag READ imageRefreshFlag NOTIFY imageRefreshFlagChanged)
Q_PROPERTY(bool hasUnsetRequiredFunctions READ hasUnsetRequiredFunctions NOTIFY hasUnsetRequiredFunctionsChanged)
Q_PROPERTY(bool motorAssignmentActive READ motorAssignmentActive NOTIFY motorAssignmentActiveChanged)
Q_PROPERTY(bool motorAssignmentEnabled READ motorAssignmentEnabled NOTIFY motorAssignmentEnabledChanged)
Q_PROPERTY(QString motorAssignmentMessage READ motorAssignmentMessage NOTIFY motorAssignmentMessageChanged)
Q_PROPERTY(ActuatorTesting::ActuatorTest* actuatorTest READ actuatorTest CONSTANT)
@ -75,6 +76,7 @@ public: @@ -75,6 +76,7 @@ public:
Q_INVOKABLE void spinCurrentMotor() { _motorAssignment.spinCurrentMotor(); }
Q_INVOKABLE void abortMotorAssignment();
bool motorAssignmentActive() const { return _motorAssignment.active(); }
bool motorAssignmentEnabled() const { return _motorAssignmentEnabled; }
const QString& motorAssignmentMessage() const { return _motorAssignment.message(); }
public slots:
@ -86,6 +88,7 @@ signals: @@ -86,6 +88,7 @@ signals:
void imageRefreshFlagChanged();
void hasUnsetRequiredFunctionsChanged();
void motorAssignmentActiveChanged();
void motorAssignmentEnabledChanged();
void motorAssignmentMessageChanged();
void actuatorActionsChanged();
@ -112,6 +115,7 @@ private: @@ -112,6 +115,7 @@ private:
ActuatorTesting::ActuatorTest _actuatorTest;
Mixer::Mixers _mixer;
MotorAssignment _motorAssignment;
bool _motorAssignmentEnabled{false};
bool _hasUnsetRequiredFunctions{false};
bool _imageRefreshFlag{false}; ///< indicator to QML to reload the image
int _selectedActuatorOutput{0};

11
src/Vehicle/Actuators/GeometryImage.cc

@ -415,3 +415,14 @@ int VehicleGeometryImageProvider::getHighlightedMotorIndexAtPos(const QPointF &p @@ -415,3 +415,14 @@ int VehicleGeometryImageProvider::getHighlightedMotorIndexAtPos(const QPointF &p
}
return -1;
}
int VehicleGeometryImageProvider::numMotors() const
{
int numMotors = 0;
for (const auto& actuator : _actuators) {
if (actuator.type == ActuatorGeometry::Type::Motor) {
++numMotors;
}
}
return numMotors;
}

2
src/Vehicle/Actuators/GeometryImage.h

@ -50,6 +50,8 @@ public: @@ -50,6 +50,8 @@ public:
QList<ActuatorGeometry>& actuators() { return _actuators; }
int numMotors() const;
private:
VehicleGeometryImageProvider();
~VehicleGeometryImageProvider() = default;

Loading…
Cancel
Save