Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.vscode/

log
build
install
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
96 changes: 40 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
1 change: 1 addition & 0 deletions ksp_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ ament_target_dependencies(${PROJECT_NAME}
ksp_bridge_interfaces
tf2
tf2_ros
tf2_geometry_msgs
)

target_link_libraries(${PROJECT_NAME}
Expand Down
2 changes: 1 addition & 1 deletion ksp_bridge/src/ksp_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ KSPBridge::KSPBridge()
: rclcpp::Node("ksp_bridge")
{
declare_parameter<int64_t>("update_interval", 10);
declare_parameter<std::vector<std::string>>("celestial_bodies", {});
declare_parameter<std::vector<std::string>>("celestial_bodies", {"kerbin"});

int64_t update_interval = get_parameter("update_interval").as_int();
m_param_celestial_bodies = get_parameter("celestial_bodies").as_string_array();
Expand Down
5 changes: 4 additions & 1 deletion ksp_bridge/src/utils.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include <cctype>
#include <ksp_bridge/utils.hpp>
#include <tf2/LinearMath/Quaternion.h>
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>

#include <tf2/LinearMath/Transform.h>
#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>


const char* base_name(const char* file)
{
Expand Down