78 lowpass::set_delta(dt);
79 double time_step = dt;
87 if (brake_left > 0.5 || brake_right > 0.5)
90 double velocity = Throttle->filter(
throttle) * Speed_Max->getDoubleValue();
94 double aileron = Aileron->filter(ctrl->
get_aileron());
95 double elevator = Elevator->filter(ctrl->
get_elevator());
96 double rudder = Rudder->filter(ctrl->
get_rudder());
103 double pitch_rate = SGD_PI_4;
104 double target_pitch = -elevator * SGD_PI_2;
106 if (old_pitch > target_pitch)
109 double pitch = old_pitch + (pitch_rate * time_step);
111 if (pitch_rate > 0.0) {
112 if (pitch > target_pitch)
113 pitch = target_pitch;
115 }
else if (pitch_rate < 0.0) {
116 if (pitch < target_pitch)
117 pitch = target_pitch;
121 double roll_rate = SGD_PI_4;
122 double target_roll = aileron * SGD_PI_2;
124 if (old_roll > target_roll)
127 double roll = old_roll + (roll_rate * time_step);
129 if (roll_rate > 0.0) {
130 if (roll > target_roll)
133 }
else if (roll_rate < 0.0) {
134 if (roll < target_roll)
139 double real_climb_rate = sin (pitch) * SG_METER_TO_FEET * velocity;
141 double climb = real_climb_rate * time_step;
144 double speed = cos (pitch) * velocity;
145 double dist = speed * time_step;
146 double kts = velocity * SG_METER_TO_NM * 3600.0;
152 double turn_rate = sin(roll) * SGD_PI_4;
153 double turn = turn_rate * time_step;
154 double yaw = fabs(rudder) < .05 ? 0.0 : (rudder * (fabs(rudder) - 0.05) / 10);
157 double lat2 = 0.0, lon2 = 0.0, az2 = 0.0;
158 if ( fabs(speed) > SG_EPSILON ) {
162 get_Psi() * SGD_RADIANS_TO_DEGREES,
163 dist, &lat2, &lon2, &az2 );
176 double heading = SGMiscd::normalizePeriodic(0, SGD_2PI,
get_Psi() + turn + yaw );
189 set_V_north(cos(heading) * velocity * SG_METER_TO_FEET);
190 set_V_east(sin(heading) * velocity * SG_METER_TO_FEET);