ADD: added comments to entity library and changed drone.yml and removed some specific ide files
This commit is contained in:
@@ -13,9 +13,9 @@ steps:
|
|||||||
- name: build
|
- name: build
|
||||||
image: kmaster.ti.unibw-hamburg.de:30808/debianbullseye
|
image: kmaster.ti.unibw-hamburg.de:30808/debianbullseye
|
||||||
commands:
|
commands:
|
||||||
# - sed -i 's/ssh\\:..git@/https\\:\\/\\//' .gitmodules
|
- sed -i 's/ssh\\:..git@/https\\:\\/\\//' .gitmodules
|
||||||
# - sed -i 's/\:12000//' .gitmodules
|
- sed -i 's/\:12000//' .gitmodules
|
||||||
# - git submodule update --init --recursive --jobs=4
|
- git submodule update --init --recursive --jobs=4
|
||||||
- mkdir -p build && cd build
|
- mkdir -p build && cd build
|
||||||
- CC=clang-11 CXX=clang++-11 cmake -DCMAKE_BUILD_TYPE=DEBUG ..
|
- CC=clang-11 CXX=clang++-11 cmake -DCMAKE_BUILD_TYPE=DEBUG ..
|
||||||
- make -j
|
- make -j
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
build/
|
build/
|
||||||
.cache
|
.cache
|
||||||
|
.vscode
|
||||||
16
.vscode/launch.json
vendored
16
.vscode/launch.json
vendored
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
// Use IntelliSense to learn about possible attributes.
|
|
||||||
// Hover to view descriptions of existing attributes.
|
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Debug-SensorManager",
|
|
||||||
"type": "gdb",
|
|
||||||
"request": "launch",
|
|
||||||
"target": "./test_SensorManager",
|
|
||||||
"cwd": "${workspaceRoot}/build",
|
|
||||||
"valuesFormatting": "parseText"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#define LOGURU_WITH_STREAMS 1
|
||||||
|
#include <loguru.hpp>
|
||||||
#include <Entities/Tracklist/Tracklist.hpp>
|
#include <Entities/Tracklist/Tracklist.hpp>
|
||||||
|
|
||||||
#include "DirectCommunicationServer.hpp"
|
#include "DirectCommunicationServer.hpp"
|
||||||
@@ -31,24 +33,6 @@
|
|||||||
|
|
||||||
namespace Entities {
|
namespace Entities {
|
||||||
|
|
||||||
// struct SensorClientData
|
|
||||||
// {
|
|
||||||
// std::string SensorName;
|
|
||||||
// bool isActive;
|
|
||||||
// SimCore::Identifier SensorID;
|
|
||||||
// // std::shared_ptr<WHISPER::InternalUDPSender> SensorSender;
|
|
||||||
// };
|
|
||||||
|
|
||||||
struct EffectorClientData
|
|
||||||
{
|
|
||||||
std::string EffectorName;
|
|
||||||
bool isActive;
|
|
||||||
SimCore::Identifier EffectorID;
|
|
||||||
std::shared_ptr<WHISPER::InternalUDPSender> EffectorSender;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Entity {
|
class Entity {
|
||||||
public:
|
public:
|
||||||
Entity(const SimCore::Identifier OwnID,
|
Entity(const SimCore::Identifier OwnID,
|
||||||
@@ -64,60 +48,95 @@ namespace Entities {
|
|||||||
bool online);
|
bool online);
|
||||||
~Entity();
|
~Entity();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief starts the Entity APP
|
||||||
|
*/
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief stops the Entity
|
||||||
|
*/
|
||||||
void stop();
|
void stop();
|
||||||
void setPosition(SimCore::Position);
|
|
||||||
|
/**
|
||||||
|
* @brief sets the current entity position
|
||||||
|
*/
|
||||||
|
void setPosition(SimCore::Position pos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief sets the speed of the Entity
|
||||||
|
* @param speed - double
|
||||||
|
*/
|
||||||
void setSpeed(double speed);
|
void setSpeed(double speed);
|
||||||
|
/**
|
||||||
|
* @brief set the course of the entity (heading, course over ground) in degree
|
||||||
|
* @param course - double
|
||||||
|
*/
|
||||||
void setCourse(double course);
|
void setCourse(double course);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief sets the pitch (climb angle) in degree
|
||||||
|
* @param pitch - double
|
||||||
|
*/
|
||||||
void setPitch( double pitch);
|
void setPitch( double pitch);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief is the child worker function which is called on every circle
|
||||||
|
*/
|
||||||
virtual void childWorker() = 0;
|
virtual void childWorker() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief is function whick is called to stop the specific child class
|
||||||
|
*/
|
||||||
virtual void stopChild() = 0;
|
virtual void stopChild() = 0;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
/// @brief shared_ptr of the own track
|
||||||
std::shared_ptr<SimCore::SimTrack> OwnShipTrack = nullptr;
|
std::shared_ptr<SimCore::SimTrack> OwnShipTrack = nullptr;
|
||||||
|
/// @brief name of the entity (marking)
|
||||||
std::unique_ptr<TrackList::TrackList> TrackList_ = nullptr;
|
|
||||||
|
|
||||||
|
|
||||||
std::string EntityName_;
|
std::string EntityName_;
|
||||||
|
/// @brief Entity Kind var (is enum)
|
||||||
SimCore::Kind::EntityKind EntityKind_;
|
SimCore::Kind::EntityKind EntityKind_;
|
||||||
|
/// @brief Entity Side (is enum)
|
||||||
SimCore::Side::EntitySide EntitySide_;
|
SimCore::Side::EntitySide EntitySide_;
|
||||||
|
/// @brief Radar cross section
|
||||||
double RCS_;
|
double RCS_;
|
||||||
|
/// @brief port of the movement worker
|
||||||
ushort MovemntWorkerPort_;
|
ushort MovemntWorkerPort_;
|
||||||
|
/// @brief port which the sensor are connecting to
|
||||||
ushort SensorPort_;
|
ushort SensorPort_;
|
||||||
|
/// @brief shared ptr of the Podcontroller
|
||||||
|
|
||||||
std::shared_ptr<kubecontrol::PodController> PodController_;
|
std::shared_ptr<kubecontrol::PodController> PodController_;
|
||||||
|
/// @brief unique ptr of the sensor manager
|
||||||
std::unique_ptr<SensorManager> SensorManager_;
|
std::unique_ptr<SensorManager> SensorManager_;
|
||||||
|
/// @brief broadcast server the own ship message is use to send
|
||||||
std::shared_ptr<WHISPER::InternalUDPSender> BroadcastServer_;
|
std::shared_ptr<WHISPER::InternalUDPSender> BroadcastServer_;
|
||||||
|
/// @brief address of the ground thruth (default = 239.0.0.1)
|
||||||
|
|
||||||
std::string GroundTruthAddr_;
|
std::string GroundTruthAddr_;
|
||||||
|
/// @brief port of the ground thruth
|
||||||
std::uint32_t GroundTruthPort_;
|
std::uint32_t GroundTruthPort_;
|
||||||
|
/// @brief port on which commands are received
|
||||||
ushort CommandPort_;
|
ushort CommandPort_;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/// @brief indicates if entity is startet in a kubernetes cluster
|
||||||
bool online_;
|
bool online_;
|
||||||
|
/// @brief vector of all startet threads
|
||||||
|
std::vector<std::thread> threads_;
|
||||||
std::vector<std::thread> threads;
|
///
|
||||||
|
std::atomic_bool stopMainLoop_ = false;
|
||||||
std::atomic<bool> stopMainLoop = false;
|
|
||||||
void MainLoop();
|
void MainLoop();
|
||||||
|
|
||||||
|
|
||||||
void startMovementWorker();
|
void startMovementWorker();
|
||||||
std::atomic<bool> MovementWorkerStarted = false;
|
std::atomic_bool MovementWorkerStarted_ = false;
|
||||||
std::shared_ptr<DirectCommunication::DirectCommunicationServer> MovemtServer_ = nullptr;
|
std::shared_ptr<DirectCommunication::DirectCommunicationServer> MovemtServer_ = nullptr;
|
||||||
void handleMovement();
|
void handleMovement();
|
||||||
std::string MovementPodUUID_;
|
std::string MovementPodUUID_;
|
||||||
@@ -125,7 +144,7 @@ namespace Entities {
|
|||||||
|
|
||||||
std::shared_ptr<DirectCommunication::DirectCommunicationServer> CommandCommsServer_ = nullptr;
|
std::shared_ptr<DirectCommunication::DirectCommunicationServer> CommandCommsServer_ = nullptr;
|
||||||
|
|
||||||
void handleExternalComms(std::string msg);
|
void handleExternalComms(const std::string &msg);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "DirectCommunicationServer.hpp"
|
#include <DirectCommunicationServer.hpp>
|
||||||
#include "Entities/Movement.hpp"
|
#include "Entities/Movement.hpp"
|
||||||
#include "Entities/SensorManager.hpp"
|
#include "Entities/SensorManager.hpp"
|
||||||
#include "Orders/MoveOrder.hpp"
|
#include "Orders/MoveOrder.hpp"
|
||||||
@@ -80,7 +80,6 @@ namespace Entities
|
|||||||
|
|
||||||
// BroadcastServer_ = std::make_shared<WHISPER::InternalUDPSender>("239.0.0.1", 10000);
|
// BroadcastServer_ = std::make_shared<WHISPER::InternalUDPSender>("239.0.0.1", 10000);
|
||||||
|
|
||||||
// TrackList_ = std::make_unique<TrackList::TrackList>();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +98,7 @@ namespace Entities
|
|||||||
|
|
||||||
Orders::MoveOrder moveorder(OwnShipTrack->getIdentifier());
|
Orders::MoveOrder moveorder(OwnShipTrack->getIdentifier());
|
||||||
moveorder.setPosition(pos);
|
moveorder.setPosition(pos);
|
||||||
if(MovementWorkerStarted == true)
|
if(MovementWorkerStarted_ == true)
|
||||||
{
|
{
|
||||||
MovemtServer_->sendMessage(moveorder.buildMessage());
|
MovemtServer_->sendMessage(moveorder.buildMessage());
|
||||||
LOG_S(INFO)<<"Move Order send";
|
LOG_S(INFO)<<"Move Order send";
|
||||||
@@ -110,7 +109,7 @@ namespace Entities
|
|||||||
OwnShipTrack->Speed.setValue(val);
|
OwnShipTrack->Speed.setValue(val);
|
||||||
Orders::MoveOrder moveorder(OwnShipTrack->getIdentifier());
|
Orders::MoveOrder moveorder(OwnShipTrack->getIdentifier());
|
||||||
moveorder.Speed.setValue(val);
|
moveorder.Speed.setValue(val);
|
||||||
if(MovementWorkerStarted == true)
|
if(MovementWorkerStarted_ == true)
|
||||||
{
|
{
|
||||||
MovemtServer_->sendMessage(moveorder.buildMessage());
|
MovemtServer_->sendMessage(moveorder.buildMessage());
|
||||||
LOG_S(INFO)<<"Move Order send with Speed";
|
LOG_S(INFO)<<"Move Order send with Speed";
|
||||||
@@ -121,7 +120,7 @@ namespace Entities
|
|||||||
OwnShipTrack->Course.setValue(val);
|
OwnShipTrack->Course.setValue(val);
|
||||||
Orders::MoveOrder moveorder(OwnShipTrack->getIdentifier());
|
Orders::MoveOrder moveorder(OwnShipTrack->getIdentifier());
|
||||||
moveorder.Course.setValue(val);
|
moveorder.Course.setValue(val);
|
||||||
if(MovementWorkerStarted == true)
|
if(MovementWorkerStarted_ == true)
|
||||||
{
|
{
|
||||||
MovemtServer_->sendMessage(moveorder.buildMessage());
|
MovemtServer_->sendMessage(moveorder.buildMessage());
|
||||||
LOG_S(INFO)<<"Move Order send with Course";
|
LOG_S(INFO)<<"Move Order send with Course";
|
||||||
@@ -136,13 +135,9 @@ namespace Entities
|
|||||||
|
|
||||||
void Entity::start()
|
void Entity::start()
|
||||||
{
|
{
|
||||||
|
stopMainLoop_ = false;
|
||||||
stopMainLoop = false;
|
|
||||||
|
|
||||||
|
threads_.emplace_back(std::thread(&Entity::MainLoop,this));
|
||||||
threads.emplace_back(std::thread(&Entity::MainLoop,this));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,18 +156,18 @@ namespace Entities
|
|||||||
SensorManager_->stop();
|
SensorManager_->stop();
|
||||||
|
|
||||||
|
|
||||||
for (std::vector<std::thread>::iterator it = threads.begin(); it != threads.end();)
|
for (std::vector<std::thread>::iterator it = threads_.begin(); it != threads_.end();)
|
||||||
{
|
{
|
||||||
if (it->joinable())
|
if (it->joinable())
|
||||||
{
|
{
|
||||||
|
|
||||||
it->join();
|
it->join();
|
||||||
it = threads.erase(it);
|
it = threads_.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_S(ERROR)<< "Remaining Threads: " << threads.size();
|
LOG_S(ERROR)<< "Remaining Threads: " << threads_.size();
|
||||||
// std::this_thread::sleep_for(std::chrono::milliseconds(30000));
|
// std::this_thread::sleep_for(std::chrono::milliseconds(30000));
|
||||||
|
|
||||||
// exit(0);
|
// exit(0);
|
||||||
@@ -208,7 +203,7 @@ namespace Entities
|
|||||||
{
|
{
|
||||||
LOG_S(INFO)<< "POS: LAT: "<< OwnShipTrack->getPosition().getGeodesicPos()(SimCore::LATITUDE) << " LON: " << OwnShipTrack->getPosition().getGeodesicPos()(SimCore::LONGITUDE);
|
LOG_S(INFO)<< "POS: LAT: "<< OwnShipTrack->getPosition().getGeodesicPos()(SimCore::LATITUDE) << " LON: " << OwnShipTrack->getPosition().getGeodesicPos()(SimCore::LONGITUDE);
|
||||||
|
|
||||||
MovementWorkerStarted = true;
|
MovementWorkerStarted_ = true;
|
||||||
MovemtServer_->sendMessage(OwnShipTrack->buildMessage());
|
MovemtServer_->sendMessage(OwnShipTrack->buildMessage());
|
||||||
LOG_S(INFO)<< "Initial Message send to MovementWorker";
|
LOG_S(INFO)<< "Initial Message send to MovementWorker";
|
||||||
}
|
}
|
||||||
@@ -218,7 +213,7 @@ namespace Entities
|
|||||||
|
|
||||||
void Entity::handleMovement()
|
void Entity::handleMovement()
|
||||||
{
|
{
|
||||||
if (!MovementWorkerStarted)
|
if (!MovementWorkerStarted_)
|
||||||
{
|
{
|
||||||
startMovementWorker();
|
startMovementWorker();
|
||||||
}else
|
}else
|
||||||
@@ -233,14 +228,14 @@ namespace Entities
|
|||||||
|
|
||||||
if (MovemtServer_->countClients() == 0)
|
if (MovemtServer_->countClients() == 0)
|
||||||
{
|
{
|
||||||
MovementWorkerStarted = false;
|
MovementWorkerStarted_ = false;
|
||||||
LOG_S(WARNING)<<"Movementclient lost";
|
LOG_S(WARNING)<<"Movementclient lost";
|
||||||
}
|
}
|
||||||
// std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
// std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::handleExternalComms(std::string msg)
|
void Entity::handleExternalComms(const std::string &msg)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@@ -384,7 +379,7 @@ namespace Entities
|
|||||||
void Entity::MainLoop()
|
void Entity::MainLoop()
|
||||||
{
|
{
|
||||||
LOG_S(INFO)<< "main loop started";
|
LOG_S(INFO)<< "main loop started";
|
||||||
while (!stopMainLoop)
|
while (!stopMainLoop_)
|
||||||
{
|
{
|
||||||
handleMovement();
|
handleMovement();
|
||||||
childWorker();
|
childWorker();
|
||||||
|
|||||||
Reference in New Issue
Block a user