First unit test for tricoper servo mixer.
This commit is contained in:
parent
c1a0ae16b7
commit
84c7c985ab
|
@ -28,6 +28,7 @@ extern "C" {
|
|||
|
||||
#include "drivers/sensor.h"
|
||||
#include "drivers/accgyro.h"
|
||||
#include "drivers/pwm_mapping.h"
|
||||
|
||||
#include "sensors/sensors.h"
|
||||
#include "sensors/acceleration.h"
|
||||
|
@ -38,11 +39,27 @@ extern "C" {
|
|||
#include "flight/mixer.h"
|
||||
#include "flight/lowpass.h"
|
||||
|
||||
#include "io/escservo.h"
|
||||
#include "io/gimbal.h"
|
||||
#include "io/rc_controls.h"
|
||||
|
||||
extern uint8_t servoCount;
|
||||
void forwardAuxChannelsToServos(void);
|
||||
|
||||
void mixerUseConfigs(
|
||||
#ifdef USE_SERVOS
|
||||
servoParam_t *servoConfToUse,
|
||||
gimbalConfig_t *gimbalConfigToUse,
|
||||
#endif
|
||||
flight3DConfig_t *flight3DConfigToUse,
|
||||
escAndServoConfig_t *escAndServoConfigToUse,
|
||||
mixerConfig_t *mixerConfigToUse,
|
||||
airplaneConfig_t *airplaneConfigToUse,
|
||||
rxConfig_t *rxConfigToUse
|
||||
);
|
||||
|
||||
void mixerInit(mixerMode_e mixerMode, motorMixer_t *initialCustomMixers);
|
||||
void mixerUsePWMOutputConfiguration(pwmOutputConfiguration_t *pwmOutputConfiguration);
|
||||
}
|
||||
|
||||
#include "unittest_macros.h"
|
||||
|
@ -61,6 +78,8 @@ servo_t servos[MAX_SUPPORTED_SERVOS];
|
|||
|
||||
uint8_t lastOneShotUpdateMotorCount;
|
||||
|
||||
uint32_t testFeatureMask = 0;
|
||||
|
||||
|
||||
TEST(FlightMixerTest, TestForwardAuxChannelsToServosWithNoServos)
|
||||
{
|
||||
|
@ -134,6 +153,70 @@ TEST(FlightMixerTest, TestForwardAuxChannelsToServosWithLessServosThanAuxChannel
|
|||
EXPECT_EQ(servos[1].value, 1250);
|
||||
}
|
||||
|
||||
TEST(FlightMixerTest, TestTricopterServo)
|
||||
{
|
||||
// given
|
||||
mixerConfig_t mixerConfig;
|
||||
memset(&mixerConfig, 0, sizeof(mixerConfig));
|
||||
|
||||
mixerConfig.tri_unarmed_servo = 1;
|
||||
|
||||
escAndServoConfig_t escAndServoConfig;
|
||||
memset(&escAndServoConfig, 0, sizeof(escAndServoConfig));
|
||||
escAndServoConfig.mincommand = 1000;
|
||||
|
||||
servoParam_t servoConf[MAX_SUPPORTED_SERVOS];
|
||||
memset(&servoConf, 0, sizeof(servoConf));
|
||||
servoConf[5].min = DEFAULT_SERVO_MIN;
|
||||
servoConf[5].max = DEFAULT_SERVO_MAX;
|
||||
servoConf[5].middle = DEFAULT_SERVO_MIDDLE;
|
||||
servoConf[5].rate = 100;
|
||||
servoConf[5].forwardFromChannel = CHANNEL_FORWARDING_DISABLED;
|
||||
|
||||
gimbalConfig_t gimbalConfig = {
|
||||
.gimbal_flags = 0
|
||||
};
|
||||
|
||||
mixerUseConfigs(
|
||||
servoConf,
|
||||
&gimbalConfig,
|
||||
NULL,
|
||||
&escAndServoConfig,
|
||||
&mixerConfig,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
motorMixer_t customMixer[MAX_SUPPORTED_MOTORS];
|
||||
memset(&customMixer, 0, sizeof(customMixer));
|
||||
|
||||
mixerInit(MIXER_TRI, customMixer);
|
||||
|
||||
// and
|
||||
pwmOutputConfiguration_t pwmOutputConfiguration = {
|
||||
.servoCount = 1,
|
||||
.motorCount = 3
|
||||
};
|
||||
|
||||
mixerUsePWMOutputConfiguration(&pwmOutputConfiguration);
|
||||
|
||||
// and
|
||||
memset(rcCommand, 0, sizeof(rcCommand));
|
||||
|
||||
// and
|
||||
memset(axisPID, 0, sizeof(axisPID));
|
||||
axisPID[YAW] = 0;
|
||||
|
||||
|
||||
// when
|
||||
mixTable();
|
||||
writeServos();
|
||||
|
||||
// then
|
||||
EXPECT_EQ(servos[0].value, 1500);
|
||||
}
|
||||
|
||||
|
||||
// STUBS
|
||||
|
||||
extern "C" {
|
||||
|
@ -153,8 +236,8 @@ uint8_t armingFlags;
|
|||
|
||||
void delay(uint32_t) {}
|
||||
|
||||
bool feature(uint32_t) {
|
||||
return true;
|
||||
bool feature(uint32_t mask) {
|
||||
return (mask & testFeatureMask);
|
||||
}
|
||||
|
||||
int32_t lowpassFixed(lowpass_t *, int32_t, int16_t) {
|
||||
|
|
Loading…
Reference in New Issue