0
$\begingroup$

Rosanswers logo

hi i have stereo images that save in a directory. i used rtabmap_ros package and this launch file for created map and localization:

<launch>

   <!-- stereo_20Hz directory -->
   <arg name="dir"        default="$(env HOME)/Downloads/stereo_20Hz" />

   <!-- Choose visualization -->
   <arg name="rviz"       default="false" />
   <arg name="rtabmapviz" default="true" />

   <arg name="rate"       default="20" />

   <arg name="ground_is_obstacle" default="false"/>
   <arg name="align_with_ground"  default="false"/>

   <!-- Run stereo_sequence_publisher to publish synchronized images -->
   <node name="stereo_pub" pkg="bag_tools" type="stereo_sequence_publisher.py" output="screen">
      <param name="image_dir_left"         value="$(arg dir)/left"/>
      <param name="image_dir_right"        value="$(arg dir)/right"/>
      <param name="file_pattern"           value="*.jpg"/>
      <param name="camera_info_file_left"  value="$(arg dir)/stereo_20Hz_ros_left.yaml"/>
      <param name="camera_info_file_right" value="$(arg dir)/stereo_20Hz_ros_right.yaml"/>
      <param name="frequency"              value="$(arg rate)"/>
      <remap from="/stereo_camera/left/image_color"  to="/stereo_camera/left/image_raw" />
      <remap from="/stereo_camera/right/image_color" to="/stereo_camera/right/image_raw" />
      <remap from="/stereo_camera/left/camera_info"  to="/stereo_camera/left/camera_info" />
      <remap from="/stereo_camera/right/camera_info" to="/stereo_camera/right/camera_info" />
   </node>

   <!-- Run the ROS package stereo_image_proc for image rectification -->
   <group ns="/stereo_camera" >
      <node pkg="stereo_image_proc" type="stereo_image_proc" name="stereo_image_proc"/>
   
<!-- Disparity to depth -->
    <node pkg="nodelet" type="nodelet" name="disparity2depth" args="standalone rtabmap_ros/disparity_to_depth"/>
  </group>

   <!-- 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_20Hz_left 100" /> 

   <include file="$(find rtabmap_ros)/launch/rtabmap.launch">
      <arg name="rtabmap_args" value="--delete_db_on_start --Rtabmap/CreateIntermediateNodes true --voxel_size 0.0 --Vis/EstimationType 1 --Vis/MinInliers 15 --SURF/HessianThreshold 100 --Grid/3DGroundIsObstacle $(arg ground_is_obstacle) --Odom/AlignWithGround $(arg align_with_ground)" />
      <arg name="rviz"             value="$(arg rviz)" />
      <arg name="rtabmapviz"       value="$(arg rtabmapviz)" />

    
<arg name="rgb_topic"               value="/stereo_camera/left/image_rect" />
  <arg name="depth_topic"             value="/stereo_camera/depth_raw" />
  <arg name="camera_info_topic"       value="/stereo_camera/left/camera_info" />
   </include>

</launch>

after mapping and saving it, i used demo_turtlebot_mapping.launch in rtabmap_ros package and changed this launch file for navigation:

<launch>
  <!-- 
       Bringup Turtlebot:
       $ roslaunch turtlebot_bringup minimal.launch
       
       Mapping:
       $ roslaunch rtabmap_ros demo_turtlebot_mapping.launch
       
       Visualization:
       $ roslaunch rtabmap_ros demo_turtlebot_rviz.launch
       
       This launch file is a one to one replacement of the gmapping_demo.launch in the 
       "SLAM Map Building with TurtleBot" tutorial:
       http://wiki.ros.org/turtlebot_navigation/Tutorials/indigo/Build%20a%20map%20with%20SLAM
       
       For localization-only after a mapping session, add argument "localization:=true" to
       demo_turtlebot_mapping.launch line above. Move the robot around until it can relocalize in 
       the previous map, then the 2D map should re-appear again. You can then follow the same steps 
       from 3.3.2 of the "Autonomous Navigation of a Known Map with TurtleBot" tutorial:
       http://wiki.ros.org/turtlebot_navigation/Tutorials/Autonomously%20navigate%20in%20a%20known%20map
 
       For turtlebot in simulation (Gazebo):
         $ roslaunch turtlebot_gazebo turtlebot_world.launch
         $ roslaunch rtabmap_ros demo_turtlebot_mapping.launch simulation:=true
         $ roslaunch rtabmap_ros demo_turtlebot_rviz.launch
  -->
  
  <arg name="database_path"     default="rtabmap.db"/>
  <arg name="rgbd_odometry"     default="false"/>
  <arg name="rtabmapviz"        default="false"/>
  <arg name="localization"      default="false"/>
  <arg name="simulation"        default="false"/>
  <arg     if="$(arg localization)" name="args"  default=""/>
  <arg unless="$(arg localization)" name="args"  default="--delete_db_on_start"/>

  <arg     if="$(arg simulation)" name="rgb_topic"   default="/stereo_camera/left/image_rect"/>
  <arg unless="$(arg simulation)" name="rgb_topic"   default="/camera/rgb/image_rect_color"/>
  <arg     if="$(arg simulation)" name="depth_topic" default="/stereo_camera/depth_raw"/>
  <arg unless="$(arg simulation)" name="depth_topic" default="/camera/depth_registered/image_raw"/>
  <arg name="camera_info_topic" default="/stereo_camera/left/camera_info"/>
  
  <arg name="wait_for_transform"  default="0.2"/> 
  <!-- 
      robot_state_publisher's publishing frequency in "turtlebot_bringup/launch/includes/robot.launch.xml" 
      can be increase from 5 to 10 Hz to avoid some TF warnings.
  -->

<!-- stereo_20Hz directory -->
   <arg name="dir"        default="$(env HOME)/Downloads/stereo_20Hz" />
   <arg name="rate"       default="20" />
   <!-- Run stereo_sequence_publisher to publish synchronized images -->
   <node name="stereo_pub" pkg="bag_tools" type="stereo_sequence_publisher.py" output="screen">
      <param name="image_dir_left"         value="$(arg dir)/left"/>
      <param name="image_dir_right"        value="$(arg dir)/right"/>
      <param name="file_pattern"           value="*.jpg"/>
      <param name="camera_info_file_left"  value="$(arg dir)/stereo_20Hz_ros_left.yaml"/>
      <param name="camera_info_file_right" value="$(arg dir)/stereo_20Hz_ros_right.yaml"/>
      <param name="frequency"              value="$(arg rate)"/>
      <remap from="/stereo_camera/left/image_color"  to="/stereo_camera/left/image_raw" />
      <remap from="/stereo_camera/right/image_color" to="/stereo_camera/right/image_raw" />
      <remap from="/stereo_camera/left/camera_info"  to="/stereo_camera/left/camera_info" />
      <remap from="/stereo_camera/right/camera_info" to="/stereo_camera/right/camera_info" />
   </node>

   <!-- Run the ROS package stereo_image_proc for image rectification -->
   <group ns="/stereo_camera" >
      <node pkg="stereo_image_proc" type="stereo_image_proc" name="stereo_image_proc"/>
   
<!-- Disparity to depth -->
    <node pkg="nodelet" type="nodelet" name="disparity2depth" args="standalone rtabmap_ros/disparity_to_depth"/>
  </group>

   <!-- 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_20Hz_left 100" /> 
  
  <!-- Navigation stuff (move_base) -->
  <include unless="$(arg simulation)" file="$(find turtlebot_bringup)/launch/3dsensor.launch"/>
  <include file="$(find turtlebot_navigation)/launch/includes/move_base.launch.xml"/>
  
  <!-- Mapping -->
  <group ns="rtabmap">

    <node name="rtabmap" pkg="rtabmap_ros" type="rtabmap" output="screen" args="$(arg args)">
      <param name="database_path"       type="string" value="$(arg database_path)"/>
      <param name="frame_id"            type="string" value="base_footprint"/>
      <param name="odom_frame_id"       type="string" value="odom"/>
      <param name="wait_for_transform_duration"  type="double"   value="$(arg wait_for_transform)"/>
      <param name="subscribe_depth"     type="bool"   value="true"/>
      <param name="subscribe_scan"      type="bool"   value="true"/>
    
      <!-- inputs -->
      <remap from="scan"            to="/scan"/>
      <remap from="rgb/image"       to="$(arg rgb_topic)"/>
      <remap from="depth/image"     to="$(arg depth_topic)"/>
      <remap from="rgb/camera_info" to="$(arg camera_info_topic)"/>
      
      <!-- output -->
      <remap from="grid_map" to="/map"/>
    
      <!-- RTAB-Map's parameters: do "rosrun rtabmap rtabmap (double-dash)params" to see the list of available parameters. -->
      <param name="RGBD/ProximityBySpace"        type="string" value="true"/>   <!-- Local loop closure detection (using estimated position) with locations in WM -->
      <param name="RGBD/OptimizeFromGraphEnd"    type="string" value="false"/>  <!-- Set to false to generate map correction between /map and /odom -->
      <param name="Kp/MaxDepth"                  type="string" value="4.0"/>
      <param name="Reg/Strategy"                 type="string" value="0"/>      <!-- Loop closure transformation: 0=Visual, 1=ICP, 2=Visual+ICP -->
      <param name="Icp/CorrespondenceRatio"      type="string" value="0.3"/>
      <param name="Vis/MinInliers"               type="string" value="15"/>      <!-- 3D visual words minimum inliers to accept loop closure -->
      <param name="Vis/InlierDistance"           type="string" value="0.1"/>    <!-- 3D visual words correspondence distance -->
      <param name="RGBD/AngularUpdate"           type="string" value="0.1"/>    <!-- Update map only if the robot is moving -->
      <param name="RGBD/LinearUpdate"            type="string" value="0.1"/>    <!-- Update map only if the robot is moving -->
      <param name="RGBD/ProximityPathMaxNeighbors" type="string" value="0"/> 
      <param name="Rtabmap/TimeThr"              type="string" value="700"/>
      <param name="Mem/RehearsalSimilarity"      type="string" value="0.30"/>
      <param name="Optimizer/Slam2D"             type="string" value="true"/>
      <param name="Reg/Force3DoF"                type="string" value="true"/>   
      
      <!-- localization mode -->
      <param     if="$(arg localization)" name="Mem/IncrementalMemory" type="string" value="false"/>
      <param unless="$(arg localization)" name="Mem/IncrementalMemory" type="string" value="true"/>
      <param name="Mem/InitWMWithAllNodes" type="string" value="$(arg localization)"/> 
    </node>
   
    <!-- Odometry : ONLY for testing without the actual robot! /odom TF should not be already published. -->
    <node if="$(arg rgbd_odometry)" pkg="rtabmap_ros" type="rgbd_odometry" name="rgbd_odometry" output="screen">
      <param name="frame_id"                    type="string" value="base_footprint"/>
      <param name="wait_for_transform_duration" type="double" value="$(arg wait_for_transform)"/>
      <param name="Reg/Force3DoF"               type="string" value="true"/>
      <param name="Vis/InlierDistance"          type="string" value="0.05"/>
      
      <remap from="rgb/image"       to="$(arg rgb_topic)"/>
      <remap from="depth/image"     to="$(arg depth_topic)"/>
      <remap from="rgb/camera_info" to="$(arg camera_info_topic)"/>
    </node>
    
    <!-- visualization with rtabmapviz -->
    <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_depth"             type="bool" value="true"/>
      <param name="subscribe_scan"              type="bool" value="true"/>
      <param name="frame_id"                    type="string" value="base_footprint"/>
      <param name="wait_for_transform_duration" type="double" value="$(arg wait_for_transform)"/>
    
      <remap from="rgb/image"       to="$(arg rgb_topic)"/>
      <remap from="depth/image"     to="$(arg depth_topic)"/>
      <remap from="rgb/camera_info" to="$(arg camera_info_topic)"/>
      <remap from="scan"            to="/scan"/>
    </node>
    
  </group>

<!-- ******* Visualization of the Turtlebot on Rviz ******* -->
  <node name="rviz" pkg="rviz" type="rviz" args="-d $(find turtlebot_rviz_launchers)/rviz/navigation.rviz"/>


</launch>

and for run this launch file in terminal typed:

roslaunch turtlebot_gazebo turtlebot_world.launch
roslaunch /home/zahra/Downloads/stereo_20Hz/demo_turtlebot_mapping.launch simulation:=true localization:=true

but when run this launch file this error consequently is created and the map isn't load:

[ WARN] (2018-02-01 15:45:11.140) SensorData.cpp:594::uncompressDataConst() Requested laser scan data, but the sensor data (-1) doesn't have laser scan.

can anyone help me! my Ubuntu is 14.04 LTS and Ros is indigo


Originally posted by zahra.kh on ROS Answers with karma: 21 on 2018-02-01

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You cannot create a map with real images, then go localization with this map in a simulated environment. Please do mapping session in the simulated environment. From this turtlebot with RTAB-Map tutorial, follow section 6 (Simulation (Gazebo)) to create a map with Gazebo, then use the following to relaunch in localization mode (like section 2 but with simulation argument):

$ roslaunch rtabmap_ros demo_turtlebot_mapping.launch localization:=true simulation:=true

As noted in Section 6, make sure to download the latest demo_turtlebot_maping.launch to have access to simulation argument. Also read the issues about the simulation example in the same section.

cheers


Originally posted by matlabbe with karma: 6409 on 2018-02-01

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by zahra.kh on 2018-02-03:
thanks matlabbe. for simulated enviroment when run (roslaunch rtabmap_ros demo_turtlebot_mapping.launch simulation:=true) map is not create and this command is appeared: [ INFO] [1517650101.550376320, 316.600000000]: No matching device found.... waiting for devices.

Comment by zahra.kh on 2018-02-03:
[ INFO] [1517650098.550035230, 313.600000000]: No matching device found.... waiting for devices. Reason: std::string openni2_wrapper::OpenNI2Driver::resolveDeviceURI(const string&) @ /tmp/binarydeb/ros-indigo-openni2-camera-0.3.0/src/openni2_driver.cpp @ 737 :

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.