From 196c04c4b7485bacfb1ee86c05d36db28d0c5604 Mon Sep 17 00:00:00 2001 From: claus Date: Mon, 16 Oct 2023 19:32:43 -0300 Subject: [PATCH 1/9] Update to track tf2_geometry_msgs under humble --- ksp_bridge/CMakeLists.txt | 1 + ksp_bridge/src/utils.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ksp_bridge/CMakeLists.txt b/ksp_bridge/CMakeLists.txt index d8120f1..dc8abd8 100644 --- a/ksp_bridge/CMakeLists.txt +++ b/ksp_bridge/CMakeLists.txt @@ -43,6 +43,7 @@ ament_target_dependencies(${PROJECT_NAME} ksp_bridge_interfaces tf2 tf2_ros + tf2_geometry_msgs ) target_link_libraries(${PROJECT_NAME} diff --git a/ksp_bridge/src/utils.cpp b/ksp_bridge/src/utils.cpp index be85ba8..95e2d98 100644 --- a/ksp_bridge/src/utils.cpp +++ b/ksp_bridge/src/utils.cpp @@ -1,7 +1,10 @@ #include #include #include -#include + +#include +#include + const char* base_name(const char* file) { From b013299bc0e46f0b37e4c5ecca1a1beb083be9f0 Mon Sep 17 00:00:00 2001 From: claus Date: Mon, 16 Oct 2023 19:36:39 -0300 Subject: [PATCH 2/9] Add Dockerfile for isolated dev workflow --- Dockerfile | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9db1d06 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM ros:humble + +# Install dependencies +RUN apt update && apt install -y libprotobuf-dev libprotoc-dev protobuf-compiler wget unzip sudo libasio-dev + + +# Install kRPC +RUN mkdir krpc && \ + cd krpc && \ + wget https://github.com/krpc/krpc/releases/download/v0.5.2/krpc-cpp-0.5.2.zip && \ + unzip krpc-cpp-0.5.2.zip && \ + cd krpc-cpp-0.5.2 && \ + mkdir build && \ + cd build && \ + cmake .. && \ + make && \ + make install + +### Bridge into it +## Build ksp_bridge +# RUN mkdir -p /ros2_ws/src +# WORKDIR /ros2_ws/src +# RUN git clone https://github.com/clausqr/ksp_bridge.git +# WORKDIR /ros2_ws +# RUN . /opt/ros/humble/setup.sh && \ +# colcon build --symlink-install \ No newline at end of file From be49e52de3c172644a53b1bca5fcd9f1ce69e0e2 Mon Sep 17 00:00:00 2001 From: claus Date: Mon, 16 Oct 2023 20:50:01 -0300 Subject: [PATCH 3/9] Add ignore build artifacts --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 687f872..467d089 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .vscode/ - +log +build From d89c434b9fde854fa8c2eed6f4c69e51349a3ab4 Mon Sep 17 00:00:00 2001 From: claus Date: Mon, 16 Oct 2023 20:50:57 -0300 Subject: [PATCH 4/9] Debug rclcpp::exceptions::Uninitialized... error --- ksp_bridge/src/ksp_bridge.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ksp_bridge/src/ksp_bridge.cpp b/ksp_bridge/src/ksp_bridge.cpp index e4d868f..bd4e5a7 100644 --- a/ksp_bridge/src/ksp_bridge.cpp +++ b/ksp_bridge/src/ksp_bridge.cpp @@ -6,7 +6,9 @@ KSPBridge::KSPBridge() : rclcpp::Node("ksp_bridge") { declare_parameter("update_interval", 10); - declare_parameter>("celestial_bodies", {}); + printf("Declaring parameter: %s\n", "celestial_bodies" ); + declare_parameter>("celestial_bodies", {"kerbin"}); + printf("Declared parameter: %s\n", "celestial_bodies" ); int64_t update_interval = get_parameter("update_interval").as_int(); m_param_celestial_bodies = get_parameter("celestial_bodies").as_string_array(); From 573f994b072acf58d037a1ddafa27b4f2fbeaa82 Mon Sep 17 00:00:00 2001 From: claus Date: Mon, 16 Oct 2023 20:51:23 -0300 Subject: [PATCH 5/9] Update dockerfile --- Dockerfile | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9db1d06..9399439 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ros:humble +FROM osrf/ros:humble-desktop # Install dependencies RUN apt update && apt install -y libprotobuf-dev libprotoc-dev protobuf-compiler wget unzip sudo libasio-dev @@ -16,11 +16,20 @@ RUN mkdir krpc && \ make && \ make install +RUN ldconfig + ### Bridge into it ## Build ksp_bridge -# RUN mkdir -p /ros2_ws/src -# WORKDIR /ros2_ws/src -# RUN git clone https://github.com/clausqr/ksp_bridge.git -# WORKDIR /ros2_ws -# RUN . /opt/ros/humble/setup.sh && \ -# colcon build --symlink-install \ No newline at end of file +RUN mkdir -p /ros2_ws +WORKDIR /ros2_ws +RUN git clone https://github.com/clausqr/ksp_bridge.git src + +RUN . /opt/ros/humble/setup.sh && \ + colcon build + +RUN echo "source /ros2_ws/install/local_setup.bash" >> /root/.bashrc + +## Build ksp_bridge +# $ docker build -t ksp_bridge . +## Running this container +# $ docker run -it -v $(pwd):/ros_ws/src --net=host ksp_bridge \ No newline at end of file From a28d0842a3d27b183b4578f0b5d7f31112b8f263 Mon Sep 17 00:00:00 2001 From: claus Date: Mon, 16 Oct 2023 20:54:39 -0300 Subject: [PATCH 6/9] Add install to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 467d089..81c8421 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .vscode/ log build +install \ No newline at end of file From 2bf4cb6e2fa41e164ac25d784f334be293aea020 Mon Sep 17 00:00:00 2001 From: claus Date: Mon, 16 Oct 2023 21:26:13 -0300 Subject: [PATCH 7/9] Update documentation. --- Dockerfile | 8 ++--- README.md | 93 ++++++++++++++++++++++++++---------------------------- 2 files changed, 49 insertions(+), 52 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9399439..774bf48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,13 +23,13 @@ RUN ldconfig RUN mkdir -p /ros2_ws WORKDIR /ros2_ws RUN git clone https://github.com/clausqr/ksp_bridge.git src - RUN . /opt/ros/humble/setup.sh && \ colcon build - RUN echo "source /ros2_ws/install/local_setup.bash" >> /root/.bashrc ## Build ksp_bridge -# $ docker build -t ksp_bridge . +# $ docker build -t clausqr:ksp_bridge . ## Running this container -# $ docker run -it -v $(pwd):/ros_ws/src --net=host ksp_bridge \ No newline at end of file +# $ docker run -it -v $(pwd):/ros_ws/src --net=host clausqr:ksp_bridge +## Inside: +# $ ros2 launch ksp_bridge_examples resource_monitor.launch.py diff --git a/README.md b/README.md index a782bf3..f7f7290 100644 --- a/README.md +++ b/README.md @@ -4,80 +4,77 @@ ROS2 package for Kerbal Space Program based on the kRPC mod. Works with: -+ KSP 1.12.3 ++ KSP 1.12.5 -+ kRPC 0.4.9 ++ kRPC 0.5.2 -+ ROS2 Foxy ++ ROS2 Humble -+ Ubuntu 20.04 ++ Ubuntu 22.04 ## Installation -The installation of the [kRPC mod](https://github.com/nullprofile/krpc) and it's dependencies. +### Install kRPC mod -### Libraries +Install the [kRPC mod](https://github.com/nullprofile/krpc) and it's dependencies. -Installation of the protobuf library: +### Clone repository and build the docker container -```bash -sudo apt update -sudo apt install -y libprotobuf-dev +``` bash +git clone https://github.com/clausqr/ksp_bridge +cd ksp_bridge +docker build -t ksp_bridge:humble . ``` -Installation of the ASIO standalone library: +## Usage + +### 1. Server settings inside KSP + +![up_and_down_assembly](doc/img/server_settings.jpg) + +**Note**: *Max. time per update* is required to be high, but it affects the framerate. + +### 2. Running the docker container -```bash -wget https://sourceforge.net/projects/asio/files/asio/1.22.1%20%28Stable%29/asio-1.22.1.tar.bz2 -tar xf asio-1.22.1.tar.bz2 -cd asio-1.22.1 -./configure -make -sudo make install +``` bash +xhost +local:docker +docker run -it --rm --net=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix ksp_bridge:humble ``` -### kRPC - Kerbal Space Program +### 3. inside the docker container -```bash -mkdir krpc; cd krpc -wget https://github.com/nullprofile/krpc/releases/download/0.4.9-1.12.1/krpc-0.4.9-1.12.1.zip -unzip krpc-0.4.9-1.12.1.zip +Resource monitor example: +``` bash +ros2 launch ksp_bridge_examples resource_monitor.launch.py ``` -Copy the *GameData/kRPC* directory into the *GameData* directory of Kerbal Space Program. -The path can be obtained through Steam (Right Click->Manage->Browse local files). +or -### kRPC - C++ library +Up and Down Launch example: +``` bash +ros2 launch ksp_bridge_examples up_and_down.launch.py +``` -```bash -cd krpc/client -unzip krpc-cpp-0.4.9.zip -cd krpc-cpp-0.4.9 -mkdir build; cd build -cmake .. -make -sudo make install -sudo ldconfig -``` +### 4. Development + +(for fast reference, your workflow may vary) -## Compilation +Mount the repository inside the docker container: +``` bash +docker run -it --rm --net=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $(pwd):/ws/ksp_bridge ksp_bridge:humble +``` -Assuming the ROS2 workspace is *~/ros2_ws*. +Code your custom packets outside the container and build and test inside the container with: -```bash -cd ~/ros2_ws/src -git clone https://github.com/g0mb4/ksp_bridge.git -cd .. +``` bash +cd /ws/ksp_bridge colcon build -source ~/.bashrc +source install/setup.bash +rqt & +ros2 run ksp_bridge_ .launch.py ``` -## Server settings -![up_and_down_assembly](doc/img/server_settings.jpg) -**Note**: *Max. time per update* is required to be high, but it affects the framerate. -## Usage -See examples. From 97bd8dc659720a9665632890cd11604d465c12d9 Mon Sep 17 00:00:00 2001 From: clausqr Date: Thu, 19 Oct 2023 19:40:39 -0300 Subject: [PATCH 8/9] Update ksp_bridge.cpp Removed debugging artifacts --- ksp_bridge/src/ksp_bridge.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/ksp_bridge/src/ksp_bridge.cpp b/ksp_bridge/src/ksp_bridge.cpp index bd4e5a7..4b51150 100644 --- a/ksp_bridge/src/ksp_bridge.cpp +++ b/ksp_bridge/src/ksp_bridge.cpp @@ -6,9 +6,7 @@ KSPBridge::KSPBridge() : rclcpp::Node("ksp_bridge") { declare_parameter("update_interval", 10); - printf("Declaring parameter: %s\n", "celestial_bodies" ); declare_parameter>("celestial_bodies", {"kerbin"}); - printf("Declared parameter: %s\n", "celestial_bodies" ); int64_t update_interval = get_parameter("update_interval").as_int(); m_param_celestial_bodies = get_parameter("celestial_bodies").as_string_array(); From 20958e9e8768dad63758fa44fad31390235477b1 Mon Sep 17 00:00:00 2001 From: claus Date: Thu, 19 Oct 2023 22:03:53 -0300 Subject: [PATCH 9/9] Rewrite README for dockerless branch --- README.md | 63 ++++++++++++++++++++++--------------------------------- 1 file changed, 25 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index f7f7290..823411f 100644 --- a/README.md +++ b/README.md @@ -14,16 +14,31 @@ Works with: ## Installation -### Install kRPC mod +### Build and install kRPC mod Install the [kRPC mod](https://github.com/nullprofile/krpc) and it's dependencies. -### Clone repository and build the docker container +``` bash +mkdir krpc + cd krpc + wget https://github.com/krpc/krpc/releases/download/v0.5.2/krpc-cpp-0.5.2.zip + unzip krpc-cpp-0.5.2.zip + cd krpc-cpp-0.5.2 + mkdir build + cd build + cmake .. + make + make install + ldconfig # may need sudo! +``` + +### Build and install ksp_bridge ``` bash -git clone https://github.com/clausqr/ksp_bridge -cd ksp_bridge -docker build -t ksp_bridge:humble . +cd ~/ros2_ws +git clone https://github.com/clausqr/ksp_bridge.git +source /opt/ros/humble/setup.bash +colcon build ``` ## Usage @@ -34,47 +49,19 @@ docker build -t ksp_bridge:humble . **Note**: *Max. time per update* is required to be high, but it affects the framerate. -### 2. Running the docker container - -``` bash -xhost +local:docker -docker run -it --rm --net=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix ksp_bridge:humble -``` +### 2. Running ksp_bridge Examples -### 3. inside the docker container +Resource Monitor -Resource monitor example: ``` bash +source ~/ros2_ws/ksp_bridge/install/local_setup.bash ros2 launch ksp_bridge_examples resource_monitor.launch.py ``` -or +or Up and Down Launch example: -``` bash -ros2 launch ksp_bridge_examples up_and_down.launch.py -``` - -### 4. Development - -(for fast reference, your workflow may vary) -Mount the repository inside the docker container: ``` bash -docker run -it --rm --net=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $(pwd):/ws/ksp_bridge ksp_bridge:humble -``` - -Code your custom packets outside the container and build and test inside the container with: - -``` bash -cd /ws/ksp_bridge -colcon build -source install/setup.bash -rqt & -ros2 run ksp_bridge_ .launch.py +ros2 launch ksp_bridge_examples up_and_down.launch.py ``` - - - - -