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 float volts_raw; /* raw volt reading */
69 float volts; /* filtered volts */
70 uint32_t est_seconds; /* estimated useful seconds remaining */
71 uint32_t loadavg; /* system "1 minute" load average */
72 uint32_t ahrs_hz; /* actual ahrs loop hz */
73 uint32_t nav_hz; /* actual nav loop hz */
76 // Manage a saved ugear log (track file)
81 vector <gps> gps_data;
82 vector <imu> imu_data;
83 vector <nav> nav_data;
84 vector <servo> servo_data;
85 vector <health> health_data;
87 // parse message and put current data into vector if message has a
88 // newer time stamp than existing data.
89 void parse_msg( const int id, char *buf,
90 gps *gpspacket, imu *imupacket, nav *navpacket,
91 servo *servopacket, health *healthpacket );
93 // activate special double swap logic for non-standard stargate
102 // read/parse the next message from the specified data stream,
103 // returns id # if a valid message found.
104 int next_message( SGIOChannel *ch, SGIOChannel *log,
105 gps *gpspacket, imu *imupacket, nav *navpacket,
106 servo *servopacket, health * healthpacket,
107 bool ignore_checksum );
108 int next_message( SGSerialPort *serial, SGIOChannel *log,
109 gps *gpspacket, imu *imupacket, nav *navpacket,
110 servo *servopacket, health *healthpacket,
111 bool ignore_checksum );
113 // load the named stream log file into internal buffers
114 bool load_stream( const string &file, bool ignore_checksum );
116 // load the named flight files into internal buffers
117 bool load_flight( const string &path );
119 inline int gps_size() const { return gps_data.size(); }
120 inline int imu_size() const { return imu_data.size(); }
121 inline int nav_size() const { return nav_data.size(); }
122 inline int servo_size() const { return servo_data.size(); }
123 inline int health_size() const { return health_data.size(); }
125 inline gps get_gpspt( const unsigned int i )
127 if ( i < gps_data.size() ) {
133 inline imu get_imupt( const unsigned int i )
135 if ( i < imu_data.size() ) {
141 inline nav get_navpt( const unsigned int i )
143 if ( i < nav_data.size() ) {
149 inline servo get_servopt( const unsigned int i )
151 if ( i < servo_data.size() ) {
152 return servo_data[i];
157 inline health get_healthpt( const unsigned int i )
159 if ( i < health_data.size() ) {
160 return health_data[i];
167 // set stargate mode where we have to do an odd swapping of doubles to
168 // account for their non-standard formate
169 inline void set_stargate_swap_mode() {
175 gps UGEARInterpGPS( const gps A, const gps B, const double percent );
176 imu UGEARInterpIMU( const imu A, const imu B, const double percent );
177 nav UGEARInterpNAV( const nav A, const nav B, const double percent );
178 servo UGEARInterpSERVO( const servo A, const servo B, const double percent );
179 health UGEARInterpHEALTH( const health A, const health B,
180 const double percent );
183 #endif // _FG_UGEAR_II_HXX