2 * Copyright © 2014 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18 #ifndef _AO_FAKEFLIGHT_H_
19 #define _AO_FAKEFLIGHT_H_
23 #include <ao_ms5607.h>
28 #define GAS_CONSTANT 287.05
30 #define GRAVITATIONAL_CONSTANT 6.67384e-11
32 #define EARTH_MASS 5.9726e24
33 #define EARTH_RADIUS 6375313
43 extern char *state_name[];
52 double average_thrust;
60 struct model models[state_num];
63 struct motor motors[MAX_MOTORS];
73 enum flight_state state;
78 /* Density of dry air in kg/m³ for a given pressure and temperature. */
79 /* Density of dry air in kg/m³ for a given pressure and temperature. */
81 density_air(double pressure, /* Pa */
82 double temperature); /* °C */
84 /* Area of a circle */
86 area_circle(double diameter);
88 /* Force due to drag (N) */
90 force_drag(double speed, /* m/s */
91 double rho, /* kg/m³ */
92 double cd, /* unitless */
93 double area); /* m² */
95 /* Force due to gravity (N) */
97 force_gravity(double mass, /* kg */
98 double altitude); /* m */
102 /* Mass (kg) of the airframe */
104 rocket_mass(struct flight *f, struct rocket *r);
106 /* Force (N) due to thrust */
108 rocket_thrust(struct flight *f, struct rocket *r);
110 /* Drag (N) due to air resistance */
112 rocket_drag(struct flight *f, struct rocket *r);
114 /* Force (N) due to gravity */
116 rocket_gravity(struct flight *f, struct rocket *r);
118 /* ao-fake-convert.c */
120 ao_ms5607_unconvert(double altitude,
121 struct ao_ms5607_sample *ret);
124 ao_accel_unconvert(double accel);
127 ao_show_header(FILE *f, struct rocket *r);
132 ao_log_flight(FILE *file, struct flight *f, struct rocket *r);
135 ao_log_sensor(FILE *file, struct flight *f, struct rocket *r);
138 ao_log_state(FILE *file, struct flight *f, struct rocket *r);