1 // newauto.cxx -- autopilot defines and prototypes (very alpha)
3 // Started April 1998 Copyright (C) 1998
5 // Contributions by Jeff Goeke-Smith <jgoeke@voyager.net>
6 // Norman Vine <nhv@cape.com>
7 // Curtis Olson <curt@flightgear.org>
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // General Public License for more details.
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #include <stdio.h> // sprintf()
32 #include <simgear/constants.h>
33 #include <simgear/debug/logstream.hxx>
34 #include <simgear/math/fg_geodesy.hxx>
36 #include <Controls/controls.hxx>
37 #include <FDM/flight.hxx>
38 #include <Main/bfi.hxx>
39 #include <Main/options.hxx>
40 #include <Scenery/scenery.hxx>
42 #include "newauto.hxx"
45 FGAutopilot *current_autopilot;
48 // Climb speed constants
49 const double min_climb = 70.0; // kts
50 const double best_climb = 75.0; // kts
51 const double ideal_climb_rate = 500.0; // fpm
53 /// These statics will eventually go into the class
54 /// they are just here while I am experimenting -- NHV :-)
55 // AutoPilot Gain Adjuster members
56 static double MaxRollAdjust; // MaxRollAdjust = 2 * APData->MaxRoll;
57 static double RollOutAdjust; // RollOutAdjust = 2 * APData->RollOut;
58 static double MaxAileronAdjust; // MaxAileronAdjust = 2 * APData->MaxAileron;
59 static double RollOutSmoothAdjust; // RollOutSmoothAdjust = 2 * APData->RollOutSmooth;
62 static float MaxRollValue; // 0.1 -> 1.0
63 static float RollOutValue;
64 static float MaxAileronValue;
65 static float RollOutSmoothValue;
67 static float TmpMaxRollValue; // for cancel operation
68 static float TmpRollOutValue;
69 static float TmpMaxAileronValue;
70 static float TmpRollOutSmoothValue;
73 static char NewTgtAirportId[16];
74 // static char NewTgtAirportLabel[] = "Enter New TgtAirport ID";
76 extern char *coord_format_lat(float);
77 extern char *coord_format_lon(float);
80 void FGAutopilot::MakeTargetLatLonStr( double lat, double lon ) {
81 sprintf( TargetLatitudeStr , "%s", coord_format_lat(TargetLatitude) );
82 sprintf( TargetLongitudeStr, "%s", coord_format_lon(TargetLongitude) );
83 sprintf( TargetLatLonStr, "%s %s", TargetLatitudeStr, TargetLongitudeStr );
87 void FGAutopilot::MakeTargetAltitudeStr( double altitude ) {
88 if ( altitude_mode == FG_ALTITUDE_TERRAIN ) {
89 sprintf( TargetAltitudeStr, "APAltitude %6.0f+", altitude );
91 sprintf( TargetAltitudeStr, "APAltitude %6.0f", altitude );
96 void FGAutopilot::MakeTargetHeadingStr( double bearing ) {
99 } else if (bearing > 360. ) {
102 sprintf( TargetHeadingStr, "APHeading %6.1f", bearing );
106 void FGAutopilot::update_old_control_values() {
107 old_aileron = FGBFI::getAileron();
108 old_elevator = FGBFI::getElevator();
109 old_elevator_trim = FGBFI::getElevatorTrim();
110 old_rudder = FGBFI::getRudder();
114 // Initialize autopilot subsystem
115 void FGAutopilot::init() {
116 FG_LOG( FG_AUTOPILOT, FG_INFO, "Init AutoPilot Subsystem" );
118 heading_hold = false ; // turn the heading hold off
119 altitude_hold = false ; // turn the altitude hold off
120 auto_throttle = false ; // turn the auto throttle off
122 // Initialize target location to startup location
123 old_lat = TargetLatitude = FGBFI::getLatitude();
124 old_lon = TargetLongitude = FGBFI::getLongitude();
126 MakeTargetLatLonStr( TargetLatitude, TargetLongitude);
128 TargetHeading = 0.0; // default direction, due north
129 TargetAltitude = 3000; // default altitude in meters
130 alt_error_accum = 0.0;
132 MakeTargetAltitudeStr( 3000.0);
133 MakeTargetHeadingStr( 0.0 );
135 // These eventually need to be read from current_aircaft somehow.
137 // the maximum roll, in Deg
140 // the deg from heading to start rolling out at, in Deg
143 // how far can I move the aleron from center.
146 // Smoothing distance for alerion control
149 // Hardwired for now should be in options
150 // 25% max control variablilty 0.5 / 2.0
151 disengage_threshold = 1.0;
153 #if !defined( USING_SLIDER_CLASS )
154 MaxRollAdjust = 2 * MaxRoll;
155 RollOutAdjust = 2 * RollOut;
156 MaxAileronAdjust = 2 * MaxAileron;
157 RollOutSmoothAdjust = 2 * RollOutSmooth;
158 #endif // !defined( USING_SLIDER_CLASS )
160 update_old_control_values();
162 // Initialize GUI components of autopilot
163 // NewTgtAirportInit();
164 // fgAPAdjustInit() ;
166 // NewAltitudeInit();
170 // Reset the autopilot system
171 void FGAutopilot::reset() {
173 heading_hold = false ; // turn the heading hold off
174 altitude_hold = false ; // turn the altitude hold off
175 auto_throttle = false ; // turn the auto throttle off
177 TargetHeading = 0.0; // default direction, due north
178 MakeTargetHeadingStr( TargetHeading );
180 TargetAltitude = 3000; // default altitude in meters
181 MakeTargetAltitudeStr( TargetAltitude );
183 alt_error_accum = 0.0;
185 update_old_control_values();
187 sprintf( NewTgtAirportId, "%s", current_options.get_airport_id().c_str() );
189 TargetLatitude = FGBFI::getLatitude();
190 TargetLongitude = FGBFI::getLongitude();
191 MakeTargetLatLonStr( TargetLatitude, TargetLongitude );
195 static inline double get_speed( void ) {
196 return( cur_fdm_state->get_V_equiv_kts() );
199 static inline double get_ground_speed() {
200 // starts in ft/s so we convert to kts
201 double ft_s = cur_fdm_state->get_V_ground_speed()
202 * current_options.get_speed_up();;
203 double kts = ft_s * FEET_TO_METER * 3600 * METER_TO_NM;
209 void FGAutopilot::MakeTargetDistanceStr( double distance ) {
210 double eta = distance*METER_TO_NM / get_ground_speed();
211 if ( eta >= 100.0 ) { eta = 99.999; }
213 if ( eta < (1.0/6.0) ) {
214 // within 10 minutes, bump up to min/secs
218 minor = (int)((eta - (int)eta) * 60.0);
219 sprintf( TargetDistanceStr, "APDistance %.2f NM ETA %d:%02d",
220 distance*METER_TO_NM, major, minor );
221 // cout << "distance = " << distance*METER_TO_NM
222 // << " gndsp = " << get_ground_speed()
223 // << " time = " << eta
224 // << " major = " << major
225 // << " minor = " << minor
230 static double NormalizeDegrees( double Input ) {
231 // normalize the input to the range (-180,180]
232 // Input should not be greater than -360 to 360.
233 // Current rules send the output to an undefined state.
237 else if ( Input <= -180 )
238 while ( Input <= -180 )
243 static double LinearExtrapolate( double x, double x1, double y1, double x2, double y2 ) {
244 // This procedure extrapolates the y value for the x posistion on a line defined by x1,y1; x2,y2
245 //assert(x1 != x2); // Divide by zero error. Cold abort for now
248 // static double y = 0.0;
249 // double dx = x2 -x1;
250 // if( (dx < -FG_EPSILON ) || ( dx > FG_EPSILON ) )
253 double m, b, y; // the constants to find in y=mx+b
256 m = ( y2 - y1 ) / ( x2 - x1 ); // calculate the m
258 b = y1 - m * x1; // calculate the b
260 y = m * x + b; // the final calculation
269 int FGAutopilot::run() {
270 // Remove the following lines when the calling funcitons start
271 // passing in the data pointer
273 // get control settings
274 // double aileron = FGBFI::getAileron();
275 // double elevator = FGBFI::getElevator();
276 // double elevator_trim = FGBFI::getElevatorTrim();
277 // double rudder = FGBFI::getRudder();
279 double lat = FGBFI::getLatitude();
280 double lon = FGBFI::getLongitude();
282 #ifdef FG_FORCE_AUTO_DISENGAGE
283 // see if somebody else has changed them
284 if( fabs(aileron - old_aileron) > disengage_threshold ||
285 fabs(elevator - old_elevator) > disengage_threshold ||
286 fabs(elevator_trim - old_elevator_trim) >
287 disengage_threshold ||
288 fabs(rudder - old_rudder) > disengage_threshold )
290 // if controls changed externally turn autopilot off
291 waypoint_hold = false ; // turn the target hold off
292 heading_hold = false ; // turn the heading hold off
293 altitude_hold = false ; // turn the altitude hold off
294 terrain_follow = false; // turn the terrain_follow hold off
295 // auto_throttle = false; // turn the auto_throttle off
297 // stash this runs control settings
298 old_aileron = aileron;
299 old_elevator = elevator;
300 old_elevator_trim = elevator_trim;
307 // heading hold enabled?
308 if ( heading_hold == true ) {
310 if ( heading_mode == FG_HEADING_LOCK ) {
311 // leave target heading alone
312 } else if ( heading_mode == FG_HEADING_WAYPOINT ) {
313 // update target heading to waypoint
315 double wp_course, wp_reverse, wp_distance;
317 #ifdef DO_fgAP_CORRECTED_COURSE
318 // compute course made good
319 // this needs lots of special casing before use
320 double course, reverse, distance, corrected_course;
321 // need to test for iter
322 geo_inverse_wgs_84( 0, //fgAPget_altitude(),
330 #endif // DO_fgAP_CORRECTED_COURSE
332 // compute course to way_point
333 // need to test for iter
334 if( ! geo_inverse_wgs_84( 0, //fgAPget_altitude(),
343 #ifdef DO_fgAP_CORRECTED_COURSE
344 corrected_course = course - wp_course;
345 if( fabs(corrected_course) > 0.1 )
346 printf("fgAP: course %f wp_course %f %f %f\n",
347 course, wp_course, fabs(corrected_course),
349 #endif // DO_fgAP_CORRECTED_COURSE
351 if ( wp_distance > 100 ) {
352 // corrected_course = course - wp_course;
353 TargetHeading = NormalizeDegrees(wp_course);
355 printf("distance(%f) to close\n", wp_distance);
356 // Real Close -- set heading hold to current heading
357 // and Ring the arival bell !!
358 heading_mode = FG_HEADING_LOCK;
359 // use current heading
360 TargetHeading = FGBFI::getHeading();
362 MakeTargetHeadingStr( TargetHeading );
363 // Force this just in case
364 TargetDistance = wp_distance;
365 MakeTargetDistanceStr( wp_distance );
374 RelHeading = NormalizeDegrees( TargetHeading - FGBFI::getHeading() );
375 // figure out how far off we are from desired heading
377 // Now it is time to deterime how far we should be rolled.
378 FG_LOG( FG_AUTOPILOT, FG_DEBUG, "RelHeading: " << RelHeading );
381 // Check if we are further from heading than the roll out point
382 if ( fabs( RelHeading ) > RollOut ) {
383 // set Target Roll to Max in desired direction
384 if ( RelHeading < 0 ) {
385 TargetRoll = 0 - MaxRoll;
387 TargetRoll = MaxRoll;
390 // We have to calculate the Target roll
392 // This calculation engine thinks that the Target roll
393 // should be a line from (RollOut,MaxRoll) to (-RollOut,
394 // -MaxRoll) I hope this works well. If I get ambitious
395 // some day this might become a fancier curve or
398 TargetRoll = LinearExtrapolate( RelHeading, -RollOut,
403 // Target Roll has now been Found.
405 // Compare Target roll to Current Roll, Generate Rel Roll
407 FG_LOG( FG_COCKPIT, FG_BULK, "TargetRoll: " << TargetRoll );
409 RelRoll = NormalizeDegrees( TargetRoll - FGBFI::getRoll() );
411 // Check if we are further from heading than the roll out smooth point
412 if ( fabs( RelRoll ) > RollOutSmooth ) {
413 // set Target Roll to Max in desired direction
415 AileronSet = 0 - MaxAileron;
417 AileronSet = MaxAileron;
420 AileronSet = LinearExtrapolate( RelRoll, -RollOutSmooth,
426 controls.set_aileron( AileronSet );
427 controls.set_rudder( AileronSet / 4.0 );
428 // controls.set_rudder( 0.0 );
432 if ( altitude_hold ) {
433 double speed, max_climb, error;
434 double prop_error, int_error;
435 double prop_adj, int_adj, total_adj;
437 if ( altitude_mode == FG_ALTITUDE_LOCK ) {
438 // normal altitude hold
439 // cout << "TargetAltitude = " << TargetAltitude
440 // << "Altitude = " << FGBFI::getAltitude() * FEET_TO_METER
443 ( TargetAltitude - FGBFI::getAltitude() * FEET_TO_METER ) * 8.0;
444 } else if ( altitude_mode == FG_ALTITUDE_TERRAIN ) {
445 // brain dead ground hugging with no look ahead
447 ( TargetAGL - FGBFI::getAGL()*FEET_TO_METER ) * 16.0;
448 // cout << "target agl = " << TargetAGL
449 // << " current agl = " << fgAPget_agl()
450 // << " target climb rate = " << TargetClimbRate
453 // just try to zero out rate of climb ...
454 TargetClimbRate = 0.0;
459 if ( speed < min_climb ) {
461 } else if ( speed < best_climb ) {
462 max_climb = ((best_climb - min_climb) - (best_climb - speed))
464 / (best_climb - min_climb);
466 max_climb = ( speed - best_climb ) * 10.0 + ideal_climb_rate;
469 // this first one could be optional if we wanted to allow
470 // better climb performance assuming we have the airspeed to
472 if ( TargetClimbRate > ideal_climb_rate ) {
473 TargetClimbRate = ideal_climb_rate;
476 if ( TargetClimbRate > max_climb ) {
477 TargetClimbRate = max_climb;
480 if ( TargetClimbRate < -ideal_climb_rate ) {
481 TargetClimbRate = -ideal_climb_rate;
484 error = FGBFI::getVerticalSpeed() * FEET_TO_METER - TargetClimbRate;
485 // cout << "climb rate = " << fgAPget_climb()
486 // << " error = " << error << endl;
488 // accumulate the error under the curve ... this really should
490 alt_error_accum += error;
492 // calculate integral error, and adjustment amount
493 int_error = alt_error_accum;
494 // printf("error = %.2f int_error = %.2f\n", error, int_error);
495 int_adj = int_error / 8000.0;
497 // caclulate proportional error
499 prop_adj = prop_error / 2000.0;
501 total_adj = 0.9 * prop_adj + 0.1 * int_adj;
502 // if ( total_adj > 0.6 ) {
504 // } else if ( total_adj < -0.2 ) {
507 if ( total_adj > 1.0 ) {
509 } else if ( total_adj < -1.0 ) {
513 controls.set_elevator( total_adj );
516 // auto throttle enabled?
517 if ( auto_throttle ) {
519 double prop_error, int_error;
520 double prop_adj, int_adj, total_adj;
522 error = TargetSpeed - get_speed();
524 // accumulate the error under the curve ... this really should
526 speed_error_accum += error;
527 if ( speed_error_accum > 2000.0 ) {
528 speed_error_accum = 2000.0;
530 else if ( speed_error_accum < -2000.0 ) {
531 speed_error_accum = -2000.0;
534 // calculate integral error, and adjustment amount
535 int_error = speed_error_accum;
537 // printf("error = %.2f int_error = %.2f\n", error, int_error);
538 int_adj = int_error / 200.0;
540 // caclulate proportional error
542 prop_adj = 0.5 + prop_error / 50.0;
544 total_adj = 0.9 * prop_adj + 0.1 * int_adj;
545 if ( total_adj > 1.0 ) {
548 else if ( total_adj < 0.0 ) {
552 controls.set_throttle( FGControls::ALL_ENGINES, total_adj );
555 #ifdef THIS_CODE_IS_NOT_USED
556 if (Mode == 2) // Glide slope hold
561 // First, calculate Relative slope and normalize it
562 RelSlope = NormalizeDegrees( TargetSlope - get_pitch());
564 // Now calculate the elevator offset from current angle
565 if ( abs(RelSlope) > SlopeSmooth )
567 if ( RelSlope < 0 ) // set RelElevator to max in the correct direction
568 RelElevator = -MaxElevator;
570 RelElevator = MaxElevator;
574 RelElevator = LinearExtrapolate(RelSlope,-SlopeSmooth,-MaxElevator,SlopeSmooth,MaxElevator);
577 fgElevMove(RelElevator);
580 #endif // THIS_CODE_IS_NOT_USED
582 // stash this runs control settings
583 // update_old_control_values();
584 old_aileron = controls.get_aileron();
585 old_elevator = controls.get_elevator();
586 old_elevator_trim = controls.get_elevator_trim();
587 old_rudder = controls.get_rudder();
589 // for cross track error
598 void FGAutopilot::set_HeadingMode( fgAutoHeadingMode mode ) {
601 if ( heading_mode == FG_HEADING_LOCK ) {
602 // set heading hold to current heading
603 TargetHeading = FGBFI::getHeading();
604 } else if ( heading_mode == FG_HEADING_WAYPOINT ) {
605 double course, reverse, distance;
606 // turn on location hold
607 // turn on heading hold
608 old_lat = FGBFI::getLatitude();
609 old_lon = FGBFI::getLongitude();
611 // need to test for iter
612 if( !geo_inverse_wgs_84( FGBFI::getAltitude() * FEET_TO_METER,
613 FGBFI::getLatitude(),
614 FGBFI::getLongitude(),
620 TargetHeading = course;
621 TargetDistance = distance;
622 MakeTargetDistanceStr( distance );
625 FG_LOG( FG_COCKPIT, FG_INFO, " fgAPSetLocation: ( "
626 << TargetLatitude << " "
627 << TargetLongitude << " ) "
631 MakeTargetHeadingStr( TargetHeading );
632 update_old_control_values();
636 void FGAutopilot::set_AltitudeMode( fgAutoAltitudeMode mode ) {
637 altitude_mode = mode;
639 if ( altitude_mode == FG_ALTITUDE_LOCK ) {
640 // lock at current altitude
641 TargetAltitude = FGBFI::getAltitude() * FEET_TO_METER;
642 alt_error_accum = 0.0;
644 if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
645 MakeTargetAltitudeStr( TargetAltitude * METER_TO_FEET );
647 MakeTargetAltitudeStr( TargetAltitude * METER_TO_FEET );
649 } else if ( altitude_mode == FG_ALTITUDE_TERRAIN ) {
650 TargetAGL = FGBFI::getAGL() * FEET_TO_METER;
651 alt_error_accum = 0.0;
653 if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
654 MakeTargetAltitudeStr( TargetAGL * METER_TO_FEET );
656 MakeTargetAltitudeStr( TargetAGL * METER_TO_FEET );
660 update_old_control_values();
661 FG_LOG( FG_COCKPIT, FG_INFO, " set_AltitudeMode():" );
666 static inline double get_aoa( void ) {
667 return( cur_fdm_state->get_Gamma_vert_rad() * RAD_TO_DEG );
670 static inline double fgAPget_latitude( void ) {
671 return( cur_fdm_state->get_Latitude() * RAD_TO_DEG );
674 static inline double fgAPget_longitude( void ) {
675 return( cur_fdm_state->get_Longitude() * RAD_TO_DEG );
678 static inline double fgAPget_roll( void ) {
679 return( cur_fdm_state->get_Phi() * RAD_TO_DEG );
682 static inline double get_pitch( void ) {
683 return( cur_fdm_state->get_Theta() );
686 double fgAPget_heading( void ) {
687 return( cur_fdm_state->get_Psi() * RAD_TO_DEG );
690 static inline double fgAPget_altitude( void ) {
691 return( cur_fdm_state->get_Altitude() * FEET_TO_METER );
694 static inline double fgAPget_climb( void ) {
695 // return in meters per minute
696 return( cur_fdm_state->get_Climb_Rate() * FEET_TO_METER * 60 );
699 static inline double get_sideslip( void ) {
700 return( cur_fdm_state->get_Beta() );
703 static inline double fgAPget_agl( void ) {
706 agl = cur_fdm_state->get_Altitude() * FEET_TO_METER
714 void FGAutopilot::AltitudeSet( double new_altitude ) {
715 double target_alt = new_altitude;
717 // cout << "new altitude = " << new_altitude << endl;
719 if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
720 target_alt = new_altitude * FEET_TO_METER;
723 if( target_alt < scenery.cur_elev ) {
724 target_alt = scenery.cur_elev;
727 TargetAltitude = target_alt;
728 altitude_mode = FG_ALTITUDE_LOCK;
730 // cout << "TargetAltitude = " << TargetAltitude << endl;
732 if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
733 target_alt *= METER_TO_FEET;
735 // ApAltitudeDialogInput->setValue((float)target_alt);
736 MakeTargetAltitudeStr( target_alt );
738 update_old_control_values();
742 void FGAutopilot::AltitudeAdjust( double inc )
744 double target_alt, target_agl;
746 if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
747 target_alt = TargetAltitude * METER_TO_FEET;
748 target_agl = TargetAGL * METER_TO_FEET;
750 target_alt = TargetAltitude;
751 target_agl = TargetAGL;
754 target_alt = ( int ) ( target_alt / inc ) * inc + inc;
755 target_agl = ( int ) ( target_agl / inc ) * inc + inc;
757 if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
758 target_alt *= FEET_TO_METER;
759 target_agl *= FEET_TO_METER;
762 TargetAltitude = target_alt;
763 TargetAGL = target_agl;
765 if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET )
766 target_alt *= METER_TO_FEET;
767 if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET )
768 target_agl *= METER_TO_FEET;
770 if ( altitude_mode == FG_ALTITUDE_LOCK ) {
771 MakeTargetAltitudeStr( target_alt );
772 } else if ( altitude_mode == FG_ALTITUDE_TERRAIN ) {
773 MakeTargetAltitudeStr( target_agl );
776 update_old_control_values();
780 void FGAutopilot::HeadingAdjust( double inc ) {
781 heading_mode = FG_HEADING_LOCK;
783 double target = ( int ) ( TargetHeading / inc ) * inc + inc;
785 TargetHeading = NormalizeDegrees( target );
786 // following cast needed ambiguous plib
787 // ApHeadingDialogInput -> setValue ((float)TargetHeading );
788 MakeTargetHeadingStr( TargetHeading );
789 update_old_control_values();
793 void FGAutopilot::HeadingSet( double new_heading ) {
794 heading_mode = FG_HEADING_LOCK;
796 new_heading = NormalizeDegrees( new_heading );
797 TargetHeading = new_heading;
798 // following cast needed ambiguous plib
799 // ApHeadingDialogInput -> setValue ((float)APData->TargetHeading );
800 MakeTargetHeadingStr( TargetHeading );
801 update_old_control_values();
804 void FGAutopilot::AutoThrottleAdjust( double inc ) {
805 double target = ( int ) ( TargetSpeed / inc ) * inc + inc;
807 TargetSpeed = target;
811 void FGAutopilot::set_AutoThrottleEnabled( bool value ) {
812 auto_throttle = value;
814 if ( auto_throttle = true ) {
815 TargetSpeed = FGBFI::getAirspeed();
816 speed_error_accum = 0.0;
819 update_old_control_values();
820 FG_LOG( FG_COCKPIT, FG_INFO, " fgAPSetAutoThrottle: ("
821 << auto_throttle << ") " << TargetSpeed );