X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAIModel%2FAICarrier.cxx;h=b6487519d026c05ea55bc026423f093d30ce9375;hb=b4fbde72b275dc75e8ecf7b44261aba642e5da0f;hp=6ed0f2d38341ab8966ee289ddbc7d1207b3775d6;hpb=8f501de78c54dbb16fcdebacb8ed2ee5f2fb49b9;p=flightgear.git diff --git a/src/AIModel/AICarrier.cxx b/src/AIModel/AICarrier.cxx index 6ed0f2d38..b6487519d 100644 --- a/src/AIModel/AICarrier.cxx +++ b/src/AIModel/AICarrier.cxx @@ -57,6 +57,7 @@ void FGAICarrier::readFromScenario(SGPropertyNode* scFileNode) { setMaxLong(scFileNode->getDoubleValue("max-long", 0)); setMinLong(scFileNode->getDoubleValue("min-long", 0)); setMPControl(scFileNode->getBoolValue("mp-control", false)); + setAIControl(scFileNode->getBoolValue("ai-control", false)); SGPropertyNode* flols = scFileNode->getChild("flols-pos"); if (flols) { @@ -121,21 +122,25 @@ void FGAICarrier::setMPControl(bool c) { MPControl = c; } +void FGAICarrier::setAIControl(bool c) { + AIControl = c; +} + void FGAICarrier::update(double dt) { // Now update the position and heading. This will compute new hdg and // roll values required for the rotation speed computation. FGAIShip::update(dt); //automatic turn into wind with a target wind of 25 kts otd - //SG_LOG(SG_GENERAL, SG_ALERT, "AICarrier: MPControl " << MPControl ); - if (!MPControl){ + //SG_LOG(SG_GENERAL, SG_ALERT, "AICarrier: MPControl " << MPControl << " AIControl " << AIControl); + if (!MPControl && AIControl){ if(turn_to_launch_hdg){ TurnToLaunch(); } else if(turn_to_recovery_hdg ){ TurnToRecover(); - } else if(OutsideBox() || returning ) {// check that the carrier is inside - ReturnToBox(); // the operating box, + } else if(OutsideBox() || returning ) {// check that the carrier is inside + ReturnToBox(); // the operating box, } else { TurnToBase(); } @@ -168,10 +173,10 @@ void FGAICarrier::update(double dt) { eyeWrtCarrier = ec2body.transform(eyeWrtCarrier); // the eyepoints vector wrt the flols position SGVec3d eyeWrtFlols = eyeWrtCarrier - flols_off; - + // the distance from the eyepoint to the flols dist = norm(eyeWrtFlols); - + // now the angle, positive angles are upwards if (fabs(dist) < SGLimits::min()) { angle = 0; @@ -180,7 +185,7 @@ void FGAICarrier::update(double dt) { sAngle = SGMiscd::min(1, SGMiscd::max(-1, sAngle)); angle = SGMiscd::rad2deg(asin(sAngle)); } - + // set the value of source if ( angle <= 4.35 && angle > 4.01 ) source = 1; @@ -259,9 +264,9 @@ void FGAICarrier::bind() { props->tie("controls/start-pos-long-deg", SGRawValueMethods(pos, &SGGeod::getLongitudeDeg)); props->tie("controls/mp-control", - SGRawValuePointer(&MPControl)); - props->tie("velocities/speed-kts", - SGRawValuePointer(&speed)); + SGRawValuePointer(&MPControl)); + props->tie("controls/ai-control", + SGRawValuePointer(&AIControl)); props->tie("environment/surface-wind-speed-true-kts", SGRawValuePointer(&wind_speed_kts)); props->tie("environment/surface-wind-from-true-degs", @@ -274,8 +279,8 @@ void FGAICarrier::bind() { SGRawValuePointer(&rel_wind_speed_kts)); props->tie("environment/in-to-wind", SGRawValuePointer(&in_to_wind)); - props->tie("controls/flols/wave-off-lights", - SGRawValuePointer(&wave_off_lights)); + //props->tie("controls/flols/wave-off-lights", + // SGRawValuePointer(&wave_off_lights)); props->tie("controls/elevators", SGRawValuePointer(&elevators)); props->tie("surface-positions/elevators-pos-norm", @@ -317,13 +322,12 @@ void FGAICarrier::unbind() { props->untie("controls/flols/distance-m"); props->untie("controls/flols/angle-degs"); props->untie("controls/turn-to-launch-hdg"); - props->untie("velocities/speed-kts"); props->untie("environment/wind-speed-true-kts"); props->untie("environment/wind-from-true-degs"); props->untie("environment/rel-wind-from-degs"); props->untie("environment/rel-wind-speed-kts"); props->untie("environment/in-to-wind"); - props->untie("controls/flols/wave-off-lights"); + //props->untie("controls/flols/wave-off-lights"); props->untie("controls/elevators"); props->untie("surface-positions/elevators-pos-norm"); props->untie("controls/constants/elevators/trans-time-secs"); @@ -333,6 +337,7 @@ void FGAICarrier::unbind() { props->untie("controls/constants/jbd/trans-time-s"); props->untie("controls/jbd-time-constant"); props->untie("controls/mp-control"); + props->untie("controls/ai-control"); props->untie("controls/turn-to-recovery-hdg"); props->untie("controls/turn-to-base-course"); } @@ -394,11 +399,14 @@ void FGAICarrier::UpdateWind( double dt) { rel_wind = rel_wind_from_deg - hdg; SG_NORMALIZE_RANGE(rel_wind, -180.0, 180.0); + //set in to wind property + InToWind(); + //switch the wave-off lights - if (InToWind()) - wave_off_lights = false; - else - wave_off_lights = true; + //if (InToWind()) + // wave_off_lights = false; + //else + // wave_off_lights = true; // cout << "rel wind: " << rel_wind << endl; @@ -433,12 +441,12 @@ void FGAICarrier::TurnToRecover(){ if (wind_speed_kts < 3){ tgt_heading = base_course + 60; } else if (rel_wind < -9 && rel_wind >= -180){ - tgt_heading = wind_from_deg; + tgt_heading = wind_from_deg; } else if (rel_wind > -7 && rel_wind < 45){ tgt_heading = wind_from_deg + 60; } else if (rel_wind >=45 && rel_wind < 180){ tgt_heading = wind_from_deg + 45; - } else + } else tgt_heading = hdg; SG_NORMALIZE_RANGE(tgt_heading, 0.0, 360.0);