Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
swashplate_mixing.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 C. De Wagter
3  * 2015 Freek van Tienen <freek.v.tienen@gmail.com>
4  *
5  * This file is part of paparazzi
6  *
7  * paparazzi is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * paparazzi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with paparazzi; see the file COPYING. If not, see
19  * <http://www.gnu.org/licenses/>.
20  */
27 #include "swashplate_mixing.h"
28 #include "throttle_curve.h"
29 
30 PRINT_CONFIG_VAR(SW_MIXING_TYPE)
32 
33 /* Coeficients per motor */
34 static const float roll_coef[SW_NB] = SW_MIXING_ROLL_COEF;
35 static const float pitch_coef[SW_NB] = SW_MIXING_PITCH_COEF;
36 static const float coll_coef[SW_NB] = SW_MIXING_COLL_COEF;
37 
38 /* Default roll trim */
39 #ifndef SW_MIXING_TRIM_ROLL
40 #define SW_MIXING_TRIM_ROLL 0
41 #endif
43 
44 /* Default pitch trim */
45 #ifndef SW_MIXING_TRIM_PITCH
46 #define SW_MIXING_TRIM_PITCH 0
47 #endif
49 
50 /* Default collective trim */
51 #ifndef SW_MIXING_TRIM_COLL
52 #define SW_MIXING_TRIM_COLL 0
53 #endif
55 
56 
57 
61 {
62  uint8_t i;
63 
64  // Go trough all the motors and calculate the trim value and set the initial command
65  for (i = 0; i < SW_NB; i++) {
71  }
72 }
73 
74 /*
75  * Run the swashplate mixing
76  * This depends on the ROLL and PITCH command
77  * It also depends on the throttle_curve.collective
78  */
80 {
81  uint8_t i;
82 
83  // Go trough all the motors and calculate the command
84  for (i = 0; i < SW_NB; i++) {
86  roll_coef[i] * in_cmd[COMMAND_ROLL] +
87  pitch_coef[i] * in_cmd[COMMAND_PITCH] +
88  coll_coef[i] * in_cmd[COMMAND_COLLECTIVE];
89  BoundAbs(swashplate_mixing.commands[i], MAX_PPRZ);
90  }
91 }
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
int16_t pprz_t
Definition: paparazzi.h:6
#define MAX_PPRZ
Definition: paparazzi.h:8
#define SW_MIXING_TRIM_PITCH
static const float pitch_coef[SW_NB]
void swashplate_mixing_run(pprz_t in_cmd[])
struct swashplate_mixing_t swashplate_mixing
void swashplate_mixing_init()
Initialize the motor mixing and calculate the trim values.
#define SW_MIXING_TRIM_ROLL
static const float roll_coef[SW_NB]
#define SW_MIXING_TRIM_COLL
static const float coll_coef[SW_NB]
#define SW_MIXING_PITCH_COEF
#define SW_MIXING_ROLL_COEF
#define SW_MIXING_COLL_COEF
int32_t commands[SW_NB]
The output commands.
#define SW_NB
MECH (front/right/coll), H120 (front/rightback/leftback), HR120 (back/leftfront/rightfront)
int32_t trim[SW_NB]
Trim values for the different actuators.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98