ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

How can I edit a map from cartographer?

asked 2022-02-27 04:44:37 -0500

jensanjo gravatar image

I used cartographer_ros (ROS noetic) to create a 2D SLAM map from a laser scan. The generated maps has some imperfections, for example it laser scanner does not detect a mirror. I edited the generated map.pgm to correct it.

But when I use it later on for localization with cartographer_node it shows the original map and not the edited map. What is the proper procedure to use an edited map?

Here is the launch file for navigation. The map.yaml points to the edited map.pgm

<launch> <arg name="robot_name" default="/"/> <arg name="rviz" default="true"/>

<arg if="$(eval arg('robot_name') == '/')"  name="frame_prefix" value="" />
<arg unless="$(eval arg('robot_name') == '/')" name="frame_prefix" value="$(arg robot_name)/" />

<group ns="$(arg robot_name)">
    <!-- Map server -->
    <arg name="map_file" default="$(find mini_pupper)/maps/map.yaml"/>
    <node pkg="map_server" name="map_server" type="map_server" args="$(arg map_file)" >
        <param name="frame_id" value="$(arg frame_prefix)map" />

    <!-- Localization -->
    <arg name="pbstream_file" default="$(find mini_pupper)/maps/map.pbstream"/>
    <node name="cartographer_node" pkg="cartographer_ros"
        type="cartographer_node" args="
        -configuration_directory $(find mini_pupper)/config/cartographer
        -configuration_basename nav.lua
        -load_state_filename $(arg pbstream_file)"

    <node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"
        type="cartographer_occupancy_grid_node" args="-resolution 0.05" />

    <!-- Calls navigation stack -->
    <include file="$(find mini_pupper)/launch/include/move_base.launch">
        <arg name="frame_prefix" value="$(arg frame_prefix)"/>
        <arg name="robot_name"   value="$(arg robot_name)"/>

    <node if="$(arg rviz)" name="rviz" pkg="rviz" type="rviz"
        args="-d $(find champ_navigation)/rviz/navigate.rviz -f $(arg frame_prefix)map"


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-11-27 08:27:35 -0500

To use cartographer in pure localization mode, you will need the original .pbtream map. I understand the fact that having a correted or almost perfect map in .pgm is easier, e.g. if you have a floor plan.

But to reuse cartographer with this map you will need to converte it again to .pbtream. To do that you can use the Ogm2Pgbm package.

Additionally, if you wanna run the tool in a separate docker container you can follow the instuctions in the readme.

Have fun, and enjoy the power of graph-based localization! :D

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2022-02-27 04:39:03 -0500

Seen: 754 times

Last updated: Feb 27 '22