ADD: added Movement calculation and a Tracklist class
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <tuple>
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
#include <Entities/Entity.hpp>
|
||||
@@ -25,21 +26,35 @@ class Ship : public Entities::Entity
|
||||
std::string CommandIPAddress):
|
||||
Entity( OwnID,EntityName,ownType, ParentID, EntityKind, GroundTruthPort, CommandPort, CommandIPAddress)
|
||||
{
|
||||
this->ownShipPosition_ = std::make_shared<SimCore::Position>();
|
||||
this->ownShipOrientation_ = std::make_shared<SimCore::Orientation>();
|
||||
SimCore::Position pos1;
|
||||
pos1.setGeodesicPos(55, 6, 0);
|
||||
Movement_.setPosition(pos1);
|
||||
Movement_.setCourse(0);
|
||||
Movement_.setSpeed(100);
|
||||
|
||||
LOG_S(INFO)<<std::endl<<Movement_.getPosition().getGeodesicPos();
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void specificPhysicsCalculations(std::chrono::milliseconds::rep duration) override
|
||||
{
|
||||
SimCore::Position pos1;
|
||||
pos1.setGeodesicPos(55, 6, 0);
|
||||
|
||||
|
||||
LOG_S(INFO)<<"calculating every " << duration << "milliseconds";
|
||||
|
||||
LOG_S(INFO)<<std::endl<<Movement_.getPosition().getGeodesicPos();
|
||||
double distance, bearing1;
|
||||
std::tie(distance, bearing1) = Movement_.getPosition().distanceBearingToPosition(pos1);
|
||||
LOG_S(INFO)<<"distance from start is:" << distance;
|
||||
LOG_S(INFO)<<"calculating every " << duration << " milliseconds";
|
||||
};
|
||||
|
||||
void specificReloadCharacteristicts() override
|
||||
{
|
||||
|
||||
|
||||
LOG_S(INFO)<<"loading specifications";
|
||||
};
|
||||
};
|
||||
@@ -55,7 +70,7 @@ SCENARIO("Testing the SimCore Sensor")
|
||||
SimCore::Identifier ID1(0,2,false);
|
||||
Ship Ship(ID1,"FGS Hamburg",WHISPER::SourceType::SHIP,IDParent,SimCore::EntityKind::SURFACE,8000,8001,"127.0.0.1");
|
||||
Ship.start();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10000));
|
||||
Ship.stop();
|
||||
WHEN("constructing Track Object with data")
|
||||
{
|
||||
|
||||
78
tests/test_MovementClass.cpp
Normal file
78
tests/test_MovementClass.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
|
||||
#include "Entities/Movement.hpp"
|
||||
#include "SimCore/Position.hpp"
|
||||
#include "SimCore/SimCore.hpp"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
#include <loguru.hpp>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SCENARIO("Testing the SimCore Sensor")
|
||||
{
|
||||
GIVEN("different Attributes for a Movement ")
|
||||
{
|
||||
SimCore::Position pos1;
|
||||
|
||||
WHEN("constructing Track Object with data")
|
||||
{
|
||||
pos1.setGeodesicPos(55, 6, 0);
|
||||
LOG_S(INFO)<<"LAT: "<<pos1.getGeodesicPos()(SimCore::LATITUDE)<<" LON: "<< pos1.getGeodesicPos()(SimCore::LONGITUDE)<< " H: "<< pos1.getGeodesicPos()(SimCore::HEIGHT);
|
||||
|
||||
Entities::Movement mov(pos1);
|
||||
mov.setCourse(90);
|
||||
mov.setSpeed(100);//m/s
|
||||
mov.setPitch(0);
|
||||
|
||||
mov.updatePosition(10000);// 10 seconds
|
||||
|
||||
LOG_S(INFO)<<"LAT: "<<mov.getPosition().getGeodesicPos()(SimCore::LATITUDE)<<" LON: "<< mov.getPosition().getGeodesicPos()(SimCore::LONGITUDE)<< " H: "<< mov.getPosition().getGeodesicPos()(SimCore::HEIGHT);
|
||||
|
||||
GeographicLib::Geodesic geod(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
|
||||
double h2, lat2,lon2;
|
||||
geod.Direct(55,6,90,1000,lat2,lon2);
|
||||
SimCore::Position pos2;
|
||||
pos2.setGeodesicPos(lat2, lon2, 0);
|
||||
GeographicLib::GeodesicLine line = geod.InverseLine(55,6 , lat2, lon2);
|
||||
LOG_S(INFO)<<"distance: "<<line.Distance()<< " lat2: "<< lat2 << " lon2: " << lon2;
|
||||
|
||||
|
||||
Entities::Movement mov2(pos1);
|
||||
mov2.setCourse(0);//degree
|
||||
mov2.setSpeed(100);//m/s
|
||||
mov2.setPitch(45);//degree
|
||||
|
||||
LOG_S(INFO)<<"LAT: "<<mov2.getPosition().getGeodesicPos()(SimCore::LATITUDE)<<" LON: "<< mov2.getPosition().getGeodesicPos()(SimCore::LONGITUDE)<< " H: "<< mov2.getPosition().getGeodesicPos()(SimCore::HEIGHT);
|
||||
|
||||
double Vd = 100 * sin(45* M_PI / 180.0);
|
||||
double h = Vd*10;
|
||||
LOG_S(INFO)<<"höhe: "<< h;
|
||||
double i;
|
||||
|
||||
for ( i = 0; i <= 10; ) {
|
||||
mov2.updatePosition(500);
|
||||
i += 0.5;
|
||||
}
|
||||
|
||||
// LOG_S(INFO)<< mov.getEulerAngles();
|
||||
|
||||
THEN("check if Track attributes are correct")
|
||||
{
|
||||
|
||||
// LOG_S(INFO)<<mov.getPosition().getGeodesicPos()(SimCore::LATITUDE);
|
||||
REQUIRE((pos2.getGeocentricPos() - mov.getPosition().getGeocentricPos()).norm() <= 0.1);
|
||||
REQUIRE((h - mov2.getPosition().getGeodesicPos()(SimCore::HEIGHT)) <= 0.1);
|
||||
|
||||
|
||||
|
||||
} //THEN
|
||||
} // WHEN
|
||||
} // GIVEN
|
||||
} //SCENARIO
|
||||
87
tests/test_Tracklist.cpp
Normal file
87
tests/test_Tracklist.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
|
||||
#include "Entities/Tracklist/Tracklist.hpp"
|
||||
#include "Entities/Tracklist/TracklistItem.hpp"
|
||||
#include "SimCore/IdentifierMaker.hpp"
|
||||
#include "SimCore/Messages/RadarTrack.hpp"
|
||||
#include "SimCore/Position.hpp"
|
||||
#include "WHISPER/Messages/Message.hpp"
|
||||
#include <SimCore/Identifier.hpp>
|
||||
#include <SimCore/SimCore.hpp>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
#include <loguru.hpp>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SCENARIO("Testing the SimCore Sensor")
|
||||
{
|
||||
GIVEN("different Attributes for a Track in different forms")
|
||||
{
|
||||
|
||||
|
||||
|
||||
SimCore::Identifier OwnID(0,1,false);
|
||||
SimCore::IdentifierMaker IDMaker;
|
||||
auto RadarID = IDMaker.getNewIdentifier(1,SimCore::INTERNAL);
|
||||
auto TrackID1 = IDMaker.getNewIdentifier(1,SimCore::INTERNAL);
|
||||
LOG_S(INFO)<<TrackID1->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<SimCore::RadarTrack>(WHISPER::SourceType::SENSOR,*TrackID1.get());
|
||||
|
||||
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";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
WHEN("constructing Track Object with data")
|
||||
{
|
||||
|
||||
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->setSpeed(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
|
||||
} // GIVEN
|
||||
} //SCENARIO
|
||||
Reference in New Issue
Block a user