initial commit

This commit is contained in:
Henry Winkel
2023-02-16 17:50:38 +01:00
parent e9bfac3c10
commit 9d76994e31
425 changed files with 102538 additions and 0 deletions

116
include/Entities/Entity.hpp Normal file
View File

@@ -0,0 +1,116 @@
#pragma once
#include "SimCore/Messages/GroundThruthTrack.hpp"
#include "SimCore/Messages/Track.hpp"
#include "SimCore/SafeMap.hpp"
#include "SimCore/SimCore.hpp"
#include <WHISPER/InternalUDPService.hpp>
#include <WHISPER/InternalUDPSender.hpp>
#include <WHISPER/InternalUDPListener.hpp>
#include <WHISPER/Messages/Message.hpp>
#include <WHISPER/threadSafeQueue.hpp>
#include <SimCore/Identifier.hpp>
#include <SimCore/Position.hpp>
#include <atomic>
#include <chrono>
#include <memory>
#include <string>
#include <thread>
#include <utility>
namespace SimCore {
struct SensorData
{
std::string SensorName;
bool isActive;
SimCore::Identifier SensorID;
std::shared_ptr<WHISPER::InternalUDPSender> SensorSender;
};
struct EffectorData
{
std::string EffectorName;
bool isActive;
SimCore::Identifier EffectorID;
std::shared_ptr<WHISPER::InternalUDPSender> EffectorSender;
};
class Entity {
public:
Entity(const SimCore::Identifier OwnID,
std::string EnttityName,
WHISPER::SourceType OwnType,
SimCore::Identifier ParentID,
SimCore::EntityKind EntityKind,
std::uint32_t GroundTruthPort,
std::uint32_t CommandPort,
std::string CommandIPAddress);
// ~Entity();
void start();
void stop();
protected:
std::shared_ptr<WHISPER::threadSafeQueue<WHISPER::Message>> incommingCommandMessages = nullptr;
std::shared_ptr<WHISPER::threadSafeQueue<WHISPER::Message>> outgoingCommandMessages = nullptr;
virtual void specificPhysicsCalculations(std::chrono::milliseconds::rep duration) = 0;
virtual void specificReloadCharacteristicts() = 0;
std::shared_ptr<Position> ownShipPosition_ = nullptr;
private:
std::string EntityName_;
SimCore::GroundTruthTrack ownTrack_;
SimCore::Identifier ParentID_;
SimCore::EntityKind EntityKind_;
std::uint32_t GroundTruthPort_;
std::uint32_t CommandPort_;
std::string CommandIPAddress_;
std::vector<std::thread> threads;
std::atomic<bool> stopCommandWorker = false;
std::atomic<bool> stopSensorWorker = false;
std::atomic<bool> stopTrackWorker = false;
std::atomic<bool> stopPhysicsWorker = false;
std::atomic<bool> physicsIsRunning = false;
void CommandWorker();
void SensorWorker();
void TrackWorker();
void physicsWorker();
void startSensor();
std::shared_ptr<WHISPER::InternalUDPSender> GroundTruthUDPSender_ = nullptr;
std::shared_ptr<std::list<SimCore::SensorData>> SensorStore_;
std::shared_ptr<SimCore::SafeMap<SimCore::Identifier, std::shared_ptr<SimCore::Track>>> Trackstore_;
};
}

View File

@@ -0,0 +1,78 @@
#pragma once
#include "SimCore/Messages/GroundThruthTrack.hpp"
#include "SimCore/Messages/Track.hpp"
#include <WHISPER/InternalUDPService.hpp>
#include <SimCore/Identifier.hpp>
#include <WHISPER/threadSafeQueue.hpp>
#include <WHISPER/Messages/Message.hpp>
#include <SimCore/SimCore.hpp>
#include <SimCore/Identifier.hpp>
#include <SimCore/Position.hpp>
#include <memory>
#include <thread>
namespace SimCore {
class Sensor {
public:
Sensor(SimCore::Identifier OwnID, SimCore::Identifier ParentID, SimCore::SensorKinds SensorKind,std::uint32_t GroundTruthPort, std::uint32_t ParentPort,std::string ParentIPAddress);
~Sensor();
void start();
void stop();
protected:
std::shared_ptr<WHISPER::threadSafeQueue<SimCore::GroundTruthTrack>> incommingTrackMessages = nullptr;
std::shared_ptr<WHISPER::threadSafeQueue<WHISPER::Message>> incommingGroundThruthMessages = nullptr;
std::shared_ptr<WHISPER::threadSafeQueue<WHISPER::Message>> outgoingGroundThruthMessages = nullptr;
std::shared_ptr<WHISPER::threadSafeQueue<WHISPER::Message>> incommingParentMessages = nullptr;
std::shared_ptr<WHISPER::threadSafeQueue<WHISPER::Message>> outgoingParentMessages = nullptr;
virtual void specificSensorCalculations() = 0;
virtual void specificReloadCharacteristicts() = 0;
std::shared_ptr<Position> ownShipPosition_ = nullptr;
private:
SimCore::Identifier OwnID_;
SimCore::Identifier ParentID_;
SimCore::SensorKinds SensorKind_;
std::uint32_t GroundTruthPort_;
std::uint32_t ParentPort_;
std::string ParentIPAddress_;
std::shared_ptr<WHISPER::InternalUDPService> GroundTruthUDPService_ = nullptr;
std::shared_ptr<WHISPER::InternalUDPService> ParentUDPService_ = nullptr;
void groundThruthData();
void parentData();
void SensorCalculations();
void ReloadCharacteristicts();
std::atomic<bool> stopReceivingGroundThruth = false;
std::atomic<bool> ReceivingGroundThruthIsRunnung = false;
std::atomic<bool> stopsendCalculatedData = false;
std::atomic<bool> sendCalculatedDataIsRunnung = false;
std::atomic<bool> stopCalculationData = false;
std::atomic<bool> CalculationIsRunnung = false;
std::thread receiveGroundTruthThread;
std::thread sendCalculatedDataThread;
std::thread sensorCalculationThread;
};
}