AI Tests
This commit is contained in:
parent
9dd5c0e055
commit
03574442c0
7 changed files with 15619 additions and 21 deletions
57
test_suite/test_data/AI/Flightplan/left_onground.xml
Executable file
57
test_suite/test_data/AI/Flightplan/left_onground.xml
Executable file
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<PropertyList>
|
||||||
|
<flightplan>
|
||||||
|
<wp>
|
||||||
|
<name>on1</name>
|
||||||
|
<lat>59.534235</lat>
|
||||||
|
<lon>-1.629072</lon>
|
||||||
|
<ktas>10</ktas>
|
||||||
|
<on-ground>1</on-ground>
|
||||||
|
</wp>
|
||||||
|
<wp>
|
||||||
|
<name>on2</name>
|
||||||
|
<lat>59.534315</lat>
|
||||||
|
<lon>-1.629182</lon>
|
||||||
|
<ktas>10</ktas>
|
||||||
|
<on-ground>1</on-ground>
|
||||||
|
</wp>
|
||||||
|
<wp>
|
||||||
|
<name>on5</name>
|
||||||
|
<lat>59.534364</lat>
|
||||||
|
<lon>-1.629345</lon>
|
||||||
|
<ktas>10</ktas>
|
||||||
|
<on-ground>1</on-ground>
|
||||||
|
</wp>
|
||||||
|
<wp>
|
||||||
|
<name>on4</name>
|
||||||
|
<lat>59.534372</lat>
|
||||||
|
<lon>-1.629544</lon>
|
||||||
|
<ktas>10</ktas>
|
||||||
|
<on-ground>1</on-ground>
|
||||||
|
</wp>
|
||||||
|
<wp>
|
||||||
|
<name>on10</name>
|
||||||
|
<lat>59.534363</lat>
|
||||||
|
<lon>-1.629681</lon>
|
||||||
|
<ktas>10</ktas>
|
||||||
|
<on-ground>1</on-ground>
|
||||||
|
</wp>
|
||||||
|
<wp>
|
||||||
|
<name>on3</name>
|
||||||
|
<lat>59.5343438</lat>
|
||||||
|
<lon>-1.6298094</lon>
|
||||||
|
<ktas>10</ktas>
|
||||||
|
<on-ground>1</on-ground>
|
||||||
|
</wp>
|
||||||
|
<wp>
|
||||||
|
<name>on11</name>
|
||||||
|
<lat>59.5341711</lat>
|
||||||
|
<lon>-1.63037</lon>
|
||||||
|
<ktas>10</ktas>
|
||||||
|
<on-ground>1</on-ground>
|
||||||
|
</wp>
|
||||||
|
<wp>
|
||||||
|
<name>END</name>
|
||||||
|
</wp>
|
||||||
|
</flightplan>
|
||||||
|
</PropertyList>
|
57
test_suite/test_data/AI/Flightplan/right_onground.xml
Executable file
57
test_suite/test_data/AI/Flightplan/right_onground.xml
Executable file
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<PropertyList>
|
||||||
|
<flightplan>
|
||||||
|
<wp>
|
||||||
|
<name>on1</name>
|
||||||
|
<lat>59.534235</lat>
|
||||||
|
<lon>-1.629072</lon>
|
||||||
|
<ktas>10</ktas>
|
||||||
|
<on-ground>1</on-ground>
|
||||||
|
</wp>
|
||||||
|
<wp>
|
||||||
|
<name>on2</name>
|
||||||
|
<lat>59.534315</lat>
|
||||||
|
<lon>-1.629182</lon>
|
||||||
|
<ktas>10</ktas>
|
||||||
|
<on-ground>1</on-ground>
|
||||||
|
</wp>
|
||||||
|
<wp>
|
||||||
|
<name>on6</name>
|
||||||
|
<lat>59.5343928</lat>
|
||||||
|
<lon>-1.6292113</lon>
|
||||||
|
<ktas>10</ktas>
|
||||||
|
<on-ground>1</on-ground>
|
||||||
|
</wp>
|
||||||
|
<wp>
|
||||||
|
<name>on7</name>
|
||||||
|
<lat>59.5344594</lat>
|
||||||
|
<lon>-1.6292113</lon>
|
||||||
|
<ktas>10</ktas>
|
||||||
|
<on-ground>1</on-ground>
|
||||||
|
</wp>
|
||||||
|
<wp>
|
||||||
|
<name>on8</name>
|
||||||
|
<lat>59.5345519</lat>
|
||||||
|
<lon>-1.6291362</lon>
|
||||||
|
<ktas>10</ktas>
|
||||||
|
<on-ground>1</on-ground>
|
||||||
|
</wp>
|
||||||
|
<wp>
|
||||||
|
<name>on9</name>
|
||||||
|
<lat>59.5346335</lat>
|
||||||
|
<lon>-1.6288868</lon>
|
||||||
|
<ktas>10</ktas>
|
||||||
|
<on-ground>1</on-ground>
|
||||||
|
</wp>
|
||||||
|
<wp>
|
||||||
|
<name>on12</name>
|
||||||
|
<lat>59.5347749</lat>
|
||||||
|
<lon>-1.6284227</lon>
|
||||||
|
<ktas>10</ktas>
|
||||||
|
<on-ground>1</on-ground>
|
||||||
|
</wp>
|
||||||
|
<wp>
|
||||||
|
<name>END</name>
|
||||||
|
</wp>
|
||||||
|
</flightplan>
|
||||||
|
</PropertyList>
|
15415
test_suite/test_data/AI/Traffic/L/LOG.xml
Normal file
15415
test_suite/test_data/AI/Traffic/L/LOG.xml
Normal file
File diff suppressed because it is too large
Load diff
|
@ -22,10 +22,11 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "test_suite/FGTestApi/testGlobals.hxx"
|
||||||
#include "test_suite/FGTestApi/NavDataCache.hxx"
|
#include "test_suite/FGTestApi/NavDataCache.hxx"
|
||||||
#include "test_suite/FGTestApi/TestDataLogger.hxx"
|
#include "test_suite/FGTestApi/TestDataLogger.hxx"
|
||||||
#include "test_suite/FGTestApi/TestPilot.hxx"
|
#include "test_suite/FGTestApi/TestPilot.hxx"
|
||||||
#include "test_suite/FGTestApi/testGlobals.hxx"
|
|
||||||
|
|
||||||
#include <AIModel/AIAircraft.hxx>
|
#include <AIModel/AIAircraft.hxx>
|
||||||
#include <AIModel/AIFlightPlan.hxx>
|
#include <AIModel/AIFlightPlan.hxx>
|
||||||
|
@ -38,6 +39,8 @@
|
||||||
#include <Navaids/navrecord.hxx>
|
#include <Navaids/navrecord.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace flightgear;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Set up function for each test.
|
// Set up function for each test.
|
||||||
|
@ -237,6 +240,52 @@ void AIFlightPlanTests::testAIFlightPlan()
|
||||||
CPPUNIT_ASSERT_EQUAL(static_cast<FGAIWaypoint*>(nullptr), aiFP->getNextWaypoint());
|
CPPUNIT_ASSERT_EQUAL(static_cast<FGAIWaypoint*>(nullptr), aiFP->getNextWaypoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AIFlightPlanTests::testAIFlightPlanLeftCircle()
|
||||||
|
{
|
||||||
|
auto aiFP = new FGAIFlightPlan;
|
||||||
|
aiFP->setName("Bob");
|
||||||
|
aiFP->setRunway("24");
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string{"Bob"}, aiFP->getName());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string{"24"}, aiFP->getRunway());
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL(0, aiFP->getNrOfWayPoints());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(static_cast<FGAIWaypoint*>(nullptr), aiFP->getPreviousWaypoint());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(static_cast<FGAIWaypoint*>(nullptr), aiFP->getCurrentWaypoint());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(static_cast<FGAIWaypoint*>(nullptr), aiFP->getNextWaypoint());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(0, aiFP->getLeg());
|
||||||
|
|
||||||
|
FGPositioned::TypeFilter ty(FGPositioned::VOR);
|
||||||
|
auto cache = flightgear::NavDataCache::instance();
|
||||||
|
auto shannonVOR = cache->findClosestWithIdent("SHA", SGGeod::fromDeg(-8, 52), &ty);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string{"SHANNON VOR-DME"}, shannonVOR->name());
|
||||||
|
auto wp1 = new FGAIWaypoint;
|
||||||
|
wp1->setPos(shannonVOR->geod());
|
||||||
|
wp1->setName("testWp_0");
|
||||||
|
wp1->setOn_ground(true);
|
||||||
|
wp1->setGear_down(true);
|
||||||
|
wp1->setSpeed(10);
|
||||||
|
aiFP->addWaypoint(wp1);
|
||||||
|
|
||||||
|
auto lastWp = wp1;
|
||||||
|
|
||||||
|
int course = 0;
|
||||||
|
|
||||||
|
for(int i = 1; i <= 10; i++) {
|
||||||
|
auto wp = new FGAIWaypoint;
|
||||||
|
course += 10;
|
||||||
|
const auto g1 = SGGeodesy::direct(lastWp->getPos(), course, SG_NM_TO_METER * 5.0);
|
||||||
|
wp->setPos(g1);
|
||||||
|
wp->setName("testWp_" + i);
|
||||||
|
wp->setOn_ground(true);
|
||||||
|
wp->setGear_down(true);
|
||||||
|
wp->setSpeed(10);
|
||||||
|
aiFP->addWaypoint(wp);
|
||||||
|
lastWp = wp;
|
||||||
|
}
|
||||||
|
CPPUNIT_ASSERT_EQUAL(aiFP->getNrOfWayPoints(), 11);
|
||||||
|
}
|
||||||
|
|
||||||
void AIFlightPlanTests::testAIFlightPlanLoadXML()
|
void AIFlightPlanTests::testAIFlightPlanLoadXML()
|
||||||
{
|
{
|
||||||
const auto xml = R"(<?xml version="1.0" encoding="UTF-8"?>
|
const auto xml = R"(<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
@ -279,3 +328,36 @@ void AIFlightPlanTests::testAIFlightPlanLoadXML()
|
||||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, wp2->getFlaps(), 0.1);
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, wp2->getFlaps(), 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AIFlightPlanTests::testLeftTurnFlightplanXML()
|
||||||
|
{
|
||||||
|
std::unique_ptr<FGAIFlightPlan> aiFP(new FGAIFlightPlan);
|
||||||
|
const auto fpath = SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "AI"/"Flightplan"/"left_onground.xml";
|
||||||
|
|
||||||
|
std::fstream fs(fpath.c_str());
|
||||||
|
|
||||||
|
bool ok = aiFP->readFlightplan(fs, sg_location("In-memory test_ai_fp.xml"));
|
||||||
|
CPPUNIT_ASSERT(ok);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL(false, aiFP->getCurrentWaypoint()->getInAir());
|
||||||
|
|
||||||
|
auto wp2 = aiFP->getNextWaypoint();
|
||||||
|
CPPUNIT_ASSERT_EQUAL(false, wp2->getInAir());
|
||||||
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, wp2->getSpeed(), 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AIFlightPlanTests::testRightTurnFlightplanXML()
|
||||||
|
{
|
||||||
|
std::unique_ptr<FGAIFlightPlan> aiFP(new FGAIFlightPlan);
|
||||||
|
const auto fpath = SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "AI"/"Flightplan"/"right_onground.xml";
|
||||||
|
|
||||||
|
std::fstream fs(fpath.c_str());
|
||||||
|
|
||||||
|
bool ok = aiFP->readFlightplan(fs, sg_location("In-memory test_ai_fp.xml"));
|
||||||
|
CPPUNIT_ASSERT(ok);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL(false, aiFP->getCurrentWaypoint()->getInAir());
|
||||||
|
|
||||||
|
auto wp2 = aiFP->getNextWaypoint();
|
||||||
|
CPPUNIT_ASSERT_EQUAL(false, wp2->getInAir());
|
||||||
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, wp2->getSpeed(), 0.1);
|
||||||
|
}
|
||||||
|
|
|
@ -34,7 +34,10 @@ class AIFlightPlanTests : public CppUnit::TestFixture
|
||||||
// Set up the test suite.
|
// Set up the test suite.
|
||||||
CPPUNIT_TEST_SUITE(AIFlightPlanTests);
|
CPPUNIT_TEST_SUITE(AIFlightPlanTests);
|
||||||
CPPUNIT_TEST(testAIFlightPlan);
|
CPPUNIT_TEST(testAIFlightPlan);
|
||||||
|
CPPUNIT_TEST(testAIFlightPlanLeftCircle);
|
||||||
CPPUNIT_TEST(testAIFlightPlanLoadXML);
|
CPPUNIT_TEST(testAIFlightPlanLoadXML);
|
||||||
|
CPPUNIT_TEST(testLeftTurnFlightplanXML);
|
||||||
|
CPPUNIT_TEST(testRightTurnFlightplanXML);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,5 +50,8 @@ public:
|
||||||
|
|
||||||
// The tests.
|
// The tests.
|
||||||
void testAIFlightPlan();
|
void testAIFlightPlan();
|
||||||
|
void testAIFlightPlanLeftCircle();
|
||||||
void testAIFlightPlanLoadXML();
|
void testAIFlightPlanLoadXML();
|
||||||
|
void testLeftTurnFlightplanXML();
|
||||||
|
void testRightTurnFlightplanXML();
|
||||||
};
|
};
|
||||||
|
|
|
@ -124,5 +124,5 @@ void AIManagerTests::testAircraftWaypoints()
|
||||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(250.0, aiAircraft->getSpeed(), 1);
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(250.0, aiAircraft->getSpeed(), 1);
|
||||||
|
|
||||||
std::unique_ptr<FGAIFlightPlan> aiFP(new FGAIFlightPlan);
|
std::unique_ptr<FGAIFlightPlan> aiFP(new FGAIFlightPlan);
|
||||||
ai->setFlightPlan(std::move(aiFP));
|
ai->setFlightPlan(std::move(aiFP));
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,30 +85,11 @@ void GroundnetTests::testShortestRoute()
|
||||||
{
|
{
|
||||||
FGAirportRef egph = FGAirport::getByIdent("EGPH");
|
FGAirportRef egph = FGAirport::getByIdent("EGPH");
|
||||||
|
|
||||||
FGAISchedule* schedule = new FGAISchedule;
|
|
||||||
|
|
||||||
FGAIAircraft* aiAircraft = new FGAIAircraft{schedule};
|
|
||||||
|
|
||||||
// std::cout << "*** Start ***\n";
|
|
||||||
|
|
||||||
FGGroundNetwork* network = egph->groundNetwork();
|
FGGroundNetwork* network = egph->groundNetwork();
|
||||||
|
|
||||||
FGParkingRef startParking = network->findParkingByName("main-apron10");
|
FGParkingRef startParking = network->findParkingByName("main-apron10");
|
||||||
|
|
||||||
FGRunwayRef runway = egph->getRunwayByIndex(0);
|
FGRunwayRef runway = egph->getRunwayByIndex(0);
|
||||||
|
|
||||||
// std::cout << startParking->getName() << "\n";
|
|
||||||
|
|
||||||
// std::cout << runway->name() << " " << runway->begin() << " " << runway->end() << "\n";
|
|
||||||
|
|
||||||
FGTaxiNodeRef end = network->findNearestNodeOnRunway(runway->threshold());
|
FGTaxiNodeRef end = network->findNearestNodeOnRunway(runway->threshold());
|
||||||
|
|
||||||
// std::cout << end->geod() << "\n";
|
|
||||||
|
|
||||||
FGTaxiRoute route = network->findShortestRoute(startParking, end);
|
FGTaxiRoute route = network->findShortestRoute(startParking, end);
|
||||||
|
|
||||||
// std::cout << route.size() << "\n";
|
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(true, network->exists());
|
CPPUNIT_ASSERT_EQUAL(true, network->exists());
|
||||||
CPPUNIT_ASSERT_EQUAL(25, route.size());
|
CPPUNIT_ASSERT_EQUAL(25, route.size());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue