ADD: use of new sensor messages
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
#include "DirectCommunicationClient.hpp"
|
||||
#include "Entities/SensorControl.hpp"
|
||||
#include "Entities/SensorManager.hpp"
|
||||
#include "SimCore/Messages/SensorData.hpp"
|
||||
#include "SimCore/Messages/SensorTrack.hpp"
|
||||
#include "SimCore/Messages/SimTrack.hpp"
|
||||
#include "SimCore/Position.hpp"
|
||||
#include "nlohmann/json_fwd.hpp"
|
||||
@@ -22,18 +24,20 @@ double fRand(double fMin, double fMax)
|
||||
double f = (double)rand() / RAND_MAX;
|
||||
return fMin + f * (fMax - fMin);
|
||||
}
|
||||
void sendRandomTrack(std::shared_ptr<DirectCommunication::DirectCommunicationClient> client, int number)
|
||||
void sendRandomTrack(std::shared_ptr<DirectCommunication::DirectCommunicationClient> client,std::shared_ptr<Sensor::SensorControl> sensor, int number)
|
||||
{
|
||||
for (int i = 0; i < number; i++) {
|
||||
std::string name = "test1-" + std::to_string(i);
|
||||
SimCore::SimTrack track(name,SimCore::Kind::EntityKind::SURFACE,SimCore::Side::NEUTRAL);
|
||||
auto simtrack = std::make_shared<SimCore::SimTrack>(name,SimCore::Kind::EntityKind::SURFACE,SimCore::Side::NEUTRAL);
|
||||
auto track = std::make_shared<SimCore::SensorTrack>(simtrack,sensor);
|
||||
// LOG_S(INFO)<<track->getSensorData()->getName();
|
||||
SimCore::Position pos;
|
||||
double lat = fRand(-90, 90);
|
||||
double lon = fRand(-180, 180);
|
||||
|
||||
pos.setGeodesicPos( lat, lon, 0);
|
||||
track.setPosition(pos);
|
||||
client->sendMessage(track.buildMessage());
|
||||
track->setPosition(pos);
|
||||
client->sendMessage(track->buildMessage());
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
|
||||
}
|
||||
@@ -42,16 +46,16 @@ for (int i = 0; i < number; i++) {
|
||||
|
||||
void sendRandomTracktoManager(std::shared_ptr<Entities::SensorManager> SensorManager_)
|
||||
{
|
||||
for (int i = 0; i < 5; i++) {
|
||||
std::string name = "test1-" + std::to_string(i);
|
||||
SimCore::SimTrack track(name,SimCore::Kind::EntityKind::SURFACE,SimCore::Side::NEUTRAL);
|
||||
SimCore::Position pos;
|
||||
double lat = fRand(-90, 90);
|
||||
double lon = fRand(-180, 180);
|
||||
// for (int i = 0; i < 5; i++) {
|
||||
// std::string name = "test1-" + std::to_string(i);
|
||||
// SimCore::SensorTrack track(name,SimCore::Kind::EntityKind::SURFACE,SimCore::Side::NEUTRAL);
|
||||
// SimCore::Position pos;
|
||||
// double lat = fRand(-90, 90);
|
||||
// double lon = fRand(-180, 180);
|
||||
|
||||
pos.setGeodesicPos( lat, lon, 0);
|
||||
track.setPosition(pos);
|
||||
}
|
||||
// pos.setGeodesicPos( lat, lon, 0);
|
||||
// track.setPosition(pos);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@@ -59,39 +63,48 @@ for (int i = 0; i < 5; i++) {
|
||||
|
||||
auto id0 = SimCore::Identifier();
|
||||
LOG_S(INFO)<<id0.getUUID();
|
||||
auto control = std::make_unique<Sensor::SensorControl>(id0.getUUID(),"Sensor", "127.0.0.1", SimCore::SensorKinds::RADAR);
|
||||
auto control = std::make_shared<Sensor::SensorControl>(id0.getUUID(),"Sensor", "127.0.0.1", SimCore::SensorKinds::RADAR);
|
||||
auto test = std::static_pointer_cast<SimCore::SensorData>(control);
|
||||
LOG_S(INFO)<< test->getSensorDataAsJson();
|
||||
|
||||
auto client = std::make_shared<DirectCommunication::DirectCommunicationClient>(5557,"127.0.0.1",id0.getUUID());
|
||||
SensorManager_->addSensorLocal(std::move(control));
|
||||
SensorManager_->addSensorLocal(control);
|
||||
// sendRandomTrack(client,5);
|
||||
|
||||
auto id1 = SimCore::Identifier();
|
||||
auto control1 = std::make_unique<Sensor::SensorControl>(id1.getUUID(),"Sensor1", "127.0.0.1", SimCore::SensorKinds::RADAR);
|
||||
auto control1 = std::make_shared<Sensor::SensorControl>(id1.getUUID(),"Sensor1", "127.0.0.1", SimCore::SensorKinds::RADAR);
|
||||
auto client1 = std::make_shared<DirectCommunication::DirectCommunicationClient>(5557,"127.0.0.1",id1.getUUID());
|
||||
SensorManager_->addSensorLocal(std::move(control1));
|
||||
SensorManager_->addSensorLocal(control1);
|
||||
// sendRandomTrack(client1,5);
|
||||
|
||||
auto id2 = SimCore::Identifier();
|
||||
auto control2 = std::make_unique<Sensor::SensorControl>(id2.getUUID(),"Sensor2", "127.0.0.1", SimCore::SensorKinds::VISUAL);
|
||||
auto control2 = std::make_shared<Sensor::SensorControl>(id2.getUUID(),"Sensor2", "127.0.0.1", SimCore::SensorKinds::VISUAL);
|
||||
auto client2 = std::make_shared<DirectCommunication::DirectCommunicationClient>(5557,"127.0.0.1",id2.getUUID());
|
||||
SensorManager_->addSensorLocal(std::move(control2));
|
||||
SensorManager_->addSensorLocal(control2);
|
||||
// sendRandomTrack(client2,5);
|
||||
|
||||
auto id3 = SimCore::Identifier();
|
||||
auto control3 = std::make_unique<Sensor::SensorControl>(id3.getUUID(),"Sensor3", "127.0.0.1", SimCore::SensorKinds::ESM);
|
||||
auto control3 = std::make_shared<Sensor::SensorControl>(id3.getUUID(),"Sensor3", "127.0.0.1", SimCore::SensorKinds::ESM);
|
||||
auto client3 = std::make_shared<DirectCommunication::DirectCommunicationClient>(5557,"127.0.0.1",id3.getUUID());
|
||||
SensorManager_->addSensorLocal(std::move(control3));
|
||||
sendRandomTrack(client2,5);
|
||||
SensorManager_->addSensorLocal(control3);
|
||||
sendRandomTrack(client2,control3,5);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
std::string name = "identical-" + std::to_string(i);
|
||||
SimCore::SimTrack track(name,SimCore::Kind::EntityKind::SURFACE,SimCore::Side::NEUTRAL);
|
||||
auto Simtrack = std::make_shared<SimCore::SimTrack>(name,SimCore::Kind::EntityKind::SURFACE,SimCore::Side::NEUTRAL);
|
||||
SimCore::SensorTrack track(Simtrack);
|
||||
|
||||
// LOG_S(INFO)<<track.getSensorData()->getID().getUUID();
|
||||
|
||||
SimCore::Position pos;
|
||||
double lat = fRand(-90, 90);
|
||||
double lon = fRand(-180, 180);
|
||||
|
||||
pos.setGeodesicPos( lat, lon, 0);
|
||||
track.setPosition(pos);
|
||||
|
||||
client->sendMessage(track.buildMessage());
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
|
||||
client1->sendMessage(track.buildMessage());
|
||||
@@ -140,6 +153,7 @@ void startSensors(SimCore::Identifier ownid, std::string GroundTruthAddr_,ushort
|
||||
RadarPod->setComponent("Radar");
|
||||
|
||||
SensorManager_->startSensor(RadarPod, SimCore::SensorKinds::RADAR);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -151,14 +165,14 @@ SCENARIO("Testing the SimCore SensorManager")
|
||||
|
||||
auto PodController_ = std::make_shared<kubecontrol::PodController>("docs/config");
|
||||
|
||||
|
||||
auto SensorManager_ = std::make_shared<Entities::SensorManager>(id, PodController_,5557);
|
||||
auto ownShip = std::make_shared<SimCore::SimTrack>(id,"Test Ship", SimCore::Kind::EntityKind::SURFACE,SimCore::Side::EntitySide::FRIEND);
|
||||
auto SensorManager_ = std::make_shared<Entities::SensorManager>(ownShip, PodController_,5557);
|
||||
|
||||
|
||||
startSensors(id, "239.0.0.1", 7000, 5557, SensorManager_);
|
||||
|
||||
|
||||
|
||||
|
||||
WHEN("constructing Track Object with data")
|
||||
{
|
||||
|
||||
@@ -172,7 +186,7 @@ SCENARIO("Testing the SimCore SensorManager")
|
||||
|
||||
REQUIRE(PodController_->getInfoForAllPods().size() == 0);
|
||||
|
||||
|
||||
SensorManager_->stop();
|
||||
} //THEN
|
||||
} // WHEN
|
||||
} // GIVEN
|
||||
@@ -187,8 +201,9 @@ SCENARIO("Testing the SimCore SensorManager with local sensors")
|
||||
|
||||
auto PodController_ = std::make_shared<kubecontrol::PodController>("docs/config");
|
||||
|
||||
auto ownShip = std::make_shared<SimCore::SimTrack>(id,"Test Ship", SimCore::Kind::EntityKind::SURFACE,SimCore::Side::EntitySide::FRIEND);
|
||||
|
||||
auto SensorManager_ = std::make_shared<Entities::SensorManager>(id, PodController_,5557);
|
||||
auto SensorManager_ = std::make_shared<Entities::SensorManager>(ownShip, PodController_,5557);
|
||||
|
||||
|
||||
sendRandomTracktoManager(SensorManager_);
|
||||
@@ -222,6 +237,7 @@ SCENARIO("Testing the SimCore SensorManager with local sensors")
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
|
||||
|
||||
SensorManager_->stop();
|
||||
|
||||
} //THEN
|
||||
} // WHEN
|
||||
|
||||
Reference in New Issue
Block a user