ADD: added Json Library,

FIX: fixed issue with dealing with GroundThruthTracks to using sharedpointer
This commit is contained in:
Henry Winkel
2023-02-17 09:03:38 +01:00
parent 9d76994e31
commit 422fdd4e7a
4 changed files with 32 additions and 12 deletions

3
.gitmodules vendored
View File

@@ -1,3 +1,6 @@
[submodule "libs/SimCore"] [submodule "libs/SimCore"]
path = libs/SimCore path = libs/SimCore
url = ssh://git@dev-gitea.ftewa.ti.unibw-hamburg.de:12000/hwinkel/SimCore.git url = ssh://git@dev-gitea.ftewa.ti.unibw-hamburg.de:12000/hwinkel/SimCore.git
[submodule "libs/json"]
path = libs/json
url = https://github.com/nlohmann/json.git

View File

@@ -15,7 +15,7 @@
#include <memory> #include <memory>
#include <thread> #include <thread>
namespace SimCore { namespace Entities {
class Sensor { class Sensor {
public: public:
@@ -25,7 +25,7 @@ namespace SimCore {
void stop(); void stop();
protected: protected:
std::shared_ptr<WHISPER::threadSafeQueue<SimCore::GroundTruthTrack>> incommingTrackMessages = nullptr; std::shared_ptr<WHISPER::threadSafeQueue<std::shared_ptr<SimCore::GroundTruthTrack>>> incommingTrackMessages = nullptr;
std::shared_ptr<WHISPER::threadSafeQueue<WHISPER::Message>> incommingGroundThruthMessages = nullptr; std::shared_ptr<WHISPER::threadSafeQueue<WHISPER::Message>> incommingGroundThruthMessages = nullptr;
@@ -37,7 +37,7 @@ namespace SimCore {
virtual void specificSensorCalculations() = 0; virtual void specificSensorCalculations() = 0;
virtual void specificReloadCharacteristicts() = 0; virtual void specificReloadCharacteristicts() = 0;
std::shared_ptr<Position> ownShipPosition_ = nullptr; std::shared_ptr<SimCore::Position> ownShipPosition_ = nullptr;
private: private:

1
libs/json Submodule

Submodule libs/json added at b2306145e1

View File

@@ -4,10 +4,11 @@
#include "SimCore/SimCore.hpp" #include "SimCore/SimCore.hpp"
#include "SimCore/UtilFunctions.hpp" #include "SimCore/UtilFunctions.hpp"
#include "WHISPER/Messages/Message.hpp" #include "WHISPER/Messages/Message.hpp"
#include <SimCore/Templates/Sensor.hpp> #include <Entities/Sensor.hpp>
#include <memory> #include <memory>
#include <utility>
namespace SimCore { namespace Entities {
Sensor::Sensor(SimCore::Identifier OwnID, SimCore::Identifier ParentID, SimCore::SensorKinds SensorKind,std::uint32_t GroundTruthPort, std::uint32_t ParentPort,std::string ParentIPAddress): Sensor::Sensor(SimCore::Identifier OwnID, SimCore::Identifier ParentID, SimCore::SensorKinds SensorKind,std::uint32_t GroundTruthPort, std::uint32_t ParentPort,std::string ParentIPAddress):
OwnID_(OwnID),ParentID_(ParentID),SensorKind_(SensorKind),GroundTruthPort_(GroundTruthPort),ParentPort_(ParentPort),ParentIPAddress_(ParentIPAddress) OwnID_(OwnID),ParentID_(ParentID),SensorKind_(SensorKind),GroundTruthPort_(GroundTruthPort),ParentPort_(ParentPort),ParentIPAddress_(ParentIPAddress)
@@ -23,7 +24,7 @@ namespace SimCore {
incommingParentMessages = std::make_shared<WHISPER::threadSafeQueue<WHISPER::Message>>(); incommingParentMessages = std::make_shared<WHISPER::threadSafeQueue<WHISPER::Message>>();
outgoingParentMessages = std::make_shared<WHISPER::threadSafeQueue<WHISPER::Message>>(); outgoingParentMessages = std::make_shared<WHISPER::threadSafeQueue<WHISPER::Message>>();
incommingTrackMessages = std::make_shared<WHISPER::threadSafeQueue<SimCore::GroundTruthTrack>>(); incommingTrackMessages = std::make_shared<WHISPER::threadSafeQueue<std::shared_ptr<SimCore::GroundTruthTrack>>>();
GroundTruthUDPService_ = std::make_shared<WHISPER::InternalUDPService>(OwnID.getParentNumber(),OwnID.getNumber(),WHISPER::SENSOR,GroundTruthPort_,SimCore::UtilFunctions::implode(ip,'.'),ownIP); GroundTruthUDPService_ = std::make_shared<WHISPER::InternalUDPService>(OwnID.getParentNumber(),OwnID.getNumber(),WHISPER::SENSOR,GroundTruthPort_,SimCore::UtilFunctions::implode(ip,'.'),ownIP);
@@ -121,9 +122,8 @@ namespace SimCore {
WHISPER::Message msg; WHISPER::Message msg;
incommingGroundThruthMessages->get(msg); incommingGroundThruthMessages->get(msg);
if (msg.msgType_ == WHISPER::MsgType::GROUND_TRUTH_TRACK) { if (msg.msgType_ == WHISPER::MsgType::GROUND_TRUTH_TRACK) {
auto elem = GroundTruthTrack::unpack(msg); auto GTrack = std::make_shared<SimCore::GroundTruthTrack>(std::move(SimCore::GroundTruthTrack::unpack(msg)));
// auto Track = SimCore::Track(msg.serialize()); incommingTrackMessages->addElement(GTrack);
incommingTrackMessages->addElement(elem);
} }
} }
@@ -152,8 +152,10 @@ namespace SimCore {
incommingParentMessages->get(msg); incommingParentMessages->get(msg);
LOG_S(INFO)<< "Message received from Parent is" << msg.msgType_; LOG_S(INFO)<< "Message received from Parent is" << msg.msgType_;
std::uint32_t type = 0; std::uint32_t type = 0;
if (msg.msgType_ == WHISPER::MsgType::OWN_TRACK) { switch (msg.msgType_) {
case WHISPER::MsgType::OWN_TRACK :{
auto OwnTrack = SimCore::GroundTruthTrack::unpack(msg); auto OwnTrack = SimCore::GroundTruthTrack::unpack(msg);
// SimCore::Track OwnTrack(msg.serialize()); // SimCore::Track OwnTrack(msg.serialize());
auto tmpPos = OwnTrack.getPostion().getGeocentricPos(); auto tmpPos = OwnTrack.getPostion().getGeocentricPos();
@@ -169,8 +171,22 @@ namespace SimCore {
tmpPos[SimCore::GeocentricPosition::Y], tmpPos[SimCore::GeocentricPosition::Y],
tmpPos[SimCore::GeocentricPosition::Z]); tmpPos[SimCore::GeocentricPosition::Z]);
} }
break;
} }
case WHISPER::MsgType::COMMAND: {
break;
}
default: {
break;
}
}
} }