2003-03-10 14:09:43 +00:00
|
|
|
// gps.hxx - distance-measuring equipment.
|
|
|
|
// Written by David Megginson, started 2003.
|
|
|
|
//
|
|
|
|
// This file is in the Public Domain and comes with no warranty.
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __INSTRUMENTS_GPS_HXX
|
|
|
|
#define __INSTRUMENTS_GPS_HXX 1
|
|
|
|
|
2003-05-06 23:46:24 +00:00
|
|
|
#include <simgear/props/props.hxx>
|
2003-09-24 17:20:55 +00:00
|
|
|
#include <simgear/structure/subsystem_mgr.hxx>
|
2008-12-09 08:10:33 +00:00
|
|
|
#include <simgear/math/SGMath.hxx>
|
|
|
|
|
|
|
|
// forward decls
|
|
|
|
class SGRoute;
|
2003-03-10 14:09:43 +00:00
|
|
|
|
2008-12-09 08:10:33 +00:00
|
|
|
class SGGeodProperty
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SGGeodProperty()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void init(SGPropertyNode* base, const char* lonStr, const char* latStr, const char* altStr = NULL);
|
|
|
|
void init(const char* lonStr, const char* latStr, const char* altStr = NULL);
|
|
|
|
void clear();
|
|
|
|
void operator=(const SGGeod& geod);
|
|
|
|
SGGeod get() const;
|
|
|
|
private:
|
|
|
|
SGPropertyNode_ptr _lon, _lat, _alt;
|
|
|
|
};
|
2003-03-10 14:09:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Model a GPS radio.
|
|
|
|
*
|
|
|
|
* Input properties:
|
|
|
|
*
|
|
|
|
* /position/longitude-deg
|
|
|
|
* /position/latitude-deg
|
|
|
|
* /position/altitude-ft
|
|
|
|
* /environment/magnetic-variation-deg
|
|
|
|
* /systems/electrical/outputs/gps
|
|
|
|
* /instrumentation/gps/serviceable
|
2004-03-15 19:23:39 +00:00
|
|
|
*
|
|
|
|
* /instrumentation/gps/wp-longitude-deg
|
|
|
|
* /instrumentation/gps/wp-latitude-deg
|
2004-05-01 09:40:09 +00:00
|
|
|
* /instrumentation/gps/wp-altitude-ft
|
2004-03-15 19:23:39 +00:00
|
|
|
* /instrumentation/gps/wp-ID
|
|
|
|
* /instrumentation/gps/wp-name
|
2004-04-16 22:12:26 +00:00
|
|
|
* /instrumentation/gps/desired-course-deg
|
2004-03-15 19:23:39 +00:00
|
|
|
* /instrumentation/gps/get-nearest-airport
|
|
|
|
* /instrumentation/gps/waypoint-type
|
2004-04-16 22:12:26 +00:00
|
|
|
* /instrumentation/gps/tracking-bug
|
2003-03-10 14:09:43 +00:00
|
|
|
*
|
|
|
|
* Output properties:
|
|
|
|
*
|
2004-03-23 02:44:24 +00:00
|
|
|
* /instrumentation/gps/indicated-longitude-deg
|
|
|
|
* /instrumentation/gps/indicated-latitude-deg
|
|
|
|
* /instrumentation/gps/indicated-altitude-ft
|
2004-05-01 09:40:09 +00:00
|
|
|
* /instrumentation/gps/indicated-vertical-speed-fpm
|
2004-03-23 02:44:24 +00:00
|
|
|
* /instrumentation/gps/indicated-track-true-deg
|
|
|
|
* /instrumentation/gps/indicated-track-magnetic-deg
|
|
|
|
* /instrumentation/gps/indicated-ground-speed-kt
|
2004-03-15 19:23:39 +00:00
|
|
|
*
|
2004-04-16 22:12:26 +00:00
|
|
|
* /instrumentation/gps/wp-distance-nm
|
2004-03-15 19:23:39 +00:00
|
|
|
* /instrumentation/gps/wp-bearing-deg
|
2004-04-16 22:12:26 +00:00
|
|
|
* /instrumentation/gps/wp-bearing-mag-deg
|
2004-03-15 19:23:39 +00:00
|
|
|
* /instrumentation/gps/TTW
|
|
|
|
* /instrumentation/gps/course-deviation-deg
|
|
|
|
* /instrumentation/gps/course-error-nm
|
|
|
|
* /instrumentation/gps/to-flag
|
|
|
|
* /instrumentation/gps/odometer
|
|
|
|
* /instrumentation/gps/trip-odometer
|
2004-04-16 22:12:26 +00:00
|
|
|
* /instrumentation/gps/true-bug-error-deg
|
|
|
|
* /instrumentation/gps/magnetic-bug-error-deg
|
2004-05-01 09:40:09 +00:00
|
|
|
* /instrumentation/gps/true-bearing-error-deg
|
|
|
|
* /instrumentation/gps/magnetic-bearing-error-deg
|
2003-03-10 14:09:43 +00:00
|
|
|
*/
|
2003-09-24 17:20:55 +00:00
|
|
|
class GPS : public SGSubsystem
|
2003-03-10 14:09:43 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-10-16 12:37:39 +00:00
|
|
|
GPS (SGPropertyNode *node);
|
2003-03-10 14:09:43 +00:00
|
|
|
GPS ();
|
|
|
|
virtual ~GPS ();
|
|
|
|
|
|
|
|
virtual void init ();
|
|
|
|
virtual void update (double delta_time_sec);
|
|
|
|
|
|
|
|
private:
|
2008-12-09 08:10:33 +00:00
|
|
|
typedef struct {
|
|
|
|
double dt;
|
|
|
|
SGGeod pos;
|
|
|
|
SGGeod wp0_pos;
|
|
|
|
SGGeod wp1_pos;
|
|
|
|
bool waypoint_changed;
|
|
|
|
double speed_kt;
|
|
|
|
double track1_deg;
|
|
|
|
double track2_deg;
|
|
|
|
double magvar_deg;
|
|
|
|
double wp0_distance;
|
|
|
|
double wp0_course_deg;
|
|
|
|
double wp0_bearing_deg;
|
|
|
|
double wp1_distance;
|
|
|
|
double wp1_course_deg;
|
|
|
|
double wp1_bearing_deg;
|
|
|
|
} UpdateContext;
|
|
|
|
|
|
|
|
void search (double frequency, const SGGeod& pos);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* reset all output properties to default / non-service values
|
|
|
|
*/
|
|
|
|
void clearOutput();
|
|
|
|
|
|
|
|
void updateWithValid(UpdateContext& ctx);
|
|
|
|
|
|
|
|
void updateNearestAirport(UpdateContext& ctx);
|
|
|
|
void updateWaypoint0(UpdateContext& ctx);
|
|
|
|
void updateWaypoint1(UpdateContext& ctx);
|
|
|
|
|
|
|
|
void updateLegCourse(UpdateContext& ctx);
|
|
|
|
void updateWaypoint0Course(UpdateContext& ctx);
|
|
|
|
void updateWaypoint1Course(UpdateContext& ctx);
|
|
|
|
|
|
|
|
void waypointChanged(UpdateContext& ctx);
|
|
|
|
void updateTTWNode(UpdateContext& ctx, double distance_m, SGPropertyNode_ptr node);
|
|
|
|
void updateTrackingBug(UpdateContext& ctx);
|
|
|
|
|
2003-03-10 14:09:43 +00:00
|
|
|
SGPropertyNode_ptr _magvar_node;
|
|
|
|
SGPropertyNode_ptr _serviceable_node;
|
|
|
|
SGPropertyNode_ptr _electrical_node;
|
2004-05-01 09:40:09 +00:00
|
|
|
SGPropertyNode_ptr _wp0_ID_node;
|
|
|
|
SGPropertyNode_ptr _wp0_name_node;
|
|
|
|
SGPropertyNode_ptr _wp0_course_node;
|
2004-03-15 19:23:39 +00:00
|
|
|
SGPropertyNode_ptr _get_nearest_airport_node;
|
2004-05-01 09:40:09 +00:00
|
|
|
SGPropertyNode_ptr _wp1_ID_node;
|
|
|
|
SGPropertyNode_ptr _wp1_name_node;
|
|
|
|
SGPropertyNode_ptr _wp1_course_node;
|
2004-04-16 22:12:26 +00:00
|
|
|
SGPropertyNode_ptr _tracking_bug_node;
|
2003-03-10 14:09:43 +00:00
|
|
|
|
|
|
|
SGPropertyNode_ptr _raim_node;
|
2004-05-01 09:40:09 +00:00
|
|
|
SGPropertyNode_ptr _indicated_vertical_speed_node;
|
2003-03-10 14:09:43 +00:00
|
|
|
SGPropertyNode_ptr _true_track_node;
|
|
|
|
SGPropertyNode_ptr _magnetic_track_node;
|
|
|
|
SGPropertyNode_ptr _speed_node;
|
2004-05-01 09:40:09 +00:00
|
|
|
SGPropertyNode_ptr _wp0_distance_node;
|
|
|
|
SGPropertyNode_ptr _wp0_ttw_node;
|
|
|
|
SGPropertyNode_ptr _wp0_bearing_node;
|
|
|
|
SGPropertyNode_ptr _wp0_mag_bearing_node;
|
|
|
|
SGPropertyNode_ptr _wp0_course_deviation_node;
|
|
|
|
SGPropertyNode_ptr _wp0_course_error_nm_node;
|
|
|
|
SGPropertyNode_ptr _wp0_to_flag_node;
|
|
|
|
SGPropertyNode_ptr _wp1_distance_node;
|
|
|
|
SGPropertyNode_ptr _wp1_ttw_node;
|
|
|
|
SGPropertyNode_ptr _wp1_bearing_node;
|
|
|
|
SGPropertyNode_ptr _wp1_mag_bearing_node;
|
|
|
|
SGPropertyNode_ptr _wp1_course_deviation_node;
|
|
|
|
SGPropertyNode_ptr _wp1_course_error_nm_node;
|
|
|
|
SGPropertyNode_ptr _wp1_to_flag_node;
|
2004-03-15 19:23:39 +00:00
|
|
|
SGPropertyNode_ptr _odometer_node;
|
|
|
|
SGPropertyNode_ptr _trip_odometer_node;
|
2004-04-16 22:12:26 +00:00
|
|
|
SGPropertyNode_ptr _true_bug_error_node;
|
|
|
|
SGPropertyNode_ptr _magnetic_bug_error_node;
|
2004-05-01 09:40:09 +00:00
|
|
|
SGPropertyNode_ptr _true_wp0_bearing_error_node;
|
|
|
|
SGPropertyNode_ptr _magnetic_wp0_bearing_error_node;
|
|
|
|
SGPropertyNode_ptr _true_wp1_bearing_error_node;
|
|
|
|
SGPropertyNode_ptr _magnetic_wp1_bearing_error_node;
|
|
|
|
SGPropertyNode_ptr _leg_distance_node;
|
|
|
|
SGPropertyNode_ptr _leg_course_node;
|
|
|
|
SGPropertyNode_ptr _leg_magnetic_course_node;
|
|
|
|
SGPropertyNode_ptr _alt_dist_ratio_node;
|
|
|
|
SGPropertyNode_ptr _leg_course_deviation_node;
|
|
|
|
SGPropertyNode_ptr _leg_course_error_nm_node;
|
|
|
|
SGPropertyNode_ptr _leg_to_flag_node;
|
|
|
|
SGPropertyNode_ptr _alt_deviation_node;
|
2003-03-10 14:09:43 +00:00
|
|
|
|
|
|
|
bool _last_valid;
|
2008-12-09 08:10:33 +00:00
|
|
|
SGGeod _last_pos;
|
2004-03-15 19:23:39 +00:00
|
|
|
double _last_speed_kts;
|
|
|
|
|
2008-12-09 08:10:33 +00:00
|
|
|
std::string _last_wp0_ID;
|
|
|
|
std::string _last_wp1_ID;
|
2004-05-01 09:40:09 +00:00
|
|
|
|
|
|
|
double _alt_dist_ratio;
|
|
|
|
double _distance_m;
|
|
|
|
double _course_deg;
|
|
|
|
|
2006-12-06 22:11:43 +00:00
|
|
|
double _bias_length;
|
|
|
|
double _bias_angle;
|
|
|
|
double _azimuth_error;
|
|
|
|
double _range_error;
|
|
|
|
double _elapsed_time;
|
|
|
|
|
2008-12-09 08:10:33 +00:00
|
|
|
std::string _name;
|
2006-12-06 22:11:43 +00:00
|
|
|
int _num;
|
2004-10-16 12:37:39 +00:00
|
|
|
|
2008-12-09 08:10:33 +00:00
|
|
|
SGGeodProperty _position;
|
|
|
|
SGGeodProperty _wp0_position;
|
|
|
|
SGGeodProperty _wp1_position;
|
|
|
|
SGGeodProperty _indicated_pos;
|
2003-03-10 14:09:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // __INSTRUMENTS_GPS_HXX
|