1
0
Fork 0

YSCB AI parking test

This commit is contained in:
portree_kid 2021-02-21 08:22:31 +01:00 committed by James Turner
parent dccea87cea
commit 620dd9ee48
5 changed files with 9342 additions and 8 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -56,6 +56,7 @@ void TrafficTests::setUp()
auto props = globals->get_props();
props->setBoolValue("sim/ai/enabled", true);
props->setBoolValue("/sim/traffic-manager/enabled", true);
props->setBoolValue("sim/signals/fdm-initialized", false);
props->setDoubleValue("/environment/visibility-m", 100.0);
@ -67,11 +68,14 @@ void TrafficTests::setUp()
FGAirportRef yssy = FGAirport::getByIdent("YSSY");
yssy->testSuiteInjectGroundnetXML(SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "YSSY.groundnet.xml");
FGAirportRef ybbn = FGAirport::getByIdent("YBBN");
ybbn->testSuiteInjectGroundnetXML(SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "YBBN.groundnet.xml");
globals->add_new_subsystem<PerformanceDB>(SGSubsystemMgr::GENERAL);
globals->add_new_subsystem<FGATCManager>(SGSubsystemMgr::GENERAL);
globals->add_new_subsystem<FGAIManager>(SGSubsystemMgr::GENERAL);
globals->add_new_subsystem<flightgear::AirportDynamicsManager>(SGSubsystemMgr::GENERAL);
globals->add_new_subsystem<FGTrafficManager>(SGSubsystemMgr::GENERAL);
globals->get_subsystem_mgr()->bind();
globals->get_subsystem_mgr()->init();
@ -410,13 +414,8 @@ void TrafficTests::testChangeRunway()
auto prefs = departureAirport->getDynamics();
flightgear::SGGeodVec geods = flightgear::SGGeodVec();
for (size_t i = 0; i < 6000 && aiAircraft->GetFlightPlan()->getLeg() < 3; i++)
for (size_t i = 0; i < 6000; i++)
{
//this->dump(aiAircraft);
if(aiAircraft->GetFlightPlan()->getLeg()>1) {
aiAircraft->GetFlightPlan()->setRunway("30");
}
if(geods.empty()||SGGeodesy::distanceM(aiAircraft->getGeodPos(), geods.back()) > 1) {
geods.insert(geods.end(), aiAircraft->getGeodPos());
}
@ -433,7 +432,7 @@ void TrafficTests::testPushforward()
{
FGAirportRef departureAirport = FGAirport::getByIdent("YSSY");
FGAirportRef arrivalAirport = FGAirport::getByIdent("YSCB");
FGAirportRef arrivalAirport = FGAirport::getByIdent("YBBN");
fgSetString("/sim/presets/airport-id", departureAirport->getId());
fgSetInt("/environment/visibility-m", 1000);
@ -504,11 +503,104 @@ void TrafficTests::testPushforward()
FGTestApi::runForTime(3.0);
}
FGTestApi::setUp::logPositionToKML("flight_ga_YSSY_" + std::to_string(departureTime));
FGTestApi::setUp::logPositionToKML("flight_ga_YSSY_depart_" + std::to_string(departureTime));
FGTestApi::writeGeodsToKML("Aircraft", geods);
CPPUNIT_ASSERT_EQUAL( 5, aiAircraft->GetFlightPlan()->getLeg());
}
void TrafficTests::testPushforwardParkYBBN()
{
FGAirportRef departureAirport = FGAirport::getByIdent("YBBN");
FGAirportRef arrivalAirport = FGAirport::getByIdent("YSSY");
fgSetString("/sim/presets/airport-id", arrivalAirport->getId());
fgSetInt("/environment/visibility-m", 1000);
time_t rawtime;
struct tm * timeinfo;
char dep [11];
char arr [11];
time (&rawtime);
rawtime = rawtime + 60;
timeinfo = gmtime (&rawtime);
strftime (dep,11,"%w/%H:%M:%S",timeinfo);
rawtime = rawtime + 3200;
timeinfo = gmtime (&rawtime);
strftime (arr,11,"%w/%H:%M:%S",timeinfo);
const int radius = 8.0;
const int cruiseAltFt = 32000;
const int cruiseSpeedKnots = 80;
const char* flighttype = "ga";
FGAISchedule* schedule = new FGAISchedule(
"B737", "KLM", departureAirport->getId(), "G-BLA", "ID", false, "B737", "KLM", "N", flighttype, radius, 8);
FGScheduledFlight* flight = new FGScheduledFlight("gaParkYSSY", "", departureAirport->getId(), arrivalAirport->getId(), 24, dep, arr, "WEEK", "HBR_BN_2");
schedule->assign(flight);
FGAIAircraft* aiAircraft = new FGAIAircraft{schedule};
const SGGeod position = departureAirport->geod();
FGTestApi::setPositionAndStabilise(position);
aiAircraft->setPerformance("ga", "");
aiAircraft->setCompany("KLM");
aiAircraft->setAcType("B737");
aiAircraft->setSpeed(0);
aiAircraft->setBank(0);
const string flightPlanName = departureAirport->getId() + "-" + arrivalAirport->getId() + ".xml";
const double crs = SGGeodesy::courseDeg(departureAirport->geod(), arrivalAirport->geod()); // direct course
time_t departureTime;
time(&departureTime); // now
departureTime = departureTime - 50;
std::unique_ptr<FGAIFlightPlan> fp(new FGAIFlightPlan(aiAircraft,
flightPlanName, crs, departureTime,
departureAirport, arrivalAirport, true, radius,
cruiseAltFt, // cruise alt
position.getLatitudeDeg(),
position.getLongitudeDeg(),
cruiseSpeedKnots, flighttype,
aiAircraft->getAcType(),
aiAircraft->getCompany()));
CPPUNIT_ASSERT_EQUAL( fp->isValidPlan(), true);
aiAircraft->FGAIBase::setFlightPlan(std::move(fp));
globals->get_subsystem<FGAIManager>()->attach(aiAircraft);
FGTestApi::setUp::logPositionToKML("flight_ga_YSSY_park_" + std::to_string(departureTime));
flightgear::SGGeodVec geods = flightgear::SGGeodVec();
int lastLeg = 0;
for (size_t i = 0; i < 12000000 && aiAircraft->GetFlightPlan()->getLeg() < 10; i++)
{
//this->dump(aiAircraft);
if(geods.empty()||SGGeodesy::distanceM(aiAircraft->getGeodPos(), geods.back()) > 1) {
geods.insert(geods.end(), aiAircraft->getGeodPos());
}
if (aiAircraft->GetFlightPlan()->getLeg() > lastLeg)
{
lastLeg = aiAircraft->GetFlightPlan()->getLeg();
char buffer [50];
sprintf(buffer, "AI Leg %d", lastLeg);
FGTestApi::writeGeodsToKML(buffer, geods);
geods.clear();
}
FGTestApi::runForTime(5.0);
}
lastLeg = aiAircraft->GetFlightPlan()->getLeg();
char buffer [50];
sprintf(buffer, "AI Leg %d", lastLeg);
FGTestApi::writeGeodsToKML(buffer, geods);
geods.clear();
CPPUNIT_ASSERT_EQUAL( 5, aiAircraft->GetFlightPlan()->getLeg());
}
void TrafficTests::dump(FGAIAircraft* aiAircraft) {
std::cout << "********************\n";
std::cout << "Geod " << aiAircraft->getGeodPos() << "\t Speed : " << aiAircraft->getSpeed() << "\n";

View file

@ -40,6 +40,7 @@ class TrafficTests : public CppUnit::TestFixture
CPPUNIT_TEST(testPushback2);
CPPUNIT_TEST(testChangeRunway);
CPPUNIT_TEST(testPushforward);
CPPUNIT_TEST(testPushforwardParkYBBN);
CPPUNIT_TEST_SUITE_END();
@ -56,6 +57,7 @@ public:
void testPushback2();
void testChangeRunway();
void testPushforward();
void testPushforwardParkYBBN();
private:
void dump(FGAIAircraft* aiAircraft);
};