Skip to content

Commit

Permalink
Implemented new command based counting of the atuators in the oneloop…
Browse files Browse the repository at this point in the history
… controller
  • Loading branch information
tmldeponti committed Apr 11, 2024
1 parent 8d7b838 commit 51cacb3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 29 deletions.
8 changes: 1 addition & 7 deletions conf/modules/oneloop_andi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@
<init fun="oneloop_andi_init()"/>
<makefile target="ap|nps" firmware="rotorcraft">
<file name="oneloop_andi.c" dir="$(SRC_FIRMWARE)/oneloop"/>
<configure name="ANDI_OUTPUTS" default="4"/>
<configure name="ANDI_NUM_ACT" default="4"/>
<configure name="ANDI_NUM_VIRTUAL_ACT" default="2"/>
<configure name="ANDI_NUM_ACT_TOT" default="6"/>
<configure name="ANDI_OUTPUTS" default="6"/>
<define name="ANDI_OUTPUTS" value="$(ANDI_OUTPUTS)"/>
<define name="ANDI_NUM_ACT" value="$(ANDI_NUM_ACT)"/>
<define name="ANDI_NUM_VIRTUAL_ACT" value="$(ANDI_NUM_VIRTUAL_ACT)"/>
<define name="ANDI_NUM_ACT_TOT" value="$(ANDI_NUM_ACT_TOT)"/>
</makefile>
</module>
22 changes: 0 additions & 22 deletions sw/airborne/firmwares/rotorcraft/oneloop/oneloop_andi.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,28 +95,6 @@
#include <stdio.h>

// Number of real actuators (e.g. motors, servos)
#ifndef ANDI_NUM_ACT
#error "You must specify the number of real actuators"
#define ANDI_NUM_ACT 4
#endif

// Number of virtual actuators (e.g. Phi, Theta). For now 2 and only 2 are supported but in the future this can be further developed.
#if ANDI_NUM_VIRTUAL_ACT < 2
#error "You must specify the number of virtual actuators to be at least 2"
#define ANDI_NUM_VIRTUAL_ACT 2
#endif

// If the total number of actuators is not defined or wrongly defined correct it
#if ANDI_NUM_ACT_TOT != (ANDI_NUM_ACT + ANDI_NUM_VIRTUAL_ACT)
#error "The number of actuators is not equal to the sum of real and virtual actuators"
#define ANDI_NUM_ACT_TOT (ANDI_NUM_ACT + ANDI_NUM_VIRTUAL_ACT)
#endif

#ifndef ANDI_OUTPUTS
#error "You must specify the number of controlled axis (outputs)"
#define ANDI_OUTPUTS 6
#endif

#ifndef ONELOOP_ANDI_NUM_THRUSTERS
float num_thrusters_oneloop = 4.0; // Number of motors used for thrust
#else
Expand Down
21 changes: 21 additions & 0 deletions sw/airborne/firmwares/rotorcraft/oneloop/oneloop_andi.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,28 @@
#include "firmwares/rotorcraft/stabilization.h"
#include "firmwares/rotorcraft/stabilization/stabilization_attitude_common_int.h"
#include "firmwares/rotorcraft/stabilization/stabilization_attitude_ref_quat_int.h"
#include "generated/airframe.h"

#ifndef ANDI_NUM_ACT
#define ANDI_NUM_ACT COMMANDS_NB_REAL
#endif

#ifndef ANDI_NUM_VIRTUAL_ACT
#define ANDI_NUM_VIRTUAL_ACT COMMANDS_NB_VIRTUAL
#endif

// Number of virtual actuators (e.g. Phi, Theta). For now 2 and only 2 are supported but in the future this can be further developed.
#if ANDI_NUM_VIRTUAL_ACT < 2
#error "You must specify the number of virtual actuators to be at least 2"
#define ANDI_NUM_VIRTUAL_ACT 2
#endif

#define ANDI_NUM_ACT_TOT (ANDI_NUM_ACT + ANDI_NUM_VIRTUAL_ACT)

#ifndef ANDI_OUTPUTS
#error "You must specify the number of controlled axis (outputs)"
#define ANDI_OUTPUTS 6
#endif
#define ANDI_G_SCALING 1000.0f

extern float act_state_filt_vect_1l[ANDI_NUM_ACT];
Expand Down

0 comments on commit 51cacb3

Please sign in to comment.