Melchior FRANZ:
_course_deg is first initialized in the if()-branch (gps.cxx:419). But this branch isn't entered at first run if wp0==wp1, so that in line 615 fgfs tries to SG_NORMALIZE_RANGE() a random value, which can take a long while if the number huge. This was occasionally a number greater than 10160! - initialize all vars before they are used (fixes endless loop) - fix some compiler warnings (initialization order, unused vars)
This commit is contained in:
parent
d3bdc4e7bc
commit
28fe28ec4f
4 changed files with 29 additions and 11 deletions
|
@ -46,10 +46,10 @@ static double altitude_data[][2] = {
|
||||||
|
|
||||||
|
|
||||||
Altimeter::Altimeter ( SGPropertyNode *node )
|
Altimeter::Altimeter ( SGPropertyNode *node )
|
||||||
: _altitude_table(new SGInterpTable),
|
: name("altimeter"),
|
||||||
name("altimeter"),
|
|
||||||
num(0),
|
num(0),
|
||||||
static_port("/systems/static")
|
static_port("/systems/static"),
|
||||||
|
_altitude_table(new SGInterpTable)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; altitude_data[i][0] != -1; i++)
|
for (i = 0; altitude_data[i][0] != -1; i++)
|
||||||
|
|
|
@ -62,10 +62,10 @@ int round (double value, int nearest=1)
|
||||||
|
|
||||||
Encoder::Encoder(SGPropertyNode *node)
|
Encoder::Encoder(SGPropertyNode *node)
|
||||||
:
|
:
|
||||||
altitudeTable(new SGInterpTable),
|
|
||||||
name("encoder"),
|
name("encoder"),
|
||||||
num(0),
|
num(0),
|
||||||
staticPort("/systems/static")
|
staticPort("/systems/static"),
|
||||||
|
altitudeTable(new SGInterpTable)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for ( i = 0; altitude_data[i][0] != -1; i++ )
|
for ( i = 0; altitude_data[i][0] != -1; i++ )
|
||||||
|
|
|
@ -32,7 +32,16 @@ GPS::GPS ( SGPropertyNode *node)
|
||||||
_last_longitude_deg(0),
|
_last_longitude_deg(0),
|
||||||
_last_latitude_deg(0),
|
_last_latitude_deg(0),
|
||||||
_last_altitude_m(0),
|
_last_altitude_m(0),
|
||||||
_last_speed_kts(0)
|
_last_speed_kts(0),
|
||||||
|
_wp0_latitude_deg(0),
|
||||||
|
_wp0_longitude_deg(0),
|
||||||
|
_wp0_altitude_m(0),
|
||||||
|
_wp1_latitude_deg(0),
|
||||||
|
_wp1_longitude_deg(0),
|
||||||
|
_wp1_altitude_m(0),
|
||||||
|
_alt_dist_ratio(0),
|
||||||
|
_distance_m(0),
|
||||||
|
_course_deg(0)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for ( i = 0; i < node->nChildren(); ++i ) {
|
for ( i = 0; i < node->nChildren(); ++i ) {
|
||||||
|
@ -57,7 +66,16 @@ GPS::GPS ()
|
||||||
_last_longitude_deg(0),
|
_last_longitude_deg(0),
|
||||||
_last_latitude_deg(0),
|
_last_latitude_deg(0),
|
||||||
_last_altitude_m(0),
|
_last_altitude_m(0),
|
||||||
_last_speed_kts(0)
|
_last_speed_kts(0),
|
||||||
|
_wp0_latitude_deg(0),
|
||||||
|
_wp0_longitude_deg(0),
|
||||||
|
_wp0_altitude_m(0),
|
||||||
|
_wp1_latitude_deg(0),
|
||||||
|
_wp1_longitude_deg(0),
|
||||||
|
_wp1_altitude_m(0),
|
||||||
|
_alt_dist_ratio(0),
|
||||||
|
_distance_m(0),
|
||||||
|
_course_deg(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +108,7 @@ GPS::init ()
|
||||||
|
|
||||||
_wp0_longitude_node = wp0_node->getChild("longitude-deg", 0, true);
|
_wp0_longitude_node = wp0_node->getChild("longitude-deg", 0, true);
|
||||||
_wp0_latitude_node = wp0_node->getChild("latitude-deg", 0, true);
|
_wp0_latitude_node = wp0_node->getChild("latitude-deg", 0, true);
|
||||||
_wp0_altitude_node = wp0_node->getChild("altitude-deg", 0, true);
|
_wp0_altitude_node = wp0_node->getChild("altitude-ft", 0, true);
|
||||||
_wp0_ID_node = wp0_node->getChild("ID", 0, true);
|
_wp0_ID_node = wp0_node->getChild("ID", 0, true);
|
||||||
_wp0_name_node = wp0_node->getChild("name", 0, true);
|
_wp0_name_node = wp0_node->getChild("name", 0, true);
|
||||||
_wp0_course_node = wp0_node->getChild("desired-course-deg", 0, true);
|
_wp0_course_node = wp0_node->getChild("desired-course-deg", 0, true);
|
||||||
|
@ -110,7 +128,7 @@ GPS::init ()
|
||||||
|
|
||||||
_wp1_longitude_node = wp1_node->getChild("longitude-deg", 0, true);
|
_wp1_longitude_node = wp1_node->getChild("longitude-deg", 0, true);
|
||||||
_wp1_latitude_node = wp1_node->getChild("latitude-deg", 0, true);
|
_wp1_latitude_node = wp1_node->getChild("latitude-deg", 0, true);
|
||||||
_wp1_altitude_node = wp1_node->getChild("altitude-deg", 0, true);
|
_wp1_altitude_node = wp1_node->getChild("altitude-ft", 0, true);
|
||||||
_wp1_ID_node = wp1_node->getChild("ID", 0, true);
|
_wp1_ID_node = wp1_node->getChild("ID", 0, true);
|
||||||
_wp1_name_node = wp1_node->getChild("name", 0, true);
|
_wp1_name_node = wp1_node->getChild("name", 0, true);
|
||||||
_wp1_course_node = wp1_node->getChild("desired-course-deg", 0, true);
|
_wp1_course_node = wp1_node->getChild("desired-course-deg", 0, true);
|
||||||
|
|
|
@ -86,7 +86,7 @@ MagCompass::update (double delta_time_sec)
|
||||||
// This is the real magnetic
|
// This is the real magnetic
|
||||||
// which would be displayed
|
// which would be displayed
|
||||||
// if the compass had no errors.
|
// if the compass had no errors.
|
||||||
double heading_mag_deg = _heading_node->getDoubleValue();
|
//double heading_mag_deg = _heading_node->getDoubleValue();
|
||||||
|
|
||||||
|
|
||||||
// don't update if the compass
|
// don't update if the compass
|
||||||
|
@ -146,7 +146,7 @@ MagCompass::update (double delta_time_sec)
|
||||||
*/
|
*/
|
||||||
double x_accel_g = _x_accel_node->getDoubleValue() / 32;
|
double x_accel_g = _x_accel_node->getDoubleValue() / 32;
|
||||||
double y_accel_g = _y_accel_node->getDoubleValue() / 32;
|
double y_accel_g = _y_accel_node->getDoubleValue() / 32;
|
||||||
double z_accel_g = _z_accel_node->getDoubleValue() / 32;
|
//double z_accel_g = _z_accel_node->getDoubleValue() / 32;
|
||||||
|
|
||||||
theta -= 0.07 * x_accel_g;
|
theta -= 0.07 * x_accel_g;
|
||||||
phi -= 0.07 * y_accel_g;
|
phi -= 0.07 * y_accel_g;
|
||||||
|
|
Loading…
Reference in a new issue