Skip to content

Commit

Permalink
Merge branch 'main' into feature/ros2
Browse files Browse the repository at this point in the history
  • Loading branch information
ulken94 authored Jan 17, 2024
2 parents 56ef03b + 6996b46 commit eeab16f
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 28 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/docker-build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: docker-build-test
on:
- pull_request
- push

jobs:
docker-build:
runs-on: [self-hosted, slambox]
steps:
- uses: actions/checkout@v3
with:
submodules: true
ref: ${{ github.ref }}
- name: Docker build
run: docker build . -t jmarpledev/slambox-ros2:github_action -f docker/Dockerfile --build-arg UID=$(id -u) --build-arg GID=$(id -g)

format-lint:
runs-on: [self-hosted, slambox]
needs: docker-build
steps:
- name: format-and-lint
uses: addnab/docker-run-action@v3
with:
image: jmarpledev/slambox-ros2:github_action
shell: bash
options: -v ${{ github.workspace }}:/home/user/ros2_ws/src/slambox-ros2
run: |
cd ~/ros2_ws/src/slambox-ros2 && \
export PATH=$PATH:/home/user/.local/bin && \
./run_check.sh all
build-test:
runs-on: [self-hosted, slambox]
needs: docker-build
steps:
- name: build-test
uses: addnab/docker-run-action@v3
with:
image: jmarpledev/slambox-ros2:github_action
shell: bash
options: -v ${{ github.workspace }}:/home/user/ros2_ws/src/slambox-ros2
run: |
cd ~/ros2_ws && \
colcon build
unit-test:
runs-on: [self-hosted, slambox]
needs: docker-build
steps:
- name: build-and-unittest
uses: addnab/docker-run-action@v3
with:
image: jmarpledev/slambox-ros2:github_action
shell: bash
options: -v ${{ github.workspace }}:/home/user/ros2_ws/src/slambox-ros2
run: |
cd ~/ros2_ws && \
colcon test
34 changes: 16 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Table of Contents
# 1. Getting started
## 1.1. Installation
### 1.1.1. Requirements
- [ROS noetic](https://wiki.ros.org/noetic/Installation/Ubuntu) (Recommended)
- [SLAMBOX-SDK](https://github.com/j-marple-dev/slambox-sdk) (v0.1.0)
- [ROS humble](https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html) (Recommended)
- [SLAMBOX-SDK](https://github.com/j-marple-dev/slambox-sdk) (v0.2.0)
- glog (>=v0.6.0)
- CMake (>= 3.16.3)
- docker (Optional but highly recommended)
Expand All @@ -34,13 +34,13 @@ Table of Contents
* Our docker image includes development environment. We highly recommend docker system.
```shell
# Clone this repository
git clone https://github.com/j-marple-dev/slambox-ros.git --recursive
git clone https://github.com/j-marple-dev/slambox-ros2.git
# Change directory
cd slambox-ros
cd slambox-ros2
# Build docker image
docker build . -t jmarpledev/slambox-ros -f docker/Dockerfile --build-arg UID=$(id -u) --build-arg GID=$(id -u)
docker build . -t jmarpledev/slambox-ros2 -f docker/Dockerfile --build-arg UID=$(id -u) --build-arg GID=$(id -u)
```

### 1.1.3. Local ROS system
Expand All @@ -51,14 +51,14 @@ Table of Contents


```shell
# Assuming that your ROS workspace is ~/catkin_ws
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
git clone https://github.com/j-marple-dev/slambox-ros.git --recursive
# Assuming that your ROS workspace is ~/ros2_ws
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src
git clone https://github.com/j-marple-dev/slambox-ros2.git --recursive
cd ../
catkin build slambox_ros
colcon build slambox_ros
# Choose the shell which you are using
source devel/setup.{bash|zsh}
source install/setup.{bash|zsh}
```

## 1.2. Configuration
Expand Down Expand Up @@ -88,28 +88,28 @@ subscribe:
### 1.3.1. Local ROS system
- Running ROS node
```shell
roslaunch slambox_ros slambox_ros_client.launch
ros2 launch slambox_ros2 slambox_ros_client_launch.py
```

- Check rostopic in another shell
```shell
rostopic hz /SLAMBOX/odom /SLAMBOX/pointcloud
ros2 topic hz /SLAMBOX/odom /SLAMBOX/pointcloud
```

### 1.3.2. Running on Docker image
- Run docker container for running SLAMBOX-ROS client
```shell
docker run -ti --privileged -e DISPLAY=:0 -e TERM=xterm-256color -v /tmp/.X11-unix:/tmp/.X11-unix:ro -v /dev:/dev -v $PWD:/home/user/catkin_ws/src/slambox-ros --network host jmarpledev/slambox-ros /usr/bin/zsh
docker run -ti --privileged -e DISPLAY=:0 -e TERM=xterm-256color -v /tmp/.X11-unix:/tmp/.X11-unix:ro -v /dev:/dev -v $PWD:/home/user/ros2_ws/src/slambox-ros2 --network host jmarpledev/slambox-ros2 /usr/bin/zsh
```

- Run docker container for running SLAMBOX-ROS client with rviz visualization
```shell
docker run -ti --privileged -e TERM=xterm-256color -e DISPLAY=:0 -v /dev:/dev -v /tmp/.X11-unix:/tmp/.X11-unix:ro -v $PWD:/home/user/catkin_ws/src/slambox-ros --network host jmarpledev/slambox-ros /usr/bin/bash -lic "roslaunch slambox_ros slambox_ros_client.launch rviz:=true"
docker run -ti --privileged -e TERM=xterm-256color -e DISPLAY=:0 -v /dev:/dev -v /tmp/.X11-unix:/tmp/.X11-unix:ro -v $PWD:/home/user/ros2_ws/src/slambox-ros2 --network host jmarpledev/slambox-ros2 /usr/bin/bash -lic "ros2 launch slambox_ros2 slambox_ros_client_launch.py"
```

- Run docker container with shell (For development environment)
```shell
docker run -ti --privileged -e DISPLAY=:0 -e TERM=xterm-256color -v /tmp/.X11-unix:/tmp/.X11-unix:ro -v /dev:/dev -v $PWD:/home/user/catkin_ws/src/slambox-ros --network host jmarpledev/slambox-ros /usr/bin/zsh
docker run -ti --privileged -e DISPLAY=:0 -e TERM=xterm-256color -v /tmp/.X11-unix:/tmp/.X11-unix:ro -v /dev:/dev -v $PWD:/home/user/ros2_ws/src/slambox-ros2 --network host jmarpledev/slambox-ros2 /usr/bin/zsh
```


Expand All @@ -121,6 +121,4 @@ Please visit https://sbox.jmarple.ai for more information.

# 4. External resources
- [glog](https://github.com/google/glog) - Google Logging Library
- [fmt](https://github.com/fmtlib/fmt) Modern formatting library
- [cli](https://github.com/daniele77/cli) - C++ CLI Library
- [ducker](https://github.com/JeiKeiLim/ducker) - Docker Helper CLI application
3 changes: 3 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ RUN git clone https://github.com/j-marple-dev/slambox-sdk.git -b v0.2.0 --recurs
make -j && \
sudo make install

RUN echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/local/lib" >> /home/user/.bashrc
RUN echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/local/lib" >> /home/user/.zshrc

# Install ROS2 humble pre-requisites
RUN sudo apt-get update && sudo apt-get install -y python3-rosdep ros-humble-pluginlib python3-colcon-common-extensions

Expand Down
14 changes: 10 additions & 4 deletions docker/Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,18 @@ RUN echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/home/user/.local/lib" >> /ho
# Install SLAMBOX SDK
RUN sudo apt-get install -y libserial-dev
WORKDIR /home/user
RUN git clone https://github.com/j-marple-dev/slambox-sdk.git -b v0.1.0 && \

RUN git clone https://github.com/j-marple-dev/slambox-sdk.git -b v0.2.0 && \

mkdir -p slambox-sdk/build && \
cd slambox-sdk/build && \
cmake -G "Unix Makefiles" .. && \
make -j && \
sudo make install

RUN echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/local/lib" >> /home/user/.bashrc
RUN echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/local/lib" >> /home/user/.zshrc

# Install ROS2 humble pre-requisites
RUN sudo apt-get purge -y libtbb-dev \
&& sudo apt-get update \
Expand All @@ -77,9 +82,10 @@ RUN sudo apt-get purge -y libtbb-dev \
RUN mkdir -p ~/ros2_ws/src
COPY --chown=user:user ./ /home/user/ros2_ws/src/slambox_ros2

RUN /bin/bash -c '. /opt/ros/humble/setup.bash; cd ~/ros2_ws; colcon build -j1'
RUN echo "source ~/catkin_ws/install/setup.bash" >> ~/.bashrc
RUN echo "source ~/catkin_ws/install/setup.zsh" >> ~/.zshrc
RUN /bin/bash -c '. /opt/ros/humble/setup.bash; cd ~/ros2_ws; colcon build --parallel-workers 1'
RUN echo "source ~/ros2_ws/install/setup.bash" >> ~/.bashrc
RUN echo "source ~/ros2_ws/install/setup.zsh" >> ~/.zshrc

RUN rm -rf /home/user/ros2_ws/src

RUN echo "export ROS_MASTER_URI=http://192.168.0.138:11311" >> ~/.zshrc
Expand Down
4 changes: 1 addition & 3 deletions src/applications/driver_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ SLAMBOXDriverClient::SLAMBOXDriverClient(const rclcpp::NodeOptions &options)
this->create_publisher<nav_msgs::msg::Odometry>(publish_odom_topic_, 1);
pointcloud_pub_ = this->create_publisher<sensor_msgs::msg::PointCloud2>(
publish_pointcloud_topic_, 1);
// request_sub_ = nh_.subscribe(subscribe_request_topic_, 1,
// &SLAMBOXDriverClient::callback_request_,
// this);

request_sub_ = this->create_subscription<std_msgs::msg::String>(
subscribe_request_topic_, 1,
std::bind(&SLAMBOXDriverClient::callback_request_, this,
Expand Down
8 changes: 5 additions & 3 deletions tests/test_msg_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@

#include <glog/logging.h>
#include <gtest/gtest.h>

#include <random>

#include <nav_msgs/msg/odometry.hpp>
#include <rclcpp/rclcpp.hpp>
#include <sensor_msgs/msg/point_cloud2.hpp>

#include <random>

#include <sbox/sbox_msgs/Odometry.hpp>
#include <sbox/sbox_msgs/PointCloud2.hpp>

Expand Down Expand Up @@ -133,7 +134,8 @@ TEST(MSGConverter, PointCloud2Conversion) {
}
pointcloud.is_dense = dis_bool(gen);

sensor_msgs::msg::PointCloud2 ros_pointcloud = sbox_msgs::to_ros_msg(pointcloud);
sensor_msgs::msg::PointCloud2 ros_pointcloud =
sbox_msgs::to_ros_msg(pointcloud);

EXPECT_EQ(pointcloud.timestamp_sec, ros_pointcloud.header.stamp.sec);
EXPECT_EQ(pointcloud.timestamp_nsec, ros_pointcloud.header.stamp.nanosec);
Expand Down

0 comments on commit eeab16f

Please sign in to comment.