Merge branch 'next' into vivian
Conflicts: src/AIModel/AIBallistic.cxx src/AIModel/AIBase.cxx
This commit is contained in:
commit
141186a358
11 changed files with 74 additions and 61 deletions
|
@ -648,7 +648,7 @@ bool FGAIAircraft::leadPointReached(FGAIFlightPlan::waypoint* curr) {
|
|||
// << dist_to_go << ": Lead distance "
|
||||
// << lead_dist << " " << curr->name
|
||||
// << " Ground target speed " << groundTargetSpeed << endl;
|
||||
double bearing;
|
||||
double bearing = 0;
|
||||
if (speed > 50) { // don't do bearing calculations for ground traffic
|
||||
bearing = getBearing(fp->getBearing(pos.getLatitudeDeg(), pos.getLongitudeDeg(), curr));
|
||||
if (bearing < minBearing) {
|
||||
|
|
|
@ -45,6 +45,7 @@ _ht_agl_ft(0.0),
|
|||
_azimuth(0.0),
|
||||
_elevation(0.0),
|
||||
_rotation(0.0),
|
||||
_elapsed_time(0),
|
||||
_aero_stabilised(false),
|
||||
_drag_area(0.007),
|
||||
_life_timer(0.0),
|
||||
|
@ -60,14 +61,13 @@ _slave_to_ac(false),
|
|||
_slave_load_to_ac(false),
|
||||
_contents_lb(0),
|
||||
_report_collision(false),
|
||||
_report_expiry(false),
|
||||
_report_impact(false),
|
||||
_external_force(false),
|
||||
_report_expiry(false),
|
||||
_impact_report_node(fgGetNode("/ai/models/model-impact", true)),
|
||||
hs(0),
|
||||
_old_height(0),
|
||||
_elapsed_time(0),
|
||||
_speed(),
|
||||
hs(0)
|
||||
_speed()
|
||||
|
||||
{
|
||||
no_roll = false;
|
||||
|
|
|
@ -53,11 +53,13 @@ const double FGAIBase::lbs_to_slugs = 0.031080950172; //conversion factor
|
|||
using namespace simgear;
|
||||
|
||||
FGAIBase::FGAIBase(object_type ot) :
|
||||
_max_speed(300),
|
||||
_name(""),
|
||||
_parent(""),
|
||||
props( NULL ),
|
||||
model_removed( fgGetNode("/ai/models/model-removed", true) ),
|
||||
manager( NULL ),
|
||||
fp( NULL ),
|
||||
|
||||
_impact_lat(0),
|
||||
_impact_lon(0),
|
||||
_impact_elev(0),
|
||||
|
@ -65,13 +67,9 @@ FGAIBase::FGAIBase(object_type ot) :
|
|||
_impact_pitch(0),
|
||||
_impact_roll(0),
|
||||
_impact_speed(0),
|
||||
_max_speed(300),
|
||||
|
||||
_refID( _newAIModelID() ),
|
||||
_otype(ot),
|
||||
_initialized(false),
|
||||
_parent(""),
|
||||
_name("")
|
||||
_initialized(false)
|
||||
|
||||
{
|
||||
tgt_heading = hdg = tgt_altitude_ft = tgt_speed = 0.0;
|
||||
|
|
|
@ -45,14 +45,14 @@ FGAIEscort::FGAIEscort() :
|
|||
FGAIShip(otEscort),
|
||||
|
||||
_relbrg (0),
|
||||
_stn_truebrg(0),
|
||||
_parent_speed(0),
|
||||
_stn_limit(0),
|
||||
_stn_angle_limit(0),
|
||||
_stn_speed(0),
|
||||
_stn_height(0),
|
||||
_max_speed(0),
|
||||
_interval(0),
|
||||
_stn_truebrg(0),
|
||||
_stn_height(0),
|
||||
_stn_speed(0),
|
||||
_stn_angle_limit(0),
|
||||
_stn_limit(0),
|
||||
_max_speed(0),
|
||||
_MPControl(false),
|
||||
_patrol(false),
|
||||
_stn_deg_true(false)
|
||||
|
|
|
@ -419,13 +419,13 @@ void FGAIFlightPlan::createTakeOff(FGAIAircraft * ac, bool firstFlight,
|
|||
double vTaxi = ac->getPerformance()->vTaxi();
|
||||
double vRotate = ac->getPerformance()->vRotate();
|
||||
double vTakeoff = ac->getPerformance()->vTakeoff();
|
||||
double vClimb = ac->getPerformance()->vClimb();
|
||||
//double vClimb = ac->getPerformance()->vClimb();
|
||||
|
||||
double accelMetric = (accel * SG_NM_TO_METER) / 3600;
|
||||
double vTaxiMetric = (vTaxi * SG_NM_TO_METER) / 3600;
|
||||
double vRotateMetric = (vRotate * SG_NM_TO_METER) / 3600;
|
||||
double vTakeoffMetric = (vTakeoff * SG_NM_TO_METER) / 3600;
|
||||
double vClimbMetric = (vClimb * SG_NM_TO_METER) / 3600;
|
||||
//double vClimbMetric = (vClimb * SG_NM_TO_METER) / 3600;
|
||||
// Acceleration = dV / dT
|
||||
// Acceleration X dT = dV
|
||||
// dT = dT / Acceleration
|
||||
|
@ -558,7 +558,7 @@ void FGAIFlightPlan::createDescent(FGAIAircraft * ac, FGAirport * apt,
|
|||
|
||||
// Create a slow descent path that ends 250 lateral to the runway.
|
||||
double initialTurnRadius = getTurnRadius(vDescent, true);
|
||||
double finalTurnRadius = getTurnRadius(vApproach, true);
|
||||
//double finalTurnRadius = getTurnRadius(vApproach, true);
|
||||
|
||||
// get length of the downwind leg for the intended runway
|
||||
double distanceOut = apt->getDynamics()->getApproachController()->getRunway(rwy->name())->getApproachDistance(); //12 * SG_NM_TO_METER;
|
||||
|
@ -801,7 +801,7 @@ void FGAIFlightPlan::createDescent(FGAIAircraft * ac, FGAirport * apt,
|
|||
|
||||
if (reposition) {
|
||||
double tempDistance;
|
||||
double minDistance = HUGE_VAL;
|
||||
//double minDistance = HUGE_VAL;
|
||||
string wptName;
|
||||
tempDistance = SGGeodesy::distanceM(current, initialTarget);
|
||||
time_t eta =
|
||||
|
@ -836,7 +836,7 @@ void FGAIFlightPlan::createLanding(FGAIAircraft * ac, FGAirport * apt,
|
|||
const string & fltType)
|
||||
{
|
||||
double vTouchdown = ac->getPerformance()->vTouchdown();
|
||||
double vTaxi = ac->getPerformance()->vTaxi();
|
||||
//double vTaxi = ac->getPerformance()->vTaxi();
|
||||
|
||||
//string rwyClass = getRunwayClassFromTrafficType(fltType);
|
||||
//double heading = ac->getTrafficRef()->getCourse();
|
||||
|
|
|
@ -40,11 +40,11 @@ _speed_kt(0),
|
|||
_range_ft(0),
|
||||
_relbrg (0),
|
||||
_parent_speed(0),
|
||||
_dt_count(0),
|
||||
_next_run(0),
|
||||
_parent_x_offset(0),
|
||||
_parent_y_offset(0),
|
||||
_parent_z_offset(0),
|
||||
_dt_count(0),
|
||||
_next_run(0),
|
||||
_break_count(0)
|
||||
|
||||
{
|
||||
|
@ -285,7 +285,7 @@ bool FGAIGroundVehicle::getPitch() {
|
|||
double rear_elev_m = 0;
|
||||
double elev_front = 0;
|
||||
double elev_rear = 0;
|
||||
double max_alt = 10000;
|
||||
//double max_alt = 10000;
|
||||
|
||||
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(geodFront, 3000),
|
||||
elev_front, &_material, 0)){
|
||||
|
@ -480,7 +480,7 @@ void FGAIGroundVehicle::AdvanceFP(){
|
|||
|
||||
void FGAIGroundVehicle::setTowSpeed(){
|
||||
|
||||
double diff = _range_ft - _x_offset;
|
||||
//double diff = _range_ft - _x_offset;
|
||||
double x = 0;
|
||||
|
||||
if (_range_ft > _x_offset * 3) x = 50;
|
||||
|
@ -537,7 +537,7 @@ void FGAIGroundVehicle::RunGroundVehicle(double dt){
|
|||
|
||||
string parent_next_name = _selected_ac->getStringValue("waypoint/name-next");
|
||||
bool parent_waiting = _selected_ac->getBoolValue("waypoint/waiting");
|
||||
bool parent_restart = _selected_ac->getBoolValue("controls/restart");
|
||||
//bool parent_restart = _selected_ac->getBoolValue("controls/restart");
|
||||
|
||||
if (parent_next_name == "END" && fp->getNextWaypoint()->name != "END" ){
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "AIGroundVeh1cle: " << _name
|
||||
|
|
|
@ -43,35 +43,35 @@
|
|||
|
||||
FGAIShip::FGAIShip(object_type ot) :
|
||||
FGAIBase(ot),
|
||||
|
||||
|
||||
_waiting(false),
|
||||
_new_waypoint(true),
|
||||
_tunnel(false),
|
||||
_initial_tunnel(false),
|
||||
_restart(false),
|
||||
_hdg_constant(0.01),
|
||||
_limit(100),
|
||||
_elevation_m(0),
|
||||
_elevation_ft(0),
|
||||
_tow_angle(0),
|
||||
_missed_count(0),
|
||||
_wp_range(0),
|
||||
_dt_count(0),
|
||||
_next_run(0),
|
||||
_roll_constant(0.001),
|
||||
_roll_factor(-0.0083335),
|
||||
_old_range(0),
|
||||
_range_rate(0),
|
||||
_missed_time_sec(30),
|
||||
_day(86400),
|
||||
_lead_angle(0),
|
||||
_xtrack_error(0),
|
||||
_tunnel(false),
|
||||
_initial_tunnel(false),
|
||||
_curr_alt(0),
|
||||
_prev_alt(0),
|
||||
_until_time(""),
|
||||
_fp_init(false),
|
||||
_missed(false),
|
||||
_waiting(false),
|
||||
_new_waypoint(true),
|
||||
_missed_count(0),
|
||||
_wait_count(0),
|
||||
_missed_time_sec(30),
|
||||
_day(86400),
|
||||
_wp_range(0),
|
||||
_old_range(0),
|
||||
_range_rate(0),
|
||||
_roll_constant(0.001),
|
||||
_hdg_constant(0.01),
|
||||
_roll_factor(-0.0083335),
|
||||
_restart(false)
|
||||
|
||||
_missed(false)
|
||||
{
|
||||
invisible = false;
|
||||
}
|
||||
|
|
|
@ -204,7 +204,7 @@ void FGSubmodelMgr::update(double dt)
|
|||
|
||||
if (trigger && (*submodel_iterator)->count != 0) {
|
||||
|
||||
int id = (*submodel_iterator)->id;
|
||||
//int id = (*submodel_iterator)->id;
|
||||
string name = (*submodel_iterator)->name;
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG,
|
||||
|
@ -338,7 +338,7 @@ void FGSubmodelMgr::transform(submodel *sm)
|
|||
IC.mass = sm->weight * lbs_to_slugs;
|
||||
|
||||
int id = sm->id;
|
||||
int sub_id = sm->sub_id;
|
||||
//int sub_id = sm->sub_id;
|
||||
string name = sm->name;
|
||||
|
||||
|
||||
|
|
|
@ -473,7 +473,7 @@ double
|
|||
FGEnvironment::get_turbulence_magnitude_norm () const
|
||||
{
|
||||
if( sgEnviro.get_turbulence_enable_state() )
|
||||
if (fgGetBool("/environment/params/real-world-weather-fetch") == true)
|
||||
if (fgGetBool("/environment/realwx/enabled")||fgGetBool("/environment/metar/valid"))
|
||||
return sgEnviro.get_cloud_turbulence();
|
||||
return turbulence_magnitude_norm;
|
||||
}
|
||||
|
|
|
@ -56,10 +56,13 @@ protected:
|
|||
void bind();
|
||||
void unbind();
|
||||
|
||||
long getMetarMaxAgeMin() const { return _max_age_n == NULL ? 0 : _max_age_n->getLongValue(); }
|
||||
|
||||
SGPropertyNode_ptr _rootNode;
|
||||
SGPropertyNode_ptr _longitude_n;
|
||||
SGPropertyNode_ptr _latitude_n;
|
||||
SGPropertyNode_ptr _ground_elevation_n;
|
||||
SGPropertyNode_ptr _max_age_n;
|
||||
|
||||
bool _enabled;
|
||||
TiedPropertyList _tiedProperties;
|
||||
|
@ -78,6 +81,7 @@ BasicRealWxController::BasicRealWxController( SGPropertyNode_ptr rootNode ) :
|
|||
_longitude_n( fgGetNode( "/position/longitude-deg", true )),
|
||||
_latitude_n( fgGetNode( "/position/latitude-deg", true )),
|
||||
_ground_elevation_n( fgGetNode( "/position/ground-elev-m", true )),
|
||||
_max_age_n( fgGetNode( "/environment/params/metar-max-age-min", false ) ),
|
||||
_enabled(true),
|
||||
_metarProperties( fgGetNode( rootNode->getStringValue("metar", "/environment/metar"), true ) )
|
||||
{
|
||||
|
@ -142,13 +146,13 @@ private:
|
|||
#if defined(ENABLE_THREADS)
|
||||
class MetarLoadThread : public OpenThreads::Thread {
|
||||
public:
|
||||
MetarLoadThread( NoaaMetarRealWxController & controller );
|
||||
MetarLoadThread( long maxAge );
|
||||
void requestMetar( const MetarLoadRequest & metarRequest );
|
||||
bool hasMetar() { return _responseQueue.size() > 0; }
|
||||
string getMetar() { return _responseQueue.pop(); }
|
||||
virtual void run();
|
||||
private:
|
||||
NoaaMetarRealWxController & _controller;
|
||||
long _maxAge;
|
||||
SGBlockingQueue <MetarLoadRequest> _requestQueue;
|
||||
SGBlockingQueue <string> _responseQueue;
|
||||
};
|
||||
|
@ -167,7 +171,7 @@ NoaaMetarRealWxController::NoaaMetarRealWxController( SGPropertyNode_ptr rootNod
|
|||
_metarStationIdNode(_metarProperties.get_root_node()->getNode("station-id",true))
|
||||
{
|
||||
#if defined(ENABLE_THREADS)
|
||||
_metarLoadThread = new MetarLoadThread(*this);
|
||||
_metarLoadThread = new MetarLoadThread(getMetarMaxAgeMin());
|
||||
_metarLoadThread->start();
|
||||
#endif
|
||||
}
|
||||
|
@ -189,8 +193,11 @@ void NoaaMetarRealWxController::update( double dt )
|
|||
if( !_enabled )
|
||||
return;
|
||||
|
||||
if( _metarLoadThread->hasMetar() )
|
||||
_metarDataNode->setStringValue( _metarLoadThread->getMetar() );
|
||||
if( _metarLoadThread->hasMetar() ) {
|
||||
string metar = _metarLoadThread->getMetar();
|
||||
SG_LOG( SG_ALL, SG_ALERT, "NoaaMetarRwalWxController::update() received METAR " << metar );
|
||||
_metarDataNode->setStringValue( metar );
|
||||
}
|
||||
|
||||
_metarTimeToLive -= dt;
|
||||
_positionTimeToLive -= dt;
|
||||
|
@ -237,8 +244,8 @@ void NoaaMetarRealWxController::update( double dt )
|
|||
/* -------------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(ENABLE_THREADS)
|
||||
NoaaMetarRealWxController::MetarLoadThread::MetarLoadThread( NoaaMetarRealWxController & controller ) :
|
||||
_controller(controller)
|
||||
NoaaMetarRealWxController::MetarLoadThread::MetarLoadThread( long maxAge ) :
|
||||
_maxAge(maxAge)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -272,14 +279,22 @@ void NoaaMetarRealWxController::MetarLoadThread::run()
|
|||
continue;
|
||||
}
|
||||
|
||||
if( result == NULL )
|
||||
continue;
|
||||
|
||||
string reply = result->getData();
|
||||
std::replace(reply.begin(), reply.end(), '\n', ' ');
|
||||
string metar = simgear::strutils::strip( reply );
|
||||
if( metar.length() > 0 )
|
||||
_responseQueue.push( metar );
|
||||
|
||||
if( metar.empty() ) {
|
||||
SG_LOG( SG_GENERAL, SG_WARN, "NoaaMetarRealWxController::fetchMetar(): dropping empty METAR for "
|
||||
<< request._stationId );
|
||||
}
|
||||
|
||||
if( _maxAge && result->getAge_min() > _maxAge ) {
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "NoaaMetarRealWxController::fetchMetar(): dropping outdated METAR "
|
||||
<< metar );
|
||||
return;
|
||||
}
|
||||
|
||||
_responseQueue.push( metar );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -375,7 +375,7 @@ void FGTrafficManager::readTimeTableFromFile(SGPath infileName)
|
|||
string arrTimeGen = tokens[6];
|
||||
string repeat = "WEEK";
|
||||
string requiredAircraft = tokens[9];
|
||||
|
||||
|
||||
if (weekdays.size() != 7) {
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "Found misconfigured weekdays string" << weekdays);
|
||||
exit(1);
|
||||
|
@ -611,7 +611,7 @@ void FGTrafficManager::endElement(const char *name)
|
|||
if (fgGetBool("/sim/traffic-manager/dumpdata") == true) {
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "Traffic Dump AC," << homePort << "," << registration << "," << requiredAircraft
|
||||
<< "," << acType << "," << livery << ","
|
||||
<< airline << "," << offset << "," << radius << "," << flighttype << "," << isHeavy << "," << mdl);
|
||||
<< airline << "," << m_class << "," << offset << "," << radius << "," << flighttype << "," << isHeavy << "," << mdl);
|
||||
}
|
||||
//scheduledAircraft.push_back(new FGAISchedule(mdl,
|
||||
// livery,
|
||||
|
|
Loading…
Add table
Reference in a new issue