8#include "Containers/StringConv.h"
9#include "Engine/World.h"
26 UE_LOG(LogTemp, Error, TEXT(
"ROSHandler.cpp: ROS is already active."));
32 FString command =
"gnome-terminal -- bash -c \"roslaunch rosbridge_server rosbridge_tcp.launch bson_only_mode:=True""\"";
35 UE_LOG(LogTemp, Warning, TEXT(
"ROSHandler.cpp: Attempting to launch ROS with command: %s"), *command);
38 system(TCHAR_TO_ANSI(*command));
45 FString Application =
"wsl";
46 FString CommandParams =
"-e bash -lic \"roslaunch rosbridge_server rosbridge_tcp.launch bson_only_mode:=True""\"";
49 FString BridgeCommands =
"-e bash -lic \"ROS2 && ros2 run ros1_bridge dynamic_bridge --bridge-all-topics""\"";
51 ROSProcessHandle = FPlatformProcess::CreateProc(*Application, *CommandParams,
true,
false,
false,
nullptr, 0,
nullptr,
nullptr);
52 ROSBridgeHandle = FPlatformProcess::CreateProc(*Application, *BridgeCommands,
true,
false,
false,
nullptr, 0,
nullptr,
nullptr);
57 UE_LOG(LogTemp, Error, TEXT(
"ROSHandler.cpp: Failed to create wsl process"));
62 UE_LOG(LogTemp, Error, TEXT(
"ROSHandler.cpp: Bridge not installed"));
76 FString StopCommand =
"killall -9 rosmaster";
80 system(TCHAR_TO_ANSI(*StopCommand));
103 FString Application =
"wsl";
104 FProcHandle Handle = FPlatformProcess::CreateProc(*Application, *StopCommand,
true,
false,
false,
nullptr, 0,
nullptr,
nullptr);
123 UE_LOG(LogTemp, Warning, TEXT(
"ROSHandler.cpp: ROS bridge state changed. ROS is connected: %s"), (
ROSConnected ? TEXT(
"true") : TEXT(
"false")));
void Setup(bool RosIsConnected)
FProcHandle ROSProcessHandle
FROSDelegate_ROState OnROSStateChanged
void OnROSBridgeChanged(EROSState newRosState)
FProcHandle ROSBridgeHandle