introlab / rtabmap_ros

RTAB-Map's ROS package.
http://wiki.ros.org/rtabmap_ros
BSD 3-Clause "New" or "Revised" License
922 stars 549 forks source link

Help optimizing RTAB-Map for outdoor agricultural mapping with RealSense D455 #1053

Closed VanjaLjubobratovic closed 8 months ago

VanjaLjubobratovic commented 8 months ago

Hello, I'm working on a project which aims to use RealSense D455 and RTAB-Map in ROS2 in order to create an areal view map of agricultural terrains. The idea is that those systems would already be in place on an autonomous plant sprayer, used for something else, and they would create the map on the side so you can monitor the plants.

I have already developed and set up everything needed for that, but the results I'm getting are not really satisfying so I was wondering if anyone could point me in the right direction.

The main issue I'm facing is point cloud spray which you can see in the next couple of images: image

From a different angle the same area looks fairly decent image

But obviously when I rotate everything so I can get an areal view, the results aren't really usable and you can clearly see all the "smearing" I'm struggling with. mosaic

My camera launch parameters:

#!/bin/bash

resolution="848x480x60"

LC_NUMERIC="en_US.UTF-8"; ros2 launch realsense2_camera rs_launch.py \
rgb_camera.profile:=$resolution \
depth_module.profile:=$resolution \
enable_gyro:=true \
enable_accel:=true \
unite_imu_method:=2 \
gyro_fps:=400 \
accel_fps:=200 \
enable_infra1:=false \
enable_infra2:=false \
enable_sync:=false \
align_depth.enable:=true \
pointcloud.enable:=false \
initial_reset:=true \
depth_module.enable_auto_exposure:=true \
decimation_filter.enable:=false \
temporal_filter.enable:=true \
spatial_filter.enable:=true \
json_file_path:=/home/vanja/RTAB-Map-Orthophoto/configs/MediumDensity.json

RTAB-Map launch parameters:

LC_NUMERIC="en_US.UTF-8"; ros2 launch rtabmap_launch rtabmap.launch.py \
rtabmap_args:="--delete_db_on_start" \
rviz:=true \
rtabmap_viz:=false \
frame_id:=camera_link \
rgb_topic:=/camera/color/image_raw \
depth_topic:=/camera/aligned_depth_to_color/image_raw \
camera_info_topic:=/camera/color/camera_info \
approx_sync:=false \
wait_imu_to_init:=true \
queue_size:=300 \
cfg:=/home/vanja/RTAB-Map-Orthophoto/configs/rtab_config.ini\

RTAB-Map config file: rtab_config.txt

I would appreciate any suggestions on this. Also, please feel free to ask me about any additional information like databases, config files, launch files and similar. Thank you!

matlabbe commented 8 months ago

not really satisfying

That looks pretty good to me! ;)

The "spray" effect is caused by the realsense's disparity approach, it will interpolate depth on the edges of objects, so that there are interpolated disparity between the foreground and background. This can be removed by adjusting the depth confidence on realsense driver. I think you can feed a preset to realsense2 ros driver to change how depth is computed, which could remove the interpolated disparity around foreground objects.

VanjaLjubobratovic commented 8 months ago

Ah, ok. So it's definitely the camera's parameters I should be playing with. I'll try that and report on the results. Thanks!

VanjaLjubobratovic commented 8 months ago

@matlabbe Hi, I think I found a solution I find satisfying and I will just repost what I wrote on RealSense GitHub.

So after some experimentation I have managed to find a solution which I would call satisfactory.

In terms of camera settings:

In terms of camera operation:

In terms of filtering:

The results of filtering on the point cloud RECORDED WITH ORIGINAL CAMERA SETTINGS: BEFORE NoFilter

AFTER Filter

When all of the steps above are actually combined, the result should be quite good. Here's my code if someone's interested in implementation details

I hope someone finds this useful.

matlabbe commented 8 months ago

Great! thx for sharing!