38 branch =
"/instrumentation/" + _name;
40 SGPropertyNode *node =
fgGetNode(branch, _num,
true );
41 if( NULL == (_offset_node = node->getChild(
"offset-deg", 0,
false)) ) {
42 _offset_node = node->getChild(
"offset-deg", 0,
true);
43 _offset_node->setDoubleValue( -
fgGetDouble(
"/environment/magnetic-variation-deg") );
45 _heading_in_node =
fgGetNode(
"/orientation/heading-deg",
true);
46 _suction_node =
fgGetNode(_suction,
true);
47 _heading_out_node = node->getChild(
"indicated-heading-deg", 0,
true);
48 _heading_bug_error_node = node->getChild(
"heading-bug-error-deg", 0,
true);
49 _heading_bug_node = node->getChild(
"heading-bug-deg", 0,
true);
92 _gyro.set_power_norm(_suction_node->getDoubleValue()/5.0);
94 double spin = _gyro.get_spin_norm();
97 double offset = _offset_node->getDoubleValue();
98 offset -= dt * (0.25 / 60.0);
99 SG_NORMALIZE_RANGE(offset, -360.0, 360.0);
105 double factor = 100 * (spin * spin * spin * spin * spin * spin);
106 double heading = _heading_in_node->getDoubleValue();
111 while ((heading - _last_heading_deg) > 180)
112 _last_heading_deg += 360;
113 while ((heading - _last_heading_deg) < -180)
114 _last_heading_deg -= 360;
116 heading =
fgGetLowPass(_last_heading_deg, heading, dt * factor);
117 _last_heading_deg = heading;
120 SG_NORMALIZE_RANGE(heading, 0.0, 360.0);
122 _heading_out_node->setDoubleValue(heading);
125 double heading_bug = _heading_bug_node->getDoubleValue();
126 double diff = heading_bug - heading;
128 SG_NORMALIZE_RANGE(diff, -180.0, 180.0);
129 _heading_bug_error_node->setDoubleValue( diff );
void fgTie(const char *name, V(*getter)(), void(*setter)(V)=0, bool useDefault=true)
Tie a property to a pair of simple functions.