rosslam

tos tf setting for laser_scan_matcher with vrep/scan and slam


I am trying this one on my environment.

https://sudonull.com/post/21487-Mapping-and-localization-of-a-mobile-robot-in-ROS-without-odometry-using-laser_scan_matcher

I got a simulation environment:

with topic: vrep/scan

with TF: base_link -> laser_link

then I use laser_scan_matcher

I got TF: map -> odom.

I need the TF from odom -> laser_link for gmapping SLAM.

but I did not figure out how to create such link.

my launch file is as below:

<launch>

  <node pkg="laser_scan_matcher" type="laser_scan_matcher_node" 
    name="laser_scan_matcher_node" output="screen">
    <param name="scan" value = "/vrep/scan"/>
    <param name="fixed_frame" value = "odom"/>
    <param name="use_alpha_beta" value="true"/>
    <param name="max_iterations" value="10"/>
  </node>

  <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" output="screen">
    <param name="scan" value = "/vrep/scan"/>
    <param name="map_udpate_interval" value="1.0"/>
    <param name="delta" value="0.02"/>
  </node>

</launch>

I read this, but I still could not figure it out. https://answers.ros.org/question/10909/combining-laser_scan_matcher-with-gmapping/

or my question is actually how to connect odom to baselink with correct launch file? enter image description here Many thanks for hint.

roslaunch

    Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://ros-vm:38189/

SUMMARY
========

PARAMETERS
 * /laser_scan_matcher_node/fixed_frame: odom
 * /laser_scan_matcher_node/max_iterations: 10
 * /laser_scan_matcher_node/publish_odom: True
 * /laser_scan_matcher_node/scan: /vrep/scan
 * /laser_scan_matcher_node/use_alpha_beta: True
 * /laser_scan_matcher_node/use_odom: True
 * /rosdistro: melodic
 * /rosversion: 1.14.5
 * /slam_gmapping/delta: 0.02
 * /slam_gmapping/map_udpate_interval: 1.0
 * /slam_gmapping/scan: /vrep/scan

NODES
  /
    laser_scan_matcher_node (laser_scan_matcher/laser_scan_matcher_node)
    slam_gmapping (gmapping/slam_gmapping)

ROS_MASTER_URI=http://localhost:11311

process[laser_scan_matcher_node-1]: started with pid [7540]
process[slam_gmapping-2]: started with pid [7545]
[ INFO] [1589974736.966492078]: Starting LaserScanMatcher

log:

 rosnode info laser_scan_matcher_node
--------------------------------------------------------------------------------
Node [/laser_scan_matcher_node]
Publications:
 * /pose2D [geometry_msgs/Pose2D]
 * /rosout [rosgraph_msgs/Log]
 * /tf [tf2_msgs/TFMessage]

Subscriptions:
 * /clock [rosgraph_msgs/Clock]
 * /imu/data [unknown type]
 * /odom [unknown type]
 * /scan [unknown type]
 * /tf [tf2_msgs/TFMessage]
 * /tf_static [unknown type]

Services:
 * /laser_scan_matcher_node/get_loggers
 * /laser_scan_matcher_node/set_logger_level


contacting node http://ros-vm:34349/ ...
Pid: 7062
Connections:
 * topic: /rosout
    * to: /rosout
    * direction: outbound (35035 - 10.0.2.15:52152) [17]
    * transport: TCPROS
 * topic: /tf
    * to: /laser_scan_matcher_node
    * direction: outbound
    * transport: INTRAPROCESS
 * topic: /tf
    * to: /rqt_gui_py_node_6989
    * direction: outbound (35035 - 10.0.2.15:52134) [14]
    * transport: TCPROS
 * topic: /tf
    * to: /slam_gmapping
    * direction: outbound (35035 - 10.0.2.15:52164) [11]
    * transport: TCPROS
 * topic: /clock
    * to: /vrep_ros_interface (http://ros-vm:35741/)
    * direction: inbound (56132 - ros-vm:60019) [12]
    * transport: TCPROS
 * topic: /tf
    * to: /laser_scan_matcher_node (http://ros-vm:34349/)
    * direction: inbound
    * transport: INTRAPROCESS
 * topic: /tf
    * to: /vrep_ros_interface (http://ros-vm:35741/)
    * direction: inbound (56134 - ros-vm:60019) [18]
    * transport: TCPROS
 * topic: /tf
    * to: /slam_gmapping (http://ros-vm:38313/)
    * direction: inbound (60954 - ros-vm:54021) [10]
    * transport: TCPROS


 rostopic list -v

Published topics:
 * /map_metadata [nav_msgs/MapMetaData] 1 publisher
 * /vrep/image [sensor_msgs/Image] 1 publisher
 * /vrep/scan [sensor_msgs/LaserScan] 1 publisher
 * /pose2D [geometry_msgs/Pose2D] 1 publisher
 * /rosout [rosgraph_msgs/Log] 4 publishers
 * /tf [tf2_msgs/TFMessage] 3 publishers
 * /clock [rosgraph_msgs/Clock] 1 publisher
 * /rosout_agg [rosgraph_msgs/Log] 1 publisher
 * /map [nav_msgs/OccupancyGrid] 1 publisher
 * /slam_gmapping/entropy [std_msgs/Float64] 1 publisher




rosnode list
/laser_scan_matcher_node
/rosout
/rqt_gui_py_node_6989
/slam_gmapping
/vrep_ros_interface

Solution

  • From the rosnode info laser_scan_matcher_node can be seen, that the node is subcribed to the topic scan.

    In the output of rostopic list -v there is no publisher for that topic. That command also lists subscribers, which you did not include in the question. There is a publisher for the topic /vrep/scan which you have tried to set in your launch files. Theoretically it is possible to use a param to provide an input/output topic, but that would have to have been implemented in the node. Generally that is not necessary, so most nodes probably do not do this.

    You would need to use the remap tag in the launch files to remap the topics instead of the param tag. Roslaunch XML wiki.

    Your launch file would be something like this, scan param replaced with remap:

    <launch>
    
      <node pkg="laser_scan_matcher" type="laser_scan_matcher_node" 
        name="laser_scan_matcher_node" output="screen">
        <remap from="scan" to="/vrep/scan"/>
        <param name="fixed_frame" value = "odom"/>
        <param name="use_alpha_beta" value="true"/>
        <param name="max_iterations" value="10"/>
      </node>
    
      <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" output="screen">
        <remap from="scan" to="/vrep/scan"/>
        <param name="map_udpate_interval" value="1.0"/>
        <param name="delta" value="0.02"/>
      </node>
    
    </launch>
    

    Not sure this will solve all of your issues.

    Also the leading / in to="/vrep/scan" is quite significant when you are remapping topics, it will take some getting used to, I suggest reading this page to get some understanding on what is going on there. The missing leading / in from="scan" is equally significant.

    After making this change check that both the slam_gmapping and laser_scan_matcher_node nodes are subscribed to /vrep/scan with rosnode info ...