Skip to content

Commit

Permalink
Merge pull request #1338 from atoums/physicalConstants
Browse files Browse the repository at this point in the history
moving some physical constants so they can be config dependants
  • Loading branch information
knmcguire committed Jan 30, 2024
2 parents 64d5f21 + 4217d16 commit 09bcfb0
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/modules/src/controller/controller_brescianini.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
1 change: 1 addition & 0 deletions src/modules/src/controller/controller_mellinger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/modules/src/power_distribution_quadrotor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/platform/interface/platform_defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@
#include "platform_defaults_flapper.h"
#endif

// Drone physical constants
// TODO provide those in each config. Those are values of cf2 platform
#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
Expand Down
6 changes: 6 additions & 0 deletions src/platform/interface/platform_defaults_cf2.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
// Requires kbuild config ENABLE_AUTO_SHUTDOWN to be activated.
#define DEFAULT_SYSTEM_SHUTDOWN_TIMEOUT_MIN 5

// Drone physical constants
// m
#define ARM_LENGTH 0.046f
// kg
#define CF_MASS 0.027f

// Default PID gains
#define PID_ROLL_RATE_KP 250.0
#define PID_ROLL_RATE_KI 500.0
Expand Down
4 changes: 0 additions & 4 deletions src/utils/interface/physicalConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 09bcfb0

Please sign in to comment.