From 43c4718798a8e806ecb85868da367804c9972f88 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Sun, 3 Dec 2017 17:59:51 +0100 Subject: [PATCH] LP-563 CameraDesired is updated continuouslly, check gimbal outputs. --- flight/modules/CameraStab/camerastab.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/flight/modules/CameraStab/camerastab.c b/flight/modules/CameraStab/camerastab.c index 29c84c6ff..972195a0e 100644 --- a/flight/modules/CameraStab/camerastab.c +++ b/flight/modules/CameraStab/camerastab.c @@ -49,6 +49,8 @@ #include "accessorydesired.h" #include "attitudestate.h" +#include "mixersettings.h" +#include "actuatorcommand.h" #include "camerastabsettings.h" #include "cameradesired.h" #include "hwsettings.h" @@ -61,6 +63,8 @@ // Private types // Private variables +static bool gimbalOutputEnabled = false; + static struct CameraStab_data { portTickType lastSysTime; float inputs[CAMERASTABSETTINGS_INPUT_NUMELEM]; @@ -83,6 +87,12 @@ static void attitudeUpdated(UAVObjEvent *ev); static void applyFeedForward(uint8_t index, float dT, float *attitude, CameraStabSettingsData *cameraStab); #endif +// this structure is equivalent to the UAVObjects for one mixer. +typedef struct { + uint8_t type; + int8_t matrix[5]; +} __attribute__((packed)) Mixer_t; + /** * Initialise the module, called on startup @@ -148,6 +158,20 @@ static void attitudeUpdated(UAVObjEvent *ev) return; } + if (!gimbalOutputEnabled) { + MixerSettingsData mixerSettings; + MixerSettingsGet(&mixerSettings); + Mixer_t *mixers = (Mixer_t *)&mixerSettings.Mixer1Type; + for (int ct = 0; ct < ACTUATORCOMMAND_CHANNEL_NUMELEM; ct++) { + uint8_t mixer_type = mixers[ct].type; + if ((mixer_type >= MIXERSETTINGS_MIXER1TYPE_CAMERAROLLORSERVO1) && + (mixer_type <= MIXERSETTINGS_MIXER1TYPE_CAMERAYAW)) { + gimbalOutputEnabled = true; + } + } + return; + } + AccessoryDesiredData accessory; CameraStabSettingsData cameraStab; -- 2.11.4.GIT