rtabmap+stereo camera+two web cam

asked 2017-10-31 14:25:44 -0600

zahra.kh gravatar image

updated 2017-11-01 09:26:27 -0600

matlabbe gravatar image

hi all. i have two Microsoft webcams that use for stereo mapping and localization with rtabmap. my launch file for run these camera and use rtabmap is this:


<arg name="rtabmapviz" default="true" />
<group ns="stereo">

  <node name="left" pkg="usb_cam" type="usb_cam_node" output="screen" >
    <param name="video_device" value="/dev/video0" />
    <param name="image_width" value="640" />
    <param name="image_height" value="480" />
    <param name="pixel_format" value="yuyv" />
    <param name="camera_frame_id" value="left" />
    <param name="io_method" value="mmap"/>
    <param name="camera_info_url" value="file:////home/zahra/Desktop/stereo/left.yaml"/>

  <node name="right" pkg="usb_cam" type="usb_cam_node" output="screen" >
    <param name="video_device" value="/dev/video1" />
    <param name="image_width" value="640" />
    <param name="image_height" value="480" />
    <param name="pixel_format" value="yuyv" />
    <param name="camera_frame_id" value="right" />
    <param name="io_method" value="mmap"/>
    <param name="camera_info_url" value="file:///home/zahra/Desktop/stereo/right.yaml"/>

<node name="stereo_image_proc" pkg="stereo_image_proc" type="stereo_image_proc" output="screen"  >

<remap from="/stereo/left/image" to="/stereo/left/image_raw"/>
<remap from="/stereo/right/image" to="/stereo/right/image_raw"/>
    <param name="prefilter_size"            value="35"/>
        <param name="prefilter_cap"             value="11"/>
        <param name="correlation_window_size"   value="41"/>
        <param name="min_disparity"             value="-15"/>
        <param name="disparity_range"           value="128"/>
        <param name="uniqueness_ratio"          value="0.0"/>
        <param name="texture_threshold"         value="1000"/>
        <param name="speckle_size"              value="500"/>
        <param name="speckle_range"             value="16"/>
        <param name="approximate_sync"          value="true"/>
        <param name="queue_size"                value="5"/>


<node name="stereo_cam" pkg="image_view" type="stereo_view" output="screen" >
<param name="queue_size" value="2000" />
<param name="approximate_sync" value="True" />
<remap from="/stereo/left/image" to="/stereo/left/image_raw"/>
<remap from="/stereo/right/image" to="/stereo/right/image_raw"/>

<!-- rotate camera so z axis is up and x forward. -->
   <arg name="pi/2" value="1.5707963267948966" />
   <node pkg="tf" type="static_transform_publisher" name="camera_base_link" args="0 0 0 -$(arg pi/2) 0 -$(arg pi/2) camera_link stereo/left 100" /> 

<group ns="rtabmap">   

      <!-- Stereo Odometry -->   
      <node pkg="rtabmap_ros" type="stereo_odometry" name="stereo_odometry" output="screen">
         <remap from="left/image_rect"       to="/stereo/left/image_rect"/>
         <remap from="right/image_rect"      to="/stereo/right/image_rect"/>
         <remap from="left/camera_info"      to="/stereo/left/camera_info"/>
         <remap from="right/camera_info"     to="/stereo_camera/right/camera_info"/>

    <param name="approx_sync"                   type="bool"     value="true"/>
        <param name="frame_id"                      type="string"   value="camera_link"/>
        <param name="odom_frame_id"                 type="string"   value="odom"/>
        <param name="queue_size"                    type="int"      value="5"/>

<!-- Visual SLAM: args: "delete_db_on_start" and "udebug" -->
      <node name="rtabmap" pkg="rtabmap_ros" type="rtabmap" output="screen" args="--delete_db_on_start">
         <param name="frame_id"         type="string" value="camera_link"/>
         <param name="subscribe_stereo" type="bool" value="true"/>
         <param name="subscribe_depth"  type="bool" value="false"/>

         <remap from="left/image_rect"   to="/stereo/left/image_rect_color"/>
         <remap from="right/image_rect"  to="/stereo/right/image_rect"/>
         <remap from="left/camera_info"  to="/stereo/left/camera_info"/>
         <remap from="right/camera_info" to="/stereo_camera/right/camera_info"/>
     <remap from="odom" to="/rtabmap/odom"/>

        <param name="approx_sync"                   type="bool"     value="true"/>
        <param name="queue_size"                    type="int"      value="30"/>


<!-- Visualisation RTAB-Map -->
      <node if="$(arg rtabmapviz)" pkg="rtabmap_ros" type="rtabmapviz" name="rtabmapviz" args="-d $(find rtabmap_ros)/launch/config/rgbd_gui.ini" output="screen">
         <param name="subscribe_stereo"    type="bool" value="true"/>
         <param name ...
edit retag flag offensive close merge delete


Can you verify that topics that stereo_odometry is subscribed to are actually published? "$ rostopic hz"

matlabbe gravatar imagematlabbe ( 2017-11-01 09:28:31 -0600 )edit

i changed my launch file : for (<remap from="right/camera_info" to="/stereo/right/camera_info"/>) , for

zahra.kh gravatar imagezahra.kh ( 2017-11-02 00:33:34 -0600 )edit

(i changed stereo/left to left ) , but when run the error is:

zahra.kh gravatar imagezahra.kh ( 2017-11-02 00:35:15 -0600 )edit

[ WARN] (2017-11-02 12:25:16.648) Stereo.cpp:159::computeCorrespondences() A large number (374/382) of stereo correspondences are rejected!

zahra.kh gravatar imagezahra.kh ( 2017-11-02 00:36:16 -0600 )edit

Optical flow may have failed, images are not calibrated, the background is too far (no disparity between the images) or maximum disparity may be too small (128).

zahra.kh gravatar imagezahra.kh ( 2017-11-02 00:36:23 -0600 )edit

[ WARN] (2017-11-02 12:25:16.651) OdometryF2M.cpp:386::computeTransform() Registration failed: "Not enough features in images (old=1, new=327, min=20)"

zahra.kh gravatar imagezahra.kh ( 2017-11-02 00:36:48 -0600 )edit

It seems a calibration problem. Also, if the two webcams cannot be hardware synchronized, you can only use the cameras in static because disparity would change between left and right images while moving. Can you show a screenshot of left and right image side by side? rosrun image_view stereo_view

matlabbe gravatar imagematlabbe ( 2017-11-03 08:01:18 -0600 )edit
matlabbe gravatar imagematlabbe ( 2017-11-03 08:04:06 -0600 )edit