Skip to content

Repository files navigation

ROS 2 Humble Setup Guide (Ubuntu 22.04 LTS)

I. ROS 2 Humble Setup or run

    ./install.sh

1. Set Locale

Before installing ROS 2, ensure your system locale is set to UTF-8.

locale  # check for UTF-8

sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8

locale  # verify settings

2. Setup Sources

To add the ROS 2 apt repository, enable the Ubuntu Universe repository.

sudo apt install software-properties-common
sudo add-apt-repository universe

Add the ROS 2 GPG key with apt.

sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

sudo apt update

3. Install ROS 2 Packages

Update your apt repository caches and install ROS 2 packages.

sudo apt update
sudo apt upgrade

sudo apt install ros-humble-desktop

Install development tools.

sudo apt install ros-dev-tools

4. Environment Setup

To start working with ROS 2, source the setup script in each terminal session.

echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc && source ~/.bashrc

5. Try Some Examples

Talker-Listener Example

Open a terminal and start a talker node:

source /opt/ros/humble/setup.bash
ros2 run demo_nodes_py talker

Open another terminal and start a listener node: ✅

source /opt/ros/humble/setup.bash
ros2 run demo_nodes_py listener

II. OpenCV 4.8.0+ Installation for Librealsense

# Install dependencies
sudo apt update
sudo apt install -y build-essential cmake pkg-config \
libjpeg-dev libtiff-dev libpng-dev \
libgtk-3-dev libcanberra-gtk* \
libatlas-base-dev gfortran python3-dev

# Download OpenCV core
git clone https://github.com/opencv/opencv.git -b 4.8.0 --depth 1
git clone https://github.com/opencv/opencv_contrib.git -b 4.8.0 --depth 1


# Enter OpenCV directory
cd opencv-4.8.0

# Build OpenCV with contrib modules
mkdir build
cd build

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_C_COMPILER=gcc-11 -D CMAKE_CXX_COMPILER=g++-11 -D CMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc -D CMAKE_CUDA_STANDARD=14 -D CMAKE_CXX_STANDARD=14 -D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=OFF -D OPENCV_GENERATE_PKGCONFIG=ON -D BUILD_EXAMPLES=OFF -D OPENCV_ENABLE_NONFREE=ON -D WITH_IPP=OFF -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_opencv_adas=OFF -D BUILD_opencv_bgsegm=OFF -D BUILD_opencv_bioinspired=OFF -D BUILD_opencv_ccalib=OFF -D BUILD_opencv_datasets=ON -D BUILD_opencv_datasettools=OFF -D BUILD_opencv_face=OFF -D BUILD_opencv_latentsvm=OFF -D BUILD_opencv_line_descriptor=OFF -D BUILD_opencv_matlab=OFF -D BUILD_opencv_optflow=ON -D BUILD_opencv_reg=OFF -D BUILD_opencv_saliency=OFF -D BUILD_opencv_surface_matching=OFF -D BUILD_opencv_text=OFF -D BUILD_opencv_tracking=ON -D BUILD_opencv_xobjdetect=OFF -D BUILD_opencv_xphoto=OFF -D BUILD_opencv_stereo=OFF -D BUILD_opencv_hdf=OFF -D BUILD_opencv_cvv=OFF -D BUILD_opencv_fuzzy=OFF -D BUILD_opencv_dnn=OFF -D BUILD_opencv_dnn_objdetect=OFF -D BUILD_opencv_dnn_superres=OFF -D BUILD_opencv_dpm=OFF -D BUILD_opencv_quality=OFF -D BUILD_opencv_rapid=OFF -D BUILD_opencv_rgbd=OFF -D BUILD_opencv_sfm=OFF -D BUILD_opencv_shape=ON -D BUILD_opencv_stitching=OFF -D BUILD_opencv_structured_light=OFF -D BUILD_opencv_alphamat=OFF -D BUILD_opencv_aruco=OFF -D BUILD_opencv_phase_unwrapping=OFF -D BUILD_opencv_photo=OFF -D BUILD_opencv_gapi=OFF -D BUILD_opencv_video=ON -D BUILD_opencv_ml=OFF -D BUILD_opencv_python2=OFF -D WITH_GSTREAMER=OFF -D ENABLE_PRECOMPILED_HEADERS=OFF -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-4.8.0/modules -D WITH_CUDA=ON -D WITH_CUDNN=ON -D WITH_CUBLAS=ON -D CUDA_ARCH_BIN=8.7 -D BUILD_opencv_cudaarithm=OFF -D BUILD_opencv_cudaimgproc=OFF -D BUILD_opencv_cudafilters=OFF -D BUILD_opencv_cudaoptflow=ON -D OPENCV_ENABLE_NONFREE=OFF -D BUILD_opencv_cudalegacy=OFF -D BUILD_opencv_cudawarping=OFF ../


      
make -j$(nproc)
sudo make install

# Refresh linker cache
sudo ldconfig

III. Camera Node Setup

** Realsense SDK Install

cd ~
git clone https://github.com/IntelRealSense/librealsense.git
cd librealsense
sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules && sudo udevadm trigger
mkdir build && cd build
cmake .. -DFORCE_RSUSB_BACKEND=ON -DBUILD_EXAMPLES=true -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
sudo make install
sudo ldconfig

1. Clone the realsense_ros Repository

git clone https://github.com/IntelRealSense/realsense-ros.git
cd realsense-ros
colcon build --symlink-install

2. Source the Workspace

Source the newly built workspace:

source ~/realsense-ros/install/setup.bash

To make it persistent, add it to your .bashrc:

echo "source ~/realsense-ros/install/setup.bash" >> ~/.bashrc

IV. RTAB-Map Installation

1. Install RTAB-Map

sudo apt install -y ros-humble-rtabmap-ros

2. Ardupilot Parameter setup (Camera Downfacing)

SERIAL1_PROTOCOL = 2 (MAVLink2).

SERIAL1_BAUD = 115 (115200 baud)

VISO_TYPE = 1 (mavlink)

EK3_SRC1_POSXY = 6 (ExternalNav)

EK3_SRC1_VELXY = 6 (ExternalNav)

EK3_SRC1_POSZ = 1 (Baro which is safer)

EK3_SRC1_VELZ = 0 

EK3_SRC1_YAW = 6 (ExternalNav)

Zed cam param enable/disable path

nano ~/zed-ros2/install/zed_wrapper/share/zed_wrapper/config/common_stereo.yaml

3 Run the script


3.1 RGB-D SLAM with Zed2i

python3 slam_aero.py --ros_cam "ros2 launch zed_wrapper zed_camera.launch.py camera_model:=zed2i enable_ipc:=false ros_params_override_path:=/home/deathstroke/zed_conf.yaml" --rtabmap "ros2 launch rtabmap_launch rtabmap.launch.py \
rtabmap_args:=\"--delete_db_on_start\" \
rgb_topic:=/zed/zed_node/rgb/image_rect_color \
depth_topic:=/zed/zed_node/depth/depth_registered \
camera_info_topic:=/zed/zed_node/rgb/camera_info \
frame_id:=zed_camera_link \
use_sim_time:=true \
approx_sync:=true \
qos:=2 \
rviz:=false \
queue_size:=100"

3.2 RGB-D SLAM with Realsense D4XX series

python3 slam_aero.py --ros_cam "ros2 launch realsense2_camera rs_launch.py \
enable_depth:=true enable_color:=true enable_sync:=true \
depth_module.depth_profile:=640,480,30 \
rgb_camera.color_profile:=640,480,30 \
enable_sync:=true enable_gyro:=true enable_accel:=true \
unite_imu_method:=2 gyro_fps:=200 accel_fps:=200" \
--rtabmap "ros2 launch rtabmap_launch rtabmap.launch.py \
rtabmap_args:=\"--delete_db_on_start\" \
rgb_topic:=/camera/camera/color/image_raw \
depth_topic:=/camera/camera/depth/image_rect_raw \
camera_info_topic:=/camera/camera/color/camera_info \
frame_id:=camera_link \
use_sim_time:=true \
approx_sync:=true \
qos:=2 \
rviz:=false \
queue_size:=100"

3.3 Stereo SLAM with Zed2i

python3 slam_aero.py --ros_cam "ros2 launch zed_wrapper zed_camera.launch.py camera_model:=zed2i enable_ipc:=false ros_params_override_path:=/home/deathstroke/zed_conf.yaml" --rtabmap "ros2 launch rtabmap_launch rtabmap.launch.py \
rtabmap_args:='--delete_db_on_start' \
stereo:=true \
left_image_topic:=/zed/zed_node/left_gray/image_rect_gray \
right_image_topic:=/zed/zed_node/right_gray/image_rect_gray \
left_camera_info_topic:=/zed/zed_node/left_gray/camera_info \
right_camera_info_topic:=/zed/zed_node/right_gray/camera_info \
frame_id:=zed_camera_link \
use_sim_time:=true \
approx_sync:=true \
qos:=2 \
rviz:=false \
queue_size:=100 \
imu_topic:=/zed/zed_node/imu/data"

3.4 Stereo SLAM with Realsense D4XX Series

python3 slam_aero.py --ros_cam "ros2 launch realsense2_camera rs_launch.py \
enable_infra1:=true enable_infra2:=true enable_color:=true enable_sync:=true \
rgb_camera.color_profile:=640,480,30 \
enable_sync:=true enable_gyro:=true enable_accel:=true \
unite_imu_method:=2 gyro_fps:=200 accel_fps:=200 \
depth_module.infra_profile:=640,480,30" \
--rtabmap "ros2 launch rtabmap_launch rtabmap.launch.py \
rtabmap_args:=\"--delete_db_on_start\" \
stereo:=true \
left_image_topic:=/camera/camera/infra1/image_rect_raw \
right_image_topic:=/camera/camera/infra2/image_rect_raw \
left_camera_info_topic:=/camera/camera/infra1/camera_info \
right_camera_info_topic:=/camera/camera/infra2/camera_info \
frame_id:=camera_link \
use_sim_time:=true \
approx_sync:=true \
qos:=2 \
rviz:=false \
queue_size:=100"

3.5 Stereo SLAM and RGB-D SLAM with custom stereo camera

python3 slam_aero.py --ros_cam "your ros2 camera launch command" --rtabmap "your rtabmap launch command"

Flight Tests with RTABMAP SLAM

alt text alt text alt text

About

Rtabmap SLAM with realsense D4XX depth camera with ROS2 Humble

Topics

Resources

Stars

10 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages