ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

How do I convert ROS sensor_msgs/MultiEchoLaserScan to sensor_msgs/LaserScan?

asked 2023-03-20 09:21:38 -0500

TheLastMiniatureTitan gravatar image

I want to run gmapping algorithm on a cartographer bag-file that contains only 3 topics:

horizontal_laser_2d [sensor_msgs/MultiEchoLaserScan]
vertical_laser_2d [sensor_msgs/MultiEchoLaserScan]
imu [sensor_msgs/Imu]

I have created my custom launch file which remaps the /horizontal_laser_2d topic to /scan which gmapping expects but it gives an error saying;

[ERROR] [1679315751.953528824]: Client [/gmapping] wants topic /horizontal_laser_2d to have datatype/md5sum [sensor_msgs/LaserScan/90c7ef2dc6895d81024acba2ac42f369], but our version has [sensor_msgs/MultiEchoLaserScan/6fefb0c6da89d7c8abe4b339f5c2f8fb]. Dropping connection.

How do I convert the /horizontal_laser_2d topic type from sensor_msgs/MultiEchoLaserScan to sensor_msgs/LaserScan so that I can run gmapping on the bag-file?

I can't attach files to this question, so I will type out my launch and lua configuration below.


  <!-- Arguments -->
  <arg name="set_base_frame" default="base_footprint"/>
  <!-- <arg name="set_odom_frame" default="odom"/> -->
  <arg name="remap_topic" default="horizontal_laser_2d"/>
  <arg name="set_map_frame"  default="map"/>
  <!-- <arg name="bag_filename"> -->
  <arg name="configuration_basename" default="$(find turtlebot3_slam)/config/my_gmapping_config.lua"/>

  <!-- <include file="$(find turtlebot3_slam)/config/my_gmapping_config.lua" /> this line of code for some reason gives an XML error and makes the laucnh file unable to run, so I commented it out-->

  <!-- Gmapping -->
  <node pkg="gmapping" type="slam_gmapping" name="gmapping" output="screen">
    <remap from="scan" to="$(arg remap_topic)"/>
    <!-- <param name="odom_frame" value="$(arg set_odom_frame)"/> -->

    <param name="base_frame" value="$(arg set_base_frame)"/>
    <param name="map_frame"  value="$(arg set_map_frame)"/>
    <param name="xmin" value="-5.0"/>
    <param name="ymin" value="-5.0"/>
    <param name="xmax" value="5.0"/>
    <param name="ymax" value="5.0"/>
    <param name="maxUrange" value="30.0"/>
    <param name="delta" value="0.05"/>  

  <node pkg="rviz" type="rviz" name="rviz" args="-d $(find hector_slam_launch)/rviz_cfg/mapping_demo.rviz"/>
  <node name="playbag" pkg="rosbag" type="play" args="/home/admin/CS/Thesis/bagfiles/$(arg bag_file)" />


include "map_builder.lua"
include "trajectory_builder.lua"

options = {
  map_builder = MAP_BUILDER,
  trajectory_builder = TRAJECTORY_BUILDER,
  map_frame = "map",
  tracking_frame = "base_link",
  published_frame = "base_link",
  odom_frame = "odom_combined",
  provide_odom_frame = true,
  publish_frame_projected_to_2d = false,
  use_pose_extrapolator = true,
  use_odometry = true,
  use_nav_sat = false,
  use_landmarks = false,
  num_laser_scans = 1,
  num_multi_echo_laser_scans = 0,
  num_subdivisions_per_laser_scan = 10,
  num_point_clouds = 0,
  lookup_transform_timeout_sec = 0.2,
  submap_publish_period_sec = 0.3,
  pose_publish_period_sec = 5e-3,
  trajectory_publish_period_sec = 30e-3,
  rangefinder_sampling_ratio = 1.,
  odometry_sampling_ratio = 1.,
  fixed_frame_pose_sampling_ratio = 1.,
  imu_sampling_ratio = 1.,
  landmarks_sampling_ratio = 1.,

MAP_BUILDER.use_trajectory_builder_2d = true
TRAJECTORY_BUILDER_2D.num_accumulated_range_data = 10

return options
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2023-03-20 09:47:37 -0500

gvdhoorn gravatar image

updated 2023-03-20 09:52:53 -0500

It doesn't appear to have much documentation (the wiki page for it is empty fi), but according to the terse description, laser_proc/laser_proc can do this.

From the nodelet description:

Nodelet to convert sensor_msgs/MultiEchoLaserScans to sensor_msgs/LaserScans.

the package also comes with a regular node that does the same.

And it's been released into Noetic, so you should be able to just apt install ros-noetic-laser-proc and then use it.

I'm pretty sure rosbag isn't capable of hosting nodelets (if performance is a concern, you could consider using osrf/nodelet_rosbag), so you'll probably want to use the laser_proc node. It subscribes to the echoes topic for the MultiEchoLaserScans messages and publishes the conversions on multiple topics, so you'll have to decide which one to use -- as a multi-echo-laserscan contains, well, basically multiple scans ..

edit flag offensive delete link more


Thank you for your reply. (Apologies for the late response) I have just installed laser_proc with the command sudo apt install ros-noetic-laser-proc ... Unfortunately, I am still not very experienced with ROS and I have not been able to use the installed package. It does not show up as a node when I type rosrun laser_<tab key>

Could you please point me to a link on how to use it? Thanks

TheLastMiniatureTitan gravatar image TheLastMiniatureTitan  ( 2023-04-04 07:40:44 -0500 )edit

Could you please point me to a link on how to use it?

Not really I'm afraid.

As I already wrote:

It doesn't appear to have much documentation (the wiki page for it is empty fi) [..]

gvdhoorn gravatar image gvdhoorn  ( 2023-04-04 08:39:10 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2023-03-20 09:21:38 -0500

Seen: 41 times

Last updated: Mar 20