2023-01-18 11:49:09 -06:00
|
|
|
/************************************************************************
|
|
|
|
PURPOSE: (Simulate an Aircraft.)
|
|
|
|
LIBRARY DEPENDENCIES:
|
|
|
|
((Aircraft/src/Aircraft.o))
|
|
|
|
**************************************************************************/
|
|
|
|
#ifndef Aircraft_HH
|
|
|
|
#define Aircraft_HH
|
|
|
|
|
2023-04-13 10:50:36 -05:00
|
|
|
#include "Aircraft/include/Waypoint.hh"
|
2023-02-13 16:45:15 -06:00
|
|
|
|
2023-04-13 10:50:36 -05:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2023-02-13 16:45:15 -06:00
|
|
|
|
2023-01-18 11:49:09 -06:00
|
|
|
class Aircraft {
|
|
|
|
public:
|
|
|
|
// Calculated by numeric integration of state derivatives.
|
|
|
|
double pos[2];
|
|
|
|
double vel[2];
|
|
|
|
|
|
|
|
// Updated by control logic;
|
2023-04-13 10:50:36 -05:00
|
|
|
WaypointList flightPath;
|
|
|
|
int cWP;
|
|
|
|
|
|
|
|
// Waypoint List Information Variables
|
|
|
|
double wpPos[2];
|
|
|
|
std::string wpImg;
|
|
|
|
int wpIdx;
|
2023-01-18 11:49:09 -06:00
|
|
|
|
|
|
|
// Static Parameters (Don't change during the simulation.)
|
|
|
|
double mass;
|
|
|
|
double thrust_mag_max;
|
|
|
|
double K_drag;
|
|
|
|
double heading_rate_gain;
|
|
|
|
|
|
|
|
// Control Parameters (Recieved from the variable server client.)
|
|
|
|
double desired_heading;
|
|
|
|
double desired_speed; // m/s
|
|
|
|
bool autoPilot;
|
|
|
|
|
|
|
|
// Calculated
|
|
|
|
// Input to numeric integrator.
|
|
|
|
double acc[2];
|
|
|
|
//
|
|
|
|
double heading;
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
int default_data();
|
|
|
|
int state_init();
|
|
|
|
int state_deriv();
|
|
|
|
int state_integ();
|
|
|
|
int control();
|
|
|
|
|
2023-04-13 10:50:36 -05:00
|
|
|
int cycleWaypoints();
|
|
|
|
|
2023-01-18 11:49:09 -06:00
|
|
|
void set_desired_compass_heading( double compass_heading);
|
|
|
|
|
|
|
|
void calc_total_force( double (&F_total_body)[2]);
|
|
|
|
void calc_drag_force( double (&F_drag_body)[2]);
|
|
|
|
void calc_thrust_force(double (&F_thrust_body)[2]);
|
|
|
|
void calc_turning_force(double (&F_turning_body)[2]);
|
|
|
|
void rotateBodyToWorld(double (&F_total_world)[2], double (&F_total_body)[2] );
|
|
|
|
};
|
|
|
|
|
|
|
|
double psiToCompass( double psi );
|
|
|
|
double compassToPsi( double compass_heading );
|
|
|
|
double northWestToPsi (double (&p)[2]) ;
|
|
|
|
double vector_magnitude(double (&vector)[2]);
|
|
|
|
void vector_difference(double (&result)[2], double (&A)[2], double (&B)[2] );
|
|
|
|
//
|
|
|
|
|
|
|
|
#endif
|