49 SGPropertyNode *node =
fgGetNode(branch,
true );
52 _pitch_in_node =
fgGetNode(
"/orientation/pitch-deg",
true);
53 _roll_in_node =
fgGetNode(
"/orientation/roll-deg",
true);
54 SGPropertyNode *cnode = node->getChild(
"config", 0,
true);
55 _tumble_flag_node = cnode->getChild(
"tumble-flag", 0,
true);
56 _caged_node = node->getChild(
"caged-flag", 0,
true);
57 _tumble_node = node->getChild(
"tumble-norm", 0,
true);
58 if( ( n = cnode->getChild(
"spin-thresh", 0,
false ) ) != NULL )
59 spin_thresh = n->getDoubleValue();
60 if( ( n = cnode->getChild(
"max-roll-error-deg", 0,
false ) ) != NULL )
61 max_roll_error = n->getDoubleValue();
62 if( ( n = cnode->getChild(
"max-pitch-error-deg", 0,
false ) ) != NULL )
63 max_pitch_error = n->getDoubleValue();
64 _pitch_int_node = node->getChild(
"internal-pitch-deg", 0,
true);
65 _roll_int_node = node->getChild(
"internal-roll-deg", 0,
true);
66 _pitch_out_node = node->getChild(
"indicated-pitch-deg", 0,
true);
67 _roll_out_node = node->getChild(
"indicated-roll-deg", 0,
true);
68 _off_node = node->getChild(
"off-flag", 0,
true);
69 _spin_node = node->getChild(
"spin", 0,
true);
71 SGPropertyNode* gyro_node = node->getChild(
"gyro", 0,
true);
72 _gyro_spin_up_node = gyro_node->getChild(
"spin-up-sec", 0,
true);
73 _gyro_spin_down_node = gyro_node->getChild(
"spin-down-sec", 0,
true);
74 if (!_gyro_spin_up_node->hasValue())
75 _gyro_spin_up_node->setDoubleValue(_gyro_spin_up);
76 if (!_gyro_spin_down_node->hasValue())
77 _gyro_spin_down_node->setDoubleValue(_gyro_spin_down);
96 if (_caged_node->getBoolValue()) {
97 _roll_int_node->setDoubleValue(0.0);
98 _pitch_int_node->setDoubleValue(0.0);
104 _gyro.set_spin_up(_gyro_spin_up_node->getDoubleValue());
105 _gyro.set_spin_down(_gyro_spin_down_node->getDoubleValue());
106 _gyro.set_spin_norm(_spin_node->getDoubleValue());
108 double spin = _gyro.get_spin_norm();
109 _spin_node->setDoubleValue( spin );
114 double responsiveness = spin * spin * spin * spin * spin * spin;
117 double roll = _roll_in_node->getDoubleValue();
118 double pitch = _pitch_in_node->getDoubleValue();
122 if (_tumble_flag_node->getBoolValue()) {
123 double tumble = _tumble_node->getDoubleValue();
124 if (fabs(roll) > 45.0) {
125 double target = (fabs(roll) - 45.0) / 45.0;
130 if (fabs(target) > fabs(tumble))
135 else if (tumble < -1.0)
139 double step = dt/300.0;
142 else if (tumble > step)
146 _tumble_node->setDoubleValue(tumble);
149 roll =
fgGetLowPass(_roll_int_node->getDoubleValue(), roll,
151 pitch =
fgGetLowPass(_pitch_int_node->getDoubleValue(), pitch,
155 _roll_int_node->setDoubleValue(roll);
156 _pitch_int_node->setDoubleValue(pitch);
161 if ( spin <= spin_thresh ) {
162 double roll_error_factor = (spin_thresh - spin) / spin_thresh;
163 double pitch_error_factor = (spin_thresh - spin) / spin_thresh;
164 roll_error = roll_error_factor * roll_error_factor * max_roll_error;
165 pitch_error = pitch_error_factor * pitch_error_factor * max_pitch_error;
171 _roll_out_node->setDoubleValue(roll + roll_error);
172 _pitch_out_node->setDoubleValue(pitch + pitch_error);