1 #ifndef _FG_UGEAR_II_HXX
2 #define _FG_UGEAR_II_HXX
9 #include <simgear/compiler.h>
15 #include <simgear/misc/stdint.hxx>
16 #include <simgear/io/iochannel.hxx>
17 #include <simgear/serial/serial.hxx>
35 double p,q,r; /* angular velocities */
36 double ax,ay,az; /* acceleration */
37 double hx,hy,hz; /* magnetic field */
38 double Ps,Pt; /* static/pitot pressure */
39 // double Tx,Ty,Tz; /* temperature */
40 double phi,the,psi; /* attitudes */
41 uint64_t err_type; /* error type */
46 double lat,lon,alt; /* gps position */
47 double ve,vn,vd; /* gps velocity */
49 uint64_t err_type; /* error type */
68 double target_roll_deg; /* AP target roll angle */
69 double target_heading_deg; /* AP target heading angle */
70 double target_pitch_deg; /* AP target pitch angle */
71 double target_climb_fps; /* AP target climb rate */
72 double target_altitude_ft; /* AP target altitude */
73 uint64_t command_sequence; /* highest received command sequence num */
74 uint64_t target_waypoint; /* index of current waypoint target */
75 uint64_t loadavg; /* system "1 minute" load average */
76 uint64_t ahrs_hz; /* actual ahrs loop hz */
77 uint64_t nav_hz; /* actual nav loop hz */
80 // Manage a saved ugear log (track file)
85 vector <gps> gps_data;
86 vector <imu> imu_data;
87 vector <nav> nav_data;
88 vector <servo> servo_data;
89 vector <health> health_data;
91 // parse message and put current data into vector if message has a
92 // newer time stamp than existing data.
93 void parse_msg( const int id, char *buf,
94 gps *gpspacket, imu *imupacket, nav *navpacket,
95 servo *servopacket, health *healthpacket );
97 // activate special double swap logic for non-standard stargate
106 // read/parse the next message from the specified data stream,
107 // returns id # if a valid message found.
108 int next_message( SGIOChannel *ch, SGIOChannel *log,
109 gps *gpspacket, imu *imupacket, nav *navpacket,
110 servo *servopacket, health * healthpacket,
111 bool ignore_checksum );
112 int next_message( SGSerialPort *serial, SGIOChannel *log,
113 gps *gpspacket, imu *imupacket, nav *navpacket,
114 servo *servopacket, health *healthpacket,
115 bool ignore_checksum );
117 // load the named stream log file into internal buffers
118 bool load_stream( const string &file, bool ignore_checksum );
120 // load the named flight files into internal buffers
121 bool load_flight( const string &path );
123 inline int gps_size() const { return gps_data.size(); }
124 inline int imu_size() const { return imu_data.size(); }
125 inline int nav_size() const { return nav_data.size(); }
126 inline int servo_size() const { return servo_data.size(); }
127 inline int health_size() const { return health_data.size(); }
129 inline gps get_gpspt( const unsigned int i )
131 if ( i < gps_data.size() ) {
137 inline imu get_imupt( const unsigned int i )
139 if ( i < imu_data.size() ) {
145 inline nav get_navpt( const unsigned int i )
147 if ( i < nav_data.size() ) {
153 inline servo get_servopt( const unsigned int i )
155 if ( i < servo_data.size() ) {
156 return servo_data[i];
161 inline health get_healthpt( const unsigned int i )
163 if ( i < health_data.size() ) {
164 return health_data[i];
171 // set stargate mode where we have to do an odd swapping of doubles to
172 // account for their non-standard formate
173 inline void set_stargate_swap_mode() {
179 gps UGEARInterpGPS( const gps A, const gps B, const double percent );
180 imu UGEARInterpIMU( const imu A, const imu B, const double percent );
181 nav UGEARInterpNAV( const nav A, const nav B, const double percent );
182 servo UGEARInterpSERVO( const servo A, const servo B, const double percent );
183 health UGEARInterpHEALTH( const health A, const health B,
184 const double percent );
187 #endif // _FG_UGEAR_II_HXX