Skip to content

Commit

Permalink
Final Version
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone-DAngelo committed Feb 10, 2024
1 parent 13692d5 commit d42bcbb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 21 deletions.
47 changes: 27 additions & 20 deletions src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,26 @@ PX4FirmwarePluginInstanceData::PX4FirmwarePluginInstanceData(QObject* parent)
}

PX4FirmwarePlugin::PX4FirmwarePlugin()
: _manualFlightMode (tr("Manual"))
, _acroFlightMode (tr("Acro"))
, _stabilizedFlightMode (tr("Stabilized"))
, _rattitudeFlightMode (tr("Rattitude"))
, _altCtlFlightMode (tr("Altitude"))
, _posCtlFlightMode (tr("Position"))
, _offboardFlightMode (tr("Offboard"))
, _readyFlightMode (tr("Ready"))
, _takeoffFlightMode (tr("Takeoff"))
, _holdFlightMode (tr("Hold"))
, _missionFlightMode (tr("Mission"))
, _rtlFlightMode (tr("Return"))
, _landingFlightMode (tr("Land"))
, _preclandFlightMode (tr("Precision Land"))
, _rtgsFlightMode (tr("Return to Groundstation"))
, _followMeFlightMode (tr("Follow Me"))
, _simpleFlightMode (tr("Simple"))
, _orbitFlightMode (tr("Orbit"))
: _manualFlightMode (tr("Manual"))
, _acroFlightMode (tr("Acro"))
, _stabilizedFlightMode (tr("Stabilized"))
, _rattitudeFlightMode (tr("Rattitude"))
, _altCtlFlightMode (tr("Altitude"))
, _posCtlFlightMode (tr("Position"))
, _offboardFlightMode (tr("Offboard"))
, _readyFlightMode (tr("Ready"))
, _takeoffFlightMode (tr("Takeoff"))
, _holdFlightMode (tr("Hold"))
, _missionFlightMode (tr("Mission"))
, _rtlFlightMode (tr("Return"))
, _landingFlightMode (tr("Land"))
, _preclandFlightMode (tr("Precision Land"))
, _rtgsFlightMode (tr("Return to Groundstation"))
, _followMeFlightMode (tr("Follow Me"))
, _simpleFlightMode (tr("Simple"))
, _orbitFlightMode (tr("Orbit"))
, _prismaManualFlightMode (tr("Prisma Manual"))
, _prismaOffboardFlightMode (tr("Prisma Offboard"))
{
qmlRegisterType<PX4SimpleFlightModesController> ("QGroundControl.Controllers", 1, 0, "PX4SimpleFlightModesController");
qmlRegisterType<AirframeComponentController> ("QGroundControl.Controllers", 1, 0, "AirframeComponentController");
Expand All @@ -75,16 +77,19 @@ PX4FirmwarePlugin::PX4FirmwarePlugin()
{ PX4_CUSTOM_MAIN_MODE_OFFBOARD, 0, true, false, true },
{ PX4_CUSTOM_MAIN_MODE_SIMPLE, 0, false, false, true },
{ PX4_CUSTOM_MAIN_MODE_POSCTL, PX4_CUSTOM_SUB_MODE_POSCTL_POSCTL, true, true, true },
{ PX4_CUSTOM_MAIN_MODE_POSCTL, PX4_CUSTOM_SUB_MODE_POSCTL_ORBIT, false, false, false },
{ PX4_CUSTOM_MAIN_MODE_POSCTL, PX4_CUSTOM_SUB_MODE_POSCTL_ORBIT, false, false, false},
{ PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_LOITER, true, true, true },
{ PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_MISSION, true, true, true },
{ PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_RTL, true, true, true },
{ PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_FOLLOW_TARGET, true, false, true },
{ PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_LAND, false, true, true },
{ PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_PRECLAND, true, false, true },
{ PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_PRECLAND, true, false, true },
{ PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_READY, false, true, true },
{ PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_RTGS, false, true, true },
{ PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_TAKEOFF, false, true, true },
{ PX4_CUSTOM_MAIN_MODE_PRISMA, PX4_CUSTOM_SUB_MODE_PRISMA_MAN, true, true, true },
{ PX4_CUSTOM_MAIN_MODE_PRISMA, PX4_CUSTOM_SUB_MODE_PRISMA_1, true, false, true },

};

// Must be in same order as above structure
Expand All @@ -107,6 +112,8 @@ PX4FirmwarePlugin::PX4FirmwarePlugin()
&_readyFlightMode,
&_rtgsFlightMode,
&_takeoffFlightMode,
&_prismaManualFlightMode,
&_prismaOffboardFlightMode,
};

// Convert static information to dynamic list. This allows for plugin override class to manipulate list.
Expand Down
4 changes: 4 additions & 0 deletions src/FirmwarePlugin/PX4/PX4FirmwarePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class PX4FirmwarePlugin : public FirmwarePlugin
QString takeControlFlightMode (void) const override { return _manualFlightMode; }
QString gotoFlightMode (void) const override { return _holdFlightMode; }
QString followFlightMode (void) const override { return _followMeFlightMode; };
QString prismaManualFlightMode (void) const { return _prismaManualFlightMode; };
QString prismaOffboardFlightMode (void) const { return _prismaOffboardFlightMode; };
void pauseVehicle (Vehicle* vehicle) override;
void guidedModeRTL (Vehicle* vehicle, bool smartRTL) override;
void guidedModeLand (Vehicle* vehicle) override;
Expand Down Expand Up @@ -108,6 +110,8 @@ class PX4FirmwarePlugin : public FirmwarePlugin
QString _followMeFlightMode;
QString _simpleFlightMode;
QString _orbitFlightMode;
QString _prismaManualFlightMode;
QString _prismaOffboardFlightMode;

private slots:
void _mavCommandResult(int vehicleId, int component, int command, int result, bool noReponseFromVehicle);
Expand Down
9 changes: 8 additions & 1 deletion src/FirmwarePlugin/PX4/px4_custom_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ enum PX4_CUSTOM_MAIN_MODE {
PX4_CUSTOM_MAIN_MODE_OFFBOARD,
PX4_CUSTOM_MAIN_MODE_STABILIZED,
PX4_CUSTOM_MAIN_MODE_RATTITUDE,
PX4_CUSTOM_MAIN_MODE_SIMPLE /* unused, but reserved for future use */
PX4_CUSTOM_MAIN_MODE_SIMPLE, /* unused, but reserved for future use */
PX4_CUSTOM_MAIN_MODE_PRISMA

};

enum PX4_CUSTOM_SUB_MODE_AUTO {
Expand All @@ -71,6 +73,11 @@ enum PX4_CUSTOM_SUB_MODE_POSCTL {
PX4_CUSTOM_SUB_MODE_POSCTL_ORBIT
};

enum PX4_CUSTOM_SUB_MODE_PRISMA {
PX4_CUSTOM_SUB_MODE_PRISMA_1 = 1,
PX4_CUSTOM_SUB_MODE_PRISMA_MAN
};

union px4_custom_mode {
struct {
uint16_t reserved;
Expand Down

0 comments on commit d42bcbb

Please sign in to comment.