introlab / rtabmap

RTAB-Map library and standalone application
https://introlab.github.io/rtabmap
Other
2.74k stars 779 forks source link

use image filter replace original color image but not work! anyone can help me !!!!! thanks! #1229

Closed qetuo105487900 closed 4 months ago

qetuo105487900 commented 7 months ago

i use this command

roslaunch rtabmap_launch rtabmap.launch \
    rtabmap_args:="--delete_db_on_start" \
    depth_topic:=/filter/rs_l515/aligned_depth_to_color/image_raw \
    rgb_topic:=/filter/rs_l515/color/image_filter \
    camera_info_topic:=/filter/rs_l515/color/camera_info \
    approx_sync:=false

is not work on rtabmap

but i use this command

roslaunch rtabmap_launch rtabmap.launch \
    rtabmap_args:="--delete_db_on_start" \
    depth_topic:=/rs_l515/aligned_depth_to_color/image_raw \
    rgb_topic:=/rs_l515/color/image_raw \
    camera_info_topic:=/rs_l515/color/camera_info \
    approx_sync:=false

it can work on rtabmap

so, how to do that i could run with image_filter topic? maybe copy camera info and change stamp to time.now() ?

update

it is still failed that i copy camera info and change stamp to time.now()

qetuo105487900 commented 7 months ago

always get the warning code

[ WARN] [1709477545.228805757]: /rtabmap/rtabmap: Did not receive data since 5 seconds! Make sure the input topics are published ("$ rostopic hz my_topic") and the timestamps in their header are set. If topics are coming from different computers, make sure the clocks of the computers are synchronized ("ntpdate"). Parameter "approx_sync" is false, which means that input topics should have all the exact timestamp for the callback to be called.
/rtabmap/rtabmap subscribed to (exact sync):
   /rtabmap/odom \
   /filter/rs_l515/color/image_raw \
   /filter/rs_l515/aligned_depth_to_color/image_raw \
   /filter/rs_l515/color/camera_info \
   /rtabmap/odom_info
qetuo105487900 commented 7 months ago

i see here: https://robotics.stackexchange.com/questions/23394/rtabmap-rtabmap-did-not-receive-data-since-5-seconds

mobiiin said is encoding problem ? is it right ? [update] it is still not work ! wt....

qetuo105487900 commented 7 months ago

i also run rostopic hz and i found the original and the filters' are very similar. so maybe is not the problem.

qetuo105487900 commented 6 months ago

should i use tf replace tf_static ? [update] it is still not work ! wt....

matlabbe commented 6 months ago

What is the rostopic hz output for:

rostopic hz \
   /filter/rs_l515/color/image_raw \
   /filter/rs_l515/aligned_depth_to_color/image_raw \
   /filter/rs_l515/color/camera_info \
qetuo105487900 commented 6 months ago

hello, @matlabbe

[1] run with depth_topic:=/rs_l515/aligned_depth_to_color/image_raw \ rgb_topic:=/rs_l515/color/image_raw \ camera_info_topic:=/rs_l515/color/camera_info \ which publish from realsense nodelet Screenshot from 2024-03-05 20-46-11 this can work well !

[2] run with depth_topic:=/filter/rs_l515/aligned_depth_to_color/image_raw \ rgb_topic:=/filter/rs_l515/color/image_raw \ camera_info_topic:=/filter/rs_l515/color/camera_info \ which publish from (realsense nodelet after sharping then publish) Screenshot from 2024-03-05 20-43-10

this can't work !

[3] this is hz between /filter/rs_l515/color/image_raw /rs_l515/color/image_raw /filter/rs_l515/aligned_depth_to_color/image_raw /rs_l515/aligned_depth_to_color/image_raw Screenshot from 2024-03-05 20-44-40 i sure that the encoding color are both rgb8 depth are both 16UC1

qetuo105487900 commented 6 months ago

maybe problem is at the tf not publish from rs_l515_link? [not this] but i create a tf_frame from base_link, it is still can't work

matlabbe commented 6 months ago

You should have warnings in rtabmap terminal if topics can be synchronized but don't have the right format or if there is a TF issue. If you have warnings about topics not received for 5 seconds, you may check if /filter/rs_l515/color/camera_info also published.

I see that you are also using approx_sync:=false, if the topics don't have the same stamps, use approx_sync:=true instead.

qetuo105487900 commented 6 months ago

yes, mr. @matlabbe , i had use approx_sync:=true instead. but i still can't slove the problem. so, can't i use /rs_d435i/color/camera_info as camera_info_topic ? like this :

  <!-- RGB-D related topics -->
  <arg name="rgb_topic"               default="filter/rs_d435i/color/image_raw" />
  <arg name="depth_topic"             default="/rs_d435i/aligned_depth_to_color/image_raw" />
  <arg name="camera_info_topic"       default="/rs_d435i/color/camera_info" />
  <arg name="depth_camera_info_topic" default="$(arg camera_info_topic)" />

as below is sharpened code, are there any problem in the code ?

#!/usr/bin/env python3
import rospy
import cv2
import numpy as np
from cv_bridge import CvBridge, CvBridgeError
from sensor_msgs.msg import Image

def color_callback(data):

    cv_image = bridge.imgmsg_to_cv2(data, "bgr8")
    sharpened_img = sharpened(cv_image)
    sharpened_img = cv2.cvtColor(sharpened_img, cv2.COLOR_BGR2RGB)

    sharpened_img = bridge.cv2_to_imgmsg(sharpened_img, "rgb8")

    # Publishing
    pub_filter_color.publish(sharpened_img)

if __name__ == '__main__':
    rospy.init_node('image_filter', anonymous=True)

    bridge = CvBridge()
    # Subscribers
    rospy.Subscriber("/rs_d435i/color/image_raw", Image, color_callback)

    # Publishers
    pub_filter_color = rospy.Publisher("/filter/rs_d435i/color/image_raw", Image, queue_size=10)
    rospy.spin()

thanks!!

matlabbe commented 6 months ago

You can use /rs_d435i/color/camera_info if /filter/rs_d435i/color/image_raw has still the same resolution (and that you didn't change the scale of the image, i.e., kept same calibration).

matlabbe commented 6 months ago

Another thing I just noticed, you should copy the old header in your new published topic header.

sharpened_img.header = data.header