c_projects/cixdof/drone.h

42 lines
931 B
C
Raw Normal View History

2026-10-31 23:12:53 -04:00
#ifndef DRONE_H
#define DRONE_H
#include "../mathprimitives/mathprimitives.h"
#include <stdint.h>
2026-11-03 22:38:36 -05:00
/*
* Properties of the quadcopter
*/
2026-10-31 23:12:53 -04:00
struct QuadCopter {
double mass_kg;
2026-11-03 22:38:36 -05:00
struct Mat3 moment_of_inertia;
2026-10-31 23:12:53 -04:00
double drag_coeff;
};
2026-11-01 23:38:25 -05:00
enum PropSpinDir { CW = 1, CCW = -1 };
2026-10-31 23:12:53 -04:00
struct Propeller {
struct Vec3 x_cg2p_b;
double angular_velocity;
double thrust_coefficient;
double moment_coefficient;
enum PropSpinDir direction;
};
struct QuadCopterSim {
double timestep;
uint32_t iterations;
struct QuadCopter quad_copter;
struct Propeller props[4];
};
static inline struct Vec3 body_position_to_inertial(struct Vec3 x_o2cg_i,
struct Quat attitude,
struct Vec3 x_cg2point_b) {
struct Vec3 x_cg2point_i = quat_apply(quat_conjugate(attitude), x_cg2point_b);
return vec3_add(x_o2cg_i, x_cg2point_i);
}
#endif