From def866a82b1ab8cb93b79b46f2b8c6d26ff93341 Mon Sep 17 00:00:00 2001 From: hwinkel Date: Sun, 29 Oct 2023 22:18:43 +0100 Subject: [PATCH] ADD: updated tests --- include/Entities/Movement.hpp | 9 ------- libs/nlohmannJSON | 2 +- tests/test_EntityClass.cpp | 8 +++--- tests/test_MovementClass.cpp | 35 ++++++++++++++++++++++++++ tests/test_Tracklist.cpp | 46 +---------------------------------- 5 files changed, 41 insertions(+), 59 deletions(-) diff --git a/include/Entities/Movement.hpp b/include/Entities/Movement.hpp index 2252db2..fe36c28 100644 --- a/include/Entities/Movement.hpp +++ b/include/Entities/Movement.hpp @@ -12,15 +12,6 @@ namespace Entities { - - - - - - - - - class Movement { public: diff --git a/libs/nlohmannJSON b/libs/nlohmannJSON index 5d27543..58d6aa5 160000 --- a/libs/nlohmannJSON +++ b/libs/nlohmannJSON @@ -1 +1 @@ -Subproject commit 5d2754306d67d1e654a1a34e1d2e74439a9d53b3 +Subproject commit 58d6aa58316a84fc770bdd0409934cdfdf0697dc diff --git a/tests/test_EntityClass.cpp b/tests/test_EntityClass.cpp index 60f0b91..10a4b20 100644 --- a/tests/test_EntityClass.cpp +++ b/tests/test_EntityClass.cpp @@ -19,11 +19,11 @@ class Ship : public Entities::Entity Ship(SimCore::Identifier OwnID, std::string EntityName, WHISPER::SourceType ownType, - SimCore::EntityKind EntityKind, + SimCore::Kind::EntityKind EntityKind, std::uint32_t GroundTruthPort, - std::uint32_t CommandPort + ushort CommandPort ): - Entity( OwnID,EntityName,ownType, EntityKind, GroundTruthPort, CommandPort,false) + Entity( OwnID,EntityName,ownType, EntityKind,SimCore::Side::EntitySide::FRIEND, "127.0.0.1",GroundTruthPort, CommandPort,false) { SimCore::Position pos1; pos1.setGeodesicPos(55, 6, 0); @@ -59,7 +59,7 @@ SCENARIO("Testing the SimCore Sensor") GIVEN("different Attributes for a Track in different forms") { SimCore::Identifier ID1; - Ship Ship(ID1,"FGSHamburg",WHISPER::SourceType::ENTITY,SimCore::EntityKind::SURFACE,8000,8001); + Ship Ship(ID1,"FGSHamburg",WHISPER::SourceType::ENTITY,SimCore::Kind::EntityKind::SURFACE,8000,8001); Ship.start(); std::this_thread::sleep_for(std::chrono::milliseconds(10000)); Ship.stop(); diff --git a/tests/test_MovementClass.cpp b/tests/test_MovementClass.cpp index 7c2ad3a..cd2e446 100644 --- a/tests/test_MovementClass.cpp +++ b/tests/test_MovementClass.cpp @@ -11,8 +11,39 @@ #include +struct KinVec{ + double x,y,z; +} +struct MovementVec{ + double dSpd,dClb,dCrs; +} +KinVec Generate_Kin_Vect(MovementVec Mov_Dat, LLA_Rad LLA_rCoord) +{ + KinVec Result; + + //Transform Mov_Dat to topocentric vector + UVW UVW_Coord; + + UVW_Coord.dU = Mov_Dat.dSpd * cos(Mov_Dat.dClb) * sin(Mov_Dat.dCrs); + UVW_Coord.dV = Mov_Dat.dSpd * cos(Mov_Dat.dClb) * cos(Mov_Dat.dCrs); + UVW_Coord.dW = Mov_Dat.dSpd * sin(Mov_Dat.dClb); + + //Transform topocentric vector to geocentric vector + + Result.x = -UVW_Coord.dU * sin(LLA_rCoord.dLon) - + UVW_Coord.dV * sin(LLA_rCoord.dLat) * cos(LLA_rCoord.dLon) + + UVW_Coord.dW * cos(LLA_rCoord.dLat) * cos(LLA_rCoord.dLon); + + Result.y = UVW_Coord.dU * cos(LLA_rCoord.dLon) - + UVW_Coord.dV * sin(LLA_rCoord.dLat) * sin(LLA_rCoord.dLon) + + UVW_Coord.dW * cos(LLA_rCoord.dLat) * sin(LLA_rCoord.dLon); + + Result.z = UVW_Coord.dV * cos(LLA_rCoord.dLat) + + UVW_Coord.dW * sin(LLA_rCoord.dLat); + return Result; +}; SCENARIO("Testing the SimCore Sensor") @@ -61,6 +92,10 @@ SCENARIO("Testing the SimCore Sensor") i += 0.5; } + MovementVec movc; + movc.dSpd = 10; + movc.dClb = 0; + movc.dCrs = 0; // LOG_S(INFO)<< mov.getEulerAngles(); THEN("check if Track attributes are correct") diff --git a/tests/test_Tracklist.cpp b/tests/test_Tracklist.cpp index f5e41ff..1bb825d 100644 --- a/tests/test_Tracklist.cpp +++ b/tests/test_Tracklist.cpp @@ -25,32 +25,6 @@ SCENARIO("Testing the SimCore Sensor") - SimCore::Identifier OwnID; - SimCore::IdentifierMaker IDMaker; - auto RadarID = IDMaker.getNewIdentifier(1,SimCore::INTERNAL); - auto TrackID1 = IDMaker.getNewIdentifier(1,SimCore::INTERNAL); - LOG_S(INFO)<serialize(); - - TrackList::TrackList InternalTracklist(OwnID); - TrackList::SensorData sensor1; - sensor1.sensorID = *RadarID.get(); - sensor1.Sensorname = "TRS-3D"; - - LOG_S(INFO)<<"making radar track"; - auto Track1 = std::make_shared(*TrackID1.get(),"test",SimCore::EntityKind::SURFACE); - - SimCore::Position pos1 ; - pos1.setGeodesicPos(55, 6, 0); - Track1->setPosition(pos1); - - LOG_S(INFO)<<"adding radar track"; - - InternalTracklist.addTrack(Track1, sensor1); - - - LOG_S(INFO)<<"radar track added"; - - @@ -60,26 +34,8 @@ SCENARIO("Testing the SimCore Sensor") THEN("check if Track attributes are correct") { - REQUIRE(InternalTracklist.size() == 1); - REQUIRE(InternalTracklist.getTrack(Track1->getIdentifier())->getSpeed() == 0); - - LOG_S(INFO)<<"add same track again"; - - Track1->Speed.setValue(10); - - InternalTracklist.addTrack(Track1, sensor1); - REQUIRE(InternalTracklist.getTrack(Track1->getIdentifier())->getSpeed() == 10); - - REQUIRE(InternalTracklist.size() == 1); - - // std::this_thread::sleep_for(std::chrono::milliseconds(2000)); // REQUIRE(InternalTracklist.size() == 1); - // std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - // REQUIRE(InternalTracklist.size() == 1); - - - InternalTracklist.stopSanitizer(); - + } //THEN } // WHEN