Merge branch 'main' of ssh://dev-gitea.ftewa.ti.unibw-hamburg.de:12000/hwinkel/SimControl
This commit is contained in:
@@ -28,6 +28,7 @@ IF(NOT TARGET SimCore)
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(NOT TARGET KubeControl)
|
IF(NOT TARGET KubeControl)
|
||||||
|
set(TEST_KUBECONTROL_LIBRARY OFF CACHE BOOL "disable testing")
|
||||||
add_subdirectory(libs/KubeControl EXCLUDE_FROM_ALL)
|
add_subdirectory(libs/KubeControl EXCLUDE_FROM_ALL)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ RUN apt-get -y install tcpdump nano netcat-openbsd
|
|||||||
|
|
||||||
|
|
||||||
# install all used libs
|
# install all used libs
|
||||||
RUN apt-get -y install libsodium23 libuuid1 libstdc++5 libcurl4
|
RUN apt-get -y install libsodium23 libuuid1 libstdc++5 libcurl4 libcurl4-gnutls-dev
|
||||||
|
|
||||||
# copy all custom buld libs
|
# copy all custom buld libs
|
||||||
COPY build/libs/SimCore/libs/whisper-com/libs/libzmq/lib/libzmq.so.5 /usr/lib/
|
COPY build/libs/SimCore/libs/whisper-com/libs/libzmq/lib/libzmq.so.5 /usr/lib/
|
||||||
|
|||||||
Submodule build/libs/SimCore/libs/whisper-comm deleted from f17566cba0
6
buildDocker.sh
Executable file
6
buildDocker.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
cd build/
|
||||||
|
make -j8
|
||||||
|
cd ..
|
||||||
|
TAG="kmaster.ti.unibw-hamburg.de:30808/simcontrol:latest"
|
||||||
|
docker build --pull --rm -f "Dockerfile" -t ${TAG} "."
|
||||||
|
docker image push ${TAG}
|
||||||
@@ -55,8 +55,15 @@ class SimControl{
|
|||||||
|
|
||||||
|
|
||||||
void startShip(std::string name);
|
void startShip(std::string name);
|
||||||
|
void updateShip(nlohmann::json request);
|
||||||
|
void deleteShip(nlohmann::json request);
|
||||||
|
|
||||||
void startWebApp();
|
void startWebApp();
|
||||||
|
|
||||||
|
void startWebsocketServer();
|
||||||
|
void HandleWebsocketMessages(std::shared_ptr<ix::ConnectionState> connectionState, ix::WebSocket &websocket, const ix::WebSocketMessagePtr &msg);
|
||||||
|
void HandleBroadcastMessage(std::string msg);
|
||||||
|
|
||||||
std::unique_ptr<kubecontrol::PodController> PodController_;
|
std::unique_ptr<kubecontrol::PodController> PodController_;
|
||||||
std::unique_ptr<TrackList> Tracklist_;
|
std::unique_ptr<TrackList> Tracklist_;
|
||||||
|
|
||||||
@@ -73,11 +80,8 @@ class SimControl{
|
|||||||
int port = 9999;
|
int port = 9999;
|
||||||
std::string host = "0.0.0.0";
|
std::string host = "0.0.0.0";
|
||||||
std::shared_ptr<ix::WebSocketServer> WebsocketServer_ = nullptr;
|
std::shared_ptr<ix::WebSocketServer> WebsocketServer_ = nullptr;
|
||||||
void startWebsocketServer();
|
|
||||||
void HandleWebsocketMessages(std::shared_ptr<ix::ConnectionState> connectionState, ix::WebSocket &websocket, const ix::WebSocketMessagePtr &msg);
|
|
||||||
|
|
||||||
std::shared_ptr<WHISPER::InternalUDPListener> BroadcastListener_;
|
std::shared_ptr<WHISPER::InternalUDPListener> BroadcastListener_;
|
||||||
void HandleBroadcastMessage(std::string msg);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ namespace SimControl
|
|||||||
void addTrack(std::shared_ptr<SimCore::SimTrack> Track);
|
void addTrack(std::shared_ptr<SimCore::SimTrack> Track);
|
||||||
std::shared_ptr<SimCore::SimTrack> getTrack(SimCore::Identifier);
|
std::shared_ptr<SimCore::SimTrack> getTrack(SimCore::Identifier);
|
||||||
|
|
||||||
|
|
||||||
|
std::shared_ptr<SimCore::SimTrack> getTrackBySringID(std::string ID);
|
||||||
|
|
||||||
|
|
||||||
void getJsonTRackList(nlohmann::json &message);
|
void getJsonTRackList(nlohmann::json &message);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Submodule libs/KubeControl updated: 49b36053d7...d40cc7a8c0
Submodule libs/SimCore updated: d060f9f2d4...edbea7e374
@@ -137,7 +137,7 @@ namespace SimControl {
|
|||||||
auto track = SimCore::SimTrack::unpack(msg);
|
auto track = SimCore::SimTrack::unpack(msg);
|
||||||
if (track != nullptr)
|
if (track != nullptr)
|
||||||
{
|
{
|
||||||
LOG_S(INFO)<<"Track received";
|
// LOG_S(INFO)<<"Track received";
|
||||||
Tracklist_->addTrack(std::move(track));
|
Tracklist_->addTrack(std::move(track));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ namespace SimControl {
|
|||||||
}
|
}
|
||||||
void SimControl::HandleWebsocketMessages(std::shared_ptr<ix::ConnectionState> connectionState, ix::WebSocket &websocket, const ix::WebSocketMessagePtr &msg)
|
void SimControl::HandleWebsocketMessages(std::shared_ptr<ix::ConnectionState> connectionState, ix::WebSocket &websocket, const ix::WebSocketMessagePtr &msg)
|
||||||
{
|
{
|
||||||
LOG_S(INFO) << "Remote ip: " << connectionState->getRemoteIp();
|
// LOG_S(INFO) << "Remote ip: " << connectionState->getRemoteIp();
|
||||||
|
|
||||||
if (msg->type == ix::WebSocketMessageType::Open)
|
if (msg->type == ix::WebSocketMessageType::Open)
|
||||||
{
|
{
|
||||||
@@ -195,7 +195,7 @@ namespace SimControl {
|
|||||||
// LOG_S(INFO)<< "Received: " << msg->str << std::endl;
|
// LOG_S(INFO)<< "Received: " << msg->str << std::endl;
|
||||||
try {
|
try {
|
||||||
nlohmann::json j = nlohmann::json::parse(msg->str);
|
nlohmann::json j = nlohmann::json::parse(msg->str);
|
||||||
LOG_S(INFO)<< "Received: " << j["Data"].get<std::string>() << std::endl;
|
// LOG_S(INFO)<< "Received: " << j["Data"].get<std::string>() << std::endl;
|
||||||
|
|
||||||
if (j["Data"] == "COP")
|
if (j["Data"] == "COP")
|
||||||
{
|
{
|
||||||
@@ -204,12 +204,17 @@ namespace SimControl {
|
|||||||
response["Data"] = "COP";
|
response["Data"] = "COP";
|
||||||
Tracklist_->getJsonTRackList(response);
|
Tracklist_->getJsonTRackList(response);
|
||||||
// response.merge_patch(Tracklist_->getJsonTRackList());
|
// response.merge_patch(Tracklist_->getJsonTRackList());
|
||||||
LOG_S(INFO)<<response;
|
// LOG_S(INFO)<<response;
|
||||||
websocket.send(response.dump());
|
websocket.send(response.dump());
|
||||||
}
|
}
|
||||||
}else if (true)
|
}else if (j["Data"] == "Entity")
|
||||||
{
|
{
|
||||||
|
|
||||||
|
updateShip(j);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -227,6 +232,10 @@ namespace SimControl {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SimControl::startShip(std::string name)
|
void SimControl::startShip(std::string name)
|
||||||
{
|
{
|
||||||
std::string uuid = name;
|
std::string uuid = name;
|
||||||
@@ -244,6 +253,52 @@ namespace SimControl {
|
|||||||
PodController_->startPod(ShipPod1);
|
PodController_->startPod(ShipPod1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimControl::updateShip(nlohmann::json request)
|
||||||
|
{
|
||||||
|
// if (j["Type"] == ) {
|
||||||
|
// statements
|
||||||
|
// }
|
||||||
|
LOG_S(INFO)<< "Entity values:" << request;
|
||||||
|
auto track = Tracklist_->getTrackBySringID(request["ID"].get<std::string>());
|
||||||
|
Orders::MoveOrder moveOrder(track->getIdentifier());
|
||||||
|
if(track != nullptr)
|
||||||
|
{
|
||||||
|
LOG_S(INFO)<<request["Speed"].get<std::string>();
|
||||||
|
LOG_S(INFO)<<request["Course"].get<std::string>();
|
||||||
|
|
||||||
|
moveOrder.Speed.setValue(std::stod(request["Speed"].get<std::string>()));
|
||||||
|
moveOrder.Course.setValue(std::stod(request["Course"].get<std::string>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(request["SetPosition"].get<bool>() == true)
|
||||||
|
{
|
||||||
|
LOG_S(INFO)<<"setting new position";
|
||||||
|
SimCore::Position pos;
|
||||||
|
LOG_S(INFO)<<"LAT: "<<request["Position"][0].get<double>();
|
||||||
|
LOG_S(INFO)<<"LON: "<<request["Position"][1].get<double>();
|
||||||
|
|
||||||
|
pos.setGeodesicPos(request["Position"][0].get<double>(),request["Position"][1].get<double>(), request["Height"].get<double>());
|
||||||
|
moveOrder.setPosition(pos);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
auto info = PodController_->getPodsInfo(request["ID"].get<std::string>());
|
||||||
|
if(info != nullptr)
|
||||||
|
{
|
||||||
|
LOG_S(INFO)<<"PODS Info: " <<info->ToJson();
|
||||||
|
DirectCommunication::DirectCommunicationClient client(std::stoi(CommandPort_),info->Ip);
|
||||||
|
client.sendMessage(moveOrder.buildMessage().serialize());
|
||||||
|
// client.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimControl::deleteShip(nlohmann::json request)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void SimControl::startWebApp()
|
void SimControl::startWebApp()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,15 @@ namespace SimControl
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<SimCore::SimTrack> TrackList::getTrackBySringID(std::string ID)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
|
|
||||||
|
auto it = TrackStore_.find(ID);
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TrackList::getJsonTRackList(nlohmann::json &message)
|
void TrackList::getJsonTRackList(nlohmann::json &message)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mx_);
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
@@ -42,7 +51,9 @@ namespace SimControl
|
|||||||
j["Name"] = it->second->Name.getValue();
|
j["Name"] = it->second->Name.getValue();
|
||||||
j["Course"] = it->second->Course.getValue();
|
j["Course"] = it->second->Course.getValue();
|
||||||
j["Speed"] = it->second->Speed.getValue();
|
j["Speed"] = it->second->Speed.getValue();
|
||||||
|
j["External"] = false;
|
||||||
j["Position"] = {it->second->getPosition().getGeodesicPos()[SimCore::LATITUDE], it->second->getPosition().getGeodesicPos()[SimCore::LONGITUDE]};
|
j["Position"] = {it->second->getPosition().getGeodesicPos()[SimCore::LATITUDE], it->second->getPosition().getGeodesicPos()[SimCore::LONGITUDE]};
|
||||||
|
j["Height"] = it->second->getPosition().getGeodesicPos()[SimCore::HEIGHT];
|
||||||
j["Type"] = SimCore::Kind::EntityKindMap[it->second->EntityKind.getValue()];
|
j["Type"] = SimCore::Kind::EntityKindMap[it->second->EntityKind.getValue()];
|
||||||
j["Side"] = SimCore::Side::EntitySideMap[it->second->EntitySide.getValue()];
|
j["Side"] = SimCore::Side::EntitySideMap[it->second->EntitySide.getValue()];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user