From fc022b683eed71da4c5f4a67d559c64600aa4d54 Mon Sep 17 00:00:00 2001 From: LAMBERT des CILLEULS Charles Date: Thu, 4 Jan 2024 13:36:21 +0100 Subject: [PATCH] moving some physical constants so they can be config dependants --- src/modules/src/controller/controller_brescianini.c | 1 + src/modules/src/controller/controller_mellinger.c | 1 + src/modules/src/power_distribution_quadrotor.c | 3 ++- src/platform/interface/platform_defaults.h | 10 ++++++++++ src/utils/interface/physicalConstants.h | 4 ---- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/modules/src/controller/controller_brescianini.c b/src/modules/src/controller/controller_brescianini.c index d17d97ab6b..905f9ba300 100644 --- a/src/modules/src/controller/controller_brescianini.c +++ b/src/modules/src/controller/controller_brescianini.c @@ -38,6 +38,7 @@ #include "num.h" #include "math3d.h" #include "physicalConstants.h" +#include "platform_defaults.h" static struct mat33 CRAZYFLIE_INERTIA = {{{16.6e-6f, 0.83e-6f, 0.72e-6f}, diff --git a/src/modules/src/controller/controller_mellinger.c b/src/modules/src/controller/controller_mellinger.c index f15f5e41c0..40bc2c285f 100644 --- a/src/modules/src/controller/controller_mellinger.c +++ b/src/modules/src/controller/controller_mellinger.c @@ -42,6 +42,7 @@ We added the following: #include "position_controller.h" #include "controller_mellinger.h" #include "physicalConstants.h" +#include "platform_defaults.h" // Global state variable used in the // firmware as the only instance and in bindings diff --git a/src/modules/src/power_distribution_quadrotor.c b/src/modules/src/power_distribution_quadrotor.c index c34de07d41..0f3a9d046e 100644 --- a/src/modules/src/power_distribution_quadrotor.c +++ b/src/modules/src/power_distribution_quadrotor.c @@ -33,6 +33,7 @@ #include "autoconf.h" #include "config.h" #include "math.h" +#include "platform_defaults.h" #ifndef CONFIG_MOTORS_DEFAULT_IDLE_THRUST # define DEFAULT_IDLE_THRUST 0 @@ -41,7 +42,7 @@ #endif static uint32_t idleThrust = DEFAULT_IDLE_THRUST; -static float armLength = 0.046f; // m; +static float armLength = ARM_LENGTH; // m static float thrustToTorque = 0.005964552f; // thrust = a * pwm^2 + b * pwm diff --git a/src/platform/interface/platform_defaults.h b/src/platform/interface/platform_defaults.h index af8d5d0f86..0ef68e2a2a 100644 --- a/src/platform/interface/platform_defaults.h +++ b/src/platform/interface/platform_defaults.h @@ -44,6 +44,16 @@ #include "platform_defaults_flapper.h" #endif +// Drone physical constants +#ifndef ARM_LENGTH + // m + #define ARM_LENGTH 0.046f +#endif +#ifndef CF_MASS + // kg + #define CF_MASS 0.027f +#endif + // IMU alignment on the airframe #ifndef IMU_PHI #define IMU_PHI 0.0f diff --git a/src/utils/interface/physicalConstants.h b/src/utils/interface/physicalConstants.h index 7b94316ce4..d107c25b3e 100644 --- a/src/utils/interface/physicalConstants.h +++ b/src/utils/interface/physicalConstants.h @@ -47,7 +47,3 @@ #ifndef ARCMINUTE #define ARCMINUTE (M_PI_F / 10800.0f) #endif - -#ifndef CF_MASS - #define CF_MASS (0.027f) // in kg -#endif