diff --git a/.gitignore b/.gitignore index 687f872..81c8421 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .vscode/ - +log +build +install \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..774bf48 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +FROM osrf/ros:humble-desktop + +# 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 + +RUN ldconfig + +### Bridge into it +## Build ksp_bridge +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 clausqr:ksp_bridge . +## Running this container +# $ 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..823411f 100644 --- a/README.md +++ b/README.md @@ -4,80 +4,64 @@ 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. - -### Libraries - -Installation of the protobuf library: - -```bash -sudo apt update -sudo apt install -y libprotobuf-dev +### Build and install kRPC mod + +Install the [kRPC mod](https://github.com/nullprofile/krpc) and it's dependencies. + +``` 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! ``` -Installation of the ASIO standalone library: +### Build and install ksp_bridge -```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 +cd ~/ros2_ws +git clone https://github.com/clausqr/ksp_bridge.git +source /opt/ros/humble/setup.bash +colcon build ``` -### kRPC - Kerbal Space Program - -```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 -``` +## Usage -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). +### 1. Server settings inside KSP -### kRPC - C++ library +![up_and_down_assembly](doc/img/server_settings.jpg) -```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 -``` +**Note**: *Max. time per update* is required to be high, but it affects the framerate. -## Compilation +### 2. Running ksp_bridge Examples -Assuming the ROS2 workspace is *~/ros2_ws*. +Resource Monitor -```bash -cd ~/ros2_ws/src -git clone https://github.com/g0mb4/ksp_bridge.git -cd .. -colcon build -source ~/.bashrc +``` bash +source ~/ros2_ws/ksp_bridge/install/local_setup.bash +ros2 launch ksp_bridge_examples resource_monitor.launch.py ``` -## Server settings - -![up_and_down_assembly](doc/img/server_settings.jpg) +or -**Note**: *Max. time per update* is required to be high, but it affects the framerate. +Up and Down Launch example: -## Usage - -See examples. +``` bash +ros2 launch ksp_bridge_examples up_and_down.launch.py +``` 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/ksp_bridge.cpp b/ksp_bridge/src/ksp_bridge.cpp index e4d868f..4b51150 100644 --- a/ksp_bridge/src/ksp_bridge.cpp +++ b/ksp_bridge/src/ksp_bridge.cpp @@ -6,7 +6,7 @@ KSPBridge::KSPBridge() : rclcpp::Node("ksp_bridge") { declare_parameter("update_interval", 10); - declare_parameter>("celestial_bodies", {}); + declare_parameter>("celestial_bodies", {"kerbin"}); int64_t update_interval = get_parameter("update_interval").as_int(); m_param_celestial_bodies = get_parameter("celestial_bodies").as_string_array(); 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) {