From: ehofman Date: Sat, 13 Nov 2004 14:45:57 +0000 (+0000) Subject: Vivian Meazza: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2df4a3b68576492a54adc11d503914558791bfc7;p=flightgear.git Vivian Meazza: I attach the latest version of Nimitz. The textures have been improved. A glide-path has been added, it is on by default, but can be switched off by means of the properties browser: /ai/models/ship/controls/glide-path. The origin has been adjusted to the turning pivot and approximate roll center. Modified AiShip files are also attached. These allow the radius of the turning circle of a ship to be input. The turning circle is adjusted for speed and rudder angle. Roll has been corrected so that a ship leans out of a turn, not inwards like an aircraft. The roll angle is adjusted for speed and rudder angle (yes, application of more rudder reduces roll angle - rudders act as stabilizers). TODO Add a relative wind calculation so that a carrier can be turned to the appropriate launch and recovery courses. Add a 'flight plan' so that the carrier can carry out a racetrack for flight ops. Add a projector landing sight. Add auto-land facilities. --- diff --git a/src/AIModel/AIShip.cxx b/src/AIModel/AIShip.cxx index 32950ba65..76086ae79 100644 --- a/src/AIModel/AIShip.cxx +++ b/src/AIModel/AIShip.cxx @@ -47,12 +47,13 @@ bool FGAIShip::init() { void FGAIShip::bind() { FGAIBase::bind(); - props->tie("surface-positions/rudder-pos-norm", + props->tie("surface-positions/rudder-pos-deg", SGRawValuePointer(&rudder)); } void FGAIShip::unbind() { FGAIBase::unbind(); + props->untie("surface-positions/rudder-pos-deg"); } void FGAIShip::update(double dt) { @@ -68,8 +69,8 @@ void FGAIShip::Run(double dt) { if (fp) ProcessFlightPlan(dt); - double turn_radius_ft; - double turn_circum_ft; + double sp_turn_radius_ft; + double rd_turn_radius_ft; double speed_north_deg_sec; double speed_east_deg_sec; double dist_covered_ft; @@ -92,16 +93,41 @@ void FGAIShip::Run(double dt) { pos.setlat( pos.lat() + speed_north_deg_sec * dt); pos.setlon( pos.lon() + speed_east_deg_sec * dt); + // adjust heading based on current rudder angle - if (rudder != 0.0) { - turn_radius_ft = 0.088362 * speed * speed + if (rudder != 0.0) { + /* rd_turn_radius_ft = 0.088362 * speed * speed / tan( fabs(rudder) / SG_RADIANS_TO_DEGREES ); - turn_circum_ft = SGD_2PI * turn_radius_ft; + turn_circum_ft = SGD_2PI * rd_turn_radius_ft; dist_covered_ft = speed * 1.686 * dt; - alpha = dist_covered_ft / turn_circum_ft * 360.0; + alpha = dist_covered_ft / turn_circum_ft * 360.0;*/ + + if (rd_turn_radius_ft <= 0) rd_turn_radius_ft = 0; // don't allow nonsense values + +// cout << "speed " << speed << " turn radius " << rd_turn_radius_ft << endl; + +// adjust turn radius for speed. The equation is very approximate. + sp_turn_radius_ft = 10 * pow ((speed - 15),2) + rd_turn_radius_ft; +// cout << "speed " << speed << " speed turn radius " << sp_turn_radius_ft << endl; + +// adjust turn radius for rudder angle. The equation is even more approximate. + rd_turn_radius_ft = -130 * (rudder - 15) + sp_turn_radius_ft; +// cout << "rudder " << rudder << " rudder turn radius " << rd_turn_radius_ft << endl; + +// calculate the angle, alpha, subtended by the arc traversed in time dt + alpha = ((speed * 1.686 * dt)/rd_turn_radius_ft) * SG_RADIANS_TO_DEGREES; + +// make sure that alpha is applied in the right direction + hdg += alpha * sign( rudder ); + if ( hdg > 360.0 ) hdg -= 360.0; if ( hdg < 0.0) hdg += 360.0; + +//adjust roll for rudder angle and speed + roll = - ( speed / 2 - rudder / 6 ); + +// cout << " hdg " << hdg << "roll "<< roll << endl; } // adjust target rudder angle if heading lock engaged