48 uint8_t control_group,
49 uint8_t control_index,
59 int main(
int argc,
char *argv[])
61 FILE *file_in = stdin;
64 file_in = fopen(argv[1],
"r");
67 unsigned rotor_count = 0;
73 fscanf(file_in,
"%i", &airmode);
76 fscanf(file_in,
"%i", &rotor_count);
82 for (
unsigned i = 0; i < rotor_count; ++i) {
83 fscanf(file_in,
"%f %f %f %f", &rotors[i].roll_scale, &rotors[i].pitch_scale,
84 &rotors[i].yaw_scale, &rotors[i].thrust_scale);
93 while (!feof(file_in)) {
107 if (mixer.
mix(actuator_outputs,
output_max) != rotor_count) {
116 while (count < rotor_count && fscanf(file_in,
"%f", &expected_output[count]) == 1) {
117 if (fabsf(expected_output[count] - actuator_outputs[count]) > 0.00001f) {
124 if (count < rotor_count) {
129 printf(
"test %i failed:\n", test_counter + 1);
130 printf(
"control input : %.3f %.3f %.3f %.3f\n", (
double)
actuator_controls[0], (
double)actuator_controls[1],
131 (
double)actuator_controls[2], (
double)actuator_controls[3]);
132 printf(
"mixer output : ");
134 for (
unsigned i = 0; i < rotor_count; ++i) {
135 printf(
"%.3f ", (
double)actuator_outputs[i]);
139 printf(
"expected output: ");
141 for (
unsigned i = 0; i < rotor_count; ++i) {
142 printf(
"%.3f ", (
double)expected_output[i]);
148 for (
unsigned i = 0; i < rotor_count; ++i) {
149 printf(
"%.3f ", (
double)(expected_output[i] - actuator_outputs[i]));
159 printf(
"tested %i cases: %i success, %i failed\n", test_counter,
160 test_counter - num_failed, num_failed);
163 if (file_in != stdin) {
167 return num_failed > 0 ? -1 : 0;
static const unsigned output_max
testing binary that runs the multirotor mixer through test cases given via file or stdin and compares...
static int mixer_callback(uintptr_t handle, uint8_t control_group, uint8_t control_index, float &control)
static MultirotorMixer * mixer
mixer initialization
void set_airmode(Airmode airmode) override
Set airmode.
unsigned mix(float *outputs, unsigned space) override
Perform the mixing function.
static float actuator_controls[output_max]
Multi-rotor mixer for pre-defined vehicle geometries.
int main(int argc, char *argv[])