mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-25 09:16:01 +03:00
Added gimbalConfig parameter group
This commit is contained in:
parent
717667dd82
commit
47d2ad73ad
7 changed files with 32 additions and 15 deletions
|
@ -43,7 +43,6 @@
|
|||
#include "flight/navigation_rewrite.h"
|
||||
#include "flight/pid.h"
|
||||
|
||||
#include "io/gimbal.h"
|
||||
#include "io/gps.h"
|
||||
#include "io/osd.h"
|
||||
#include "io/ledstrip.h"
|
||||
|
@ -115,8 +114,6 @@ typedef struct master_s {
|
|||
#ifdef USE_SERVOS
|
||||
// Servo-related stuff
|
||||
servoParam_t servoConf[MAX_SUPPORTED_SERVOS]; // servo configuration
|
||||
// gimbal-related configuration
|
||||
gimbalConfig_t gimbalConfig;
|
||||
|
||||
uint16_t flaperon_throw_offset;
|
||||
uint8_t flaperon_throw_inverted;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
// FC configuration
|
||||
#define PG_FAILSAFE_CONFIG 1
|
||||
#define PG_BOARD_ALIGNMENT 2
|
||||
//#define PG_GIMBAL_CONFIG 3
|
||||
#define PG_GIMBAL_CONFIG 3
|
||||
//#define PG_MOTOR_MIXER 4
|
||||
//#define PG_BLACKBOX_CONFIG 5
|
||||
#define PG_MOTOR_CONFIG 6
|
||||
|
|
|
@ -503,9 +503,6 @@ void createDefaultConfig(master_t *config)
|
|||
config->servoConf[i].forwardFromChannel = CHANNEL_FORWARDING_DISABLED;
|
||||
}
|
||||
|
||||
// gimbal
|
||||
config->gimbalConfig.mode = GIMBAL_MODE_NORMAL;
|
||||
|
||||
config->flaperon_throw_offset = FLAPERON_THROW_DEFAULT;
|
||||
config->flaperon_throw_inverted = 0;
|
||||
|
||||
|
@ -663,7 +660,7 @@ static void activateConfig(void)
|
|||
|
||||
mixerUseConfigs(&masterConfig.flight3DConfig, &masterConfig.mixerConfig);
|
||||
#ifdef USE_SERVOS
|
||||
servosUseConfigs(&masterConfig.servoMixerConfig, masterConfig.servoConf, &masterConfig.gimbalConfig);
|
||||
servosUseConfigs(&masterConfig.servoMixerConfig, masterConfig.servoConf);
|
||||
#endif
|
||||
|
||||
imuConfigure(&masterConfig.imuConfig, ¤tProfile->pidProfile);
|
||||
|
|
|
@ -583,6 +583,11 @@ static const clivalue_t valueTable[] = {
|
|||
{ "align_board_roll", VAR_INT16 | MASTER_VALUE, .config.minmax = { -1800, 3600 }, PG_BOARD_ALIGNMENT, offsetof(boardAlignment_t, rollDeciDegrees) },
|
||||
{ "align_board_pitch", VAR_INT16 | MASTER_VALUE, .config.minmax = { -1800, 3600 }, PG_BOARD_ALIGNMENT, offsetof(boardAlignment_t, pitchDeciDegrees) },
|
||||
{ "align_board_yaw", VAR_INT16 | MASTER_VALUE, .config.minmax = { -1800, 3600 }, PG_BOARD_ALIGNMENT, offsetof(boardAlignment_t, yawDeciDegrees) },
|
||||
|
||||
// PG_GIMBAL_CONFIG
|
||||
#ifdef USE_SERVOS
|
||||
{ "gimbal_mode", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_GIMBAL_MODE }, PG_GIMBAL_CONFIG, offsetof(gimbalConfig_t, mode) },
|
||||
#endif
|
||||
};
|
||||
|
||||
#else
|
||||
|
@ -755,7 +760,6 @@ const clivalue_t valueTable[] = {
|
|||
{ "tri_unarmed_servo", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, &servoMixerConfig()->tri_unarmed_servo, .config.lookup = { TABLE_OFF_ON } },
|
||||
{ "servo_lowpass_freq", VAR_INT16 | MASTER_VALUE, &servoMixerConfig()->servo_lowpass_freq, .config.minmax = { 10, 400} },
|
||||
{ "servo_lowpass_enable", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, &servoMixerConfig()->servo_lowpass_enable, .config.lookup = { TABLE_OFF_ON } },
|
||||
{ "gimbal_mode", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.gimbalConfig.mode, .config.lookup = { TABLE_GIMBAL_MODE } },
|
||||
{ "servo_center_pulse", VAR_UINT16 | MASTER_VALUE, &servoConfig()->servoCenterPulse, .config.minmax = { PWM_RANGE_ZERO, PWM_RANGE_MAX } },
|
||||
{ "servo_pwm_rate", VAR_UINT16 | MASTER_VALUE, &servoConfig()->servoPwmRate, .config.minmax = { 50, 498 } },
|
||||
{ "fw_iterm_throw_limit", VAR_INT16 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.fixedWingItermThrowLimit, .config.minmax = { FW_ITERM_THROW_LIMIT_MIN, FW_ITERM_THROW_LIMIT_MAX} },
|
||||
|
@ -1086,6 +1090,9 @@ static rxFailsafeChannelConfig_t rxFailsafeChannelConfigsCopy[MAX_SUPPORTED_RC_C
|
|||
static rxChannelRangeConfig_t rxChannelRangeConfigsCopy[NON_AUX_CHANNEL_COUNT];
|
||||
static motorConfig_t motorConfigCopy;
|
||||
static boardAlignment_t boardAlignmentCopy;
|
||||
#ifdef USE_SERVOS
|
||||
static gimbalConfig_t gimbalConfigCopy;
|
||||
#endif
|
||||
|
||||
static void backupConfigs(void)
|
||||
{
|
||||
|
@ -1110,6 +1117,9 @@ static void backupConfigs(void)
|
|||
}
|
||||
motorConfigCopy = *motorConfig();
|
||||
boardAlignmentCopy = *boardAlignment();
|
||||
#ifdef USE_SERVOS
|
||||
gimbalConfigCopy = *gimbalConfig();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void restoreConfigs(void)
|
||||
|
@ -1134,6 +1144,9 @@ static void restoreConfigs(void)
|
|||
}
|
||||
*motorConfig() = motorConfigCopy;
|
||||
*boardAlignment() = boardAlignmentCopy;
|
||||
#ifdef USE_SERVOS
|
||||
*gimbalConfig() = gimbalConfigCopy;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void *getDefaultPointer(const void *valuePointer, const master_t *defaultConfig)
|
||||
|
@ -1177,6 +1190,9 @@ static void dumpValues(uint16_t valueSection, uint8_t dumpMask, const master_t *
|
|||
dumpPgValues(MASTER_VALUE, dumpMask, PG_RX_CONFIG, &rxConfigCopy, rxConfig());
|
||||
dumpPgValues(MASTER_VALUE, dumpMask, PG_MOTOR_CONFIG, &motorConfigCopy, motorConfig());
|
||||
dumpPgValues(MASTER_VALUE, dumpMask, PG_BOARD_ALIGNMENT, &boardAlignmentCopy, boardAlignment());
|
||||
#ifdef USE_SERVOS
|
||||
dumpPgValues(MASTER_VALUE, dumpMask, PG_GIMBAL_CONFIG, &gimbalConfigCopy, gimbalConfig());
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
#include "common/maths.h"
|
||||
#include "common/filter.h"
|
||||
|
||||
#include "config/parameter_group.h"
|
||||
#include "config/parameter_group_ids.h"
|
||||
|
||||
#include "drivers/pwm_output.h"
|
||||
#include "drivers/pwm_mapping.h"
|
||||
#include "drivers/system.h"
|
||||
|
@ -67,7 +70,6 @@ servoMixerConfig_t *servoMixerConfig;
|
|||
|
||||
static uint8_t servoRuleCount = 0;
|
||||
static servoMixer_t currentServoMixer[MAX_SERVO_RULES];
|
||||
static gimbalConfig_t *gimbalConfig;
|
||||
int16_t servo[MAX_SUPPORTED_SERVOS];
|
||||
static int servoOutputEnabled;
|
||||
|
||||
|
@ -132,11 +134,13 @@ const mixerRules_t servoMixers[] = {
|
|||
|
||||
static servoMixer_t *customServoMixers;
|
||||
|
||||
void servosUseConfigs(servoMixerConfig_t *servoMixerConfigToUse, servoParam_t *servoParamsToUse, gimbalConfig_t *gimbalConfigToUse)
|
||||
// no template required since default is zero
|
||||
PG_REGISTER(gimbalConfig_t, gimbalConfig, PG_GIMBAL_CONFIG, 0);
|
||||
|
||||
void servosUseConfigs(servoMixerConfig_t *servoMixerConfigToUse, servoParam_t *servoParamsToUse)
|
||||
{
|
||||
servoMixerConfig = servoMixerConfigToUse;
|
||||
servoConf = servoParamsToUse;
|
||||
gimbalConfig = gimbalConfigToUse;
|
||||
}
|
||||
|
||||
int16_t getFlaperonDirection(uint8_t servoPin) {
|
||||
|
@ -417,7 +421,7 @@ void processServoTilt(void)
|
|||
servo[SERVO_GIMBAL_ROLL] = determineServoMiddleOrForwardFromChannel(SERVO_GIMBAL_ROLL);
|
||||
|
||||
if (IS_RC_MODE_ACTIVE(BOXCAMSTAB)) {
|
||||
if (gimbalConfig->mode == GIMBAL_MODE_MIXTILT) {
|
||||
if (gimbalConfig()->mode == GIMBAL_MODE_MIXTILT) {
|
||||
servo[SERVO_GIMBAL_PITCH] -= (-(int32_t)servoConf[SERVO_GIMBAL_PITCH].rate) * attitude.values.pitch / 50 - (int32_t)servoConf[SERVO_GIMBAL_ROLL].rate * attitude.values.roll / 50;
|
||||
servo[SERVO_GIMBAL_ROLL] += (-(int32_t)servoConf[SERVO_GIMBAL_PITCH].rate) * attitude.values.pitch / 50 + (int32_t)servoConf[SERVO_GIMBAL_ROLL].rate * attitude.values.roll / 50;
|
||||
} else {
|
||||
|
|
|
@ -124,6 +124,5 @@ void filterServos(void);
|
|||
void servoMixerLoadMix(int index, servoMixer_t *customServoMixers);
|
||||
void loadCustomServoMixer(void);
|
||||
int servoDirection(int servoIndex, int fromChannel);
|
||||
struct gimbalConfig_s;
|
||||
void servosUseConfigs(servoMixerConfig_t *servoConfigToUse, servoParam_t *servoParamsToUse, struct gimbalConfig_s *gimbalConfigToUse);
|
||||
void servosUseConfigs(servoMixerConfig_t *servoConfigToUse, servoParam_t *servoParamsToUse);
|
||||
void servosInit(servoMixer_t *customServoMixers);
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "config/parameter_group.h"
|
||||
|
||||
typedef enum {
|
||||
GIMBAL_MODE_NORMAL = 0,
|
||||
GIMBAL_MODE_MIXTILT = 1
|
||||
|
@ -27,3 +29,5 @@ typedef enum {
|
|||
typedef struct gimbalConfig_s {
|
||||
uint8_t mode;
|
||||
} gimbalConfig_t;
|
||||
|
||||
PG_DECLARE(gimbalConfig_t, gimbalConfig);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue