Skip to content

Commit 43c4718

Browse files
committed
LP-563 CameraDesired is updated continuouslly, check gimbal outputs.
1 parent 3735346 commit 43c4718

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

flight/modules/CameraStab/camerastab.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949

5050
#include "accessorydesired.h"
5151
#include "attitudestate.h"
52+
#include "mixersettings.h"
53+
#include "actuatorcommand.h"
5254
#include "camerastabsettings.h"
5355
#include "cameradesired.h"
5456
#include "hwsettings.h"
@@ -61,6 +63,8 @@
6163
// Private types
6264

6365
// Private variables
66+
static bool gimbalOutputEnabled = false;
67+
6468
static struct CameraStab_data {
6569
portTickType lastSysTime;
6670
float inputs[CAMERASTABSETTINGS_INPUT_NUMELEM];
@@ -83,6 +87,12 @@ static void attitudeUpdated(UAVObjEvent *ev);
8387
static void applyFeedForward(uint8_t index, float dT, float *attitude, CameraStabSettingsData *cameraStab);
8488
#endif
8589

90+
// this structure is equivalent to the UAVObjects for one mixer.
91+
typedef struct {
92+
uint8_t type;
93+
int8_t matrix[5];
94+
} __attribute__((packed)) Mixer_t;
95+
8696

8797
/**
8898
* Initialise the module, called on startup
@@ -148,6 +158,20 @@ static void attitudeUpdated(UAVObjEvent *ev)
148158
return;
149159
}
150160

161+
if (!gimbalOutputEnabled) {
162+
MixerSettingsData mixerSettings;
163+
MixerSettingsGet(&mixerSettings);
164+
Mixer_t *mixers = (Mixer_t *)&mixerSettings.Mixer1Type;
165+
for (int ct = 0; ct < ACTUATORCOMMAND_CHANNEL_NUMELEM; ct++) {
166+
uint8_t mixer_type = mixers[ct].type;
167+
if ((mixer_type >= MIXERSETTINGS_MIXER1TYPE_CAMERAROLLORSERVO1) &&
168+
(mixer_type <= MIXERSETTINGS_MIXER1TYPE_CAMERAYAW)) {
169+
gimbalOutputEnabled = true;
170+
}
171+
}
172+
return;
173+
}
174+
151175
AccessoryDesiredData accessory;
152176

153177
CameraStabSettingsData cameraStab;

0 commit comments

Comments
 (0)