-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflight_computer.h
More file actions
42 lines (35 loc) · 1.55 KB
/
Copy pathflight_computer.h
File metadata and controls
42 lines (35 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef FLIGHT_COMPUTER_H
#define FLIGHT_COMPUTER_H
// For MOTOR_COUNT and SERVO_COUNT below - the snapshot has to be exactly as
// wide as the drivers it is reporting on.
#include "motors.h"
#include "servos.h"
// The vehicle's mode. This is the only FlightMode in the firmware - main.cpp
// does not keep one of its own.
enum FlightMode {
IDLE, // disarmed, motors inert
VERTICAL, // hover, altitude hold on the four lift rotors
TRANSITION, // timed tilt ramp between hover and cruise
HORIZONTAL // cruise, heading and speed hold
};
// One snapshot of the aircraft, assembled once per cycle and handed to
// telemetry. There is no attitude in here: the airframe carries no IMU, so
// pitch, roll and yaw have no source, and a downlink that reports numbers
// nothing measured is worse than one that admits the gap.
struct FlightData {
float altitude; // m above where the aircraft was powered up
float verticalSpeed; // m/s, positive up
float heading; // deg, 0..360
float speed; // m/s over the ground
float latitude; // decimal degrees
float longitude; // decimal degrees
float motorPower[MOTOR_COUNT]; // 0..1, as last commanded
float servoAngles[SERVO_COUNT]; // degrees, as last commanded
FlightMode mode;
bool armed;
};
void initFlightComputer();
// One control cycle. main.cpp calls this at a fixed 50 Hz.
void updateFlightComputer();
FlightData getFlightData();
#endif // FLIGHT_COMPUTER_H