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

Using cartographer for creating map, how??

asked 2017-01-16 08:42:56 -0600

SCrusher gravatar image

Hello, I just installed cartographer package and I am trying to use it in order to create a map and visualise it in rviz. I am using vrep, where I have a robot with laser scan publishing data to laser scan topic and odometry data to odom topic. I am trying to make the cartographer_node to subscribe to these topics and produce the map, just like I did with gmapping before.

However I am lost in the launch files and in how I pass these parameters to cartographer. I am in beginner level. I have read the ros tutorials but still it doesn't make sense. Could anyone provide me with an example of how to do this?

Thanks in advance.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2017-01-31 16:37:57 -0600

farhatm gravatar image

Hey, you need a IMU topic that publich /imu msg. I d'ont know, if you can use it only with /scan and /odom topic you have to change the configuration in your backpack_2d.lua.

use_laser_scan = true, use_multi_echo_laser_scan = false,

read this: https://google-cartographer-ros.readt...

edit flag offensive delete link more
0

answered 2017-02-01 21:20:15 -0600

tb12 gravatar image

I also use a laser scanner but I don't have any odometry data (I assume you mean from your wheels?) and it works fine. Here is my configuration file, which is almost identical to the given backpack_2d.lua file from the demo:

include "map_builder.lua"

options = {
  map_builder = MAP_BUILDER,
  map_frame = "map",
  tracking_frame = "base_link",
  published_frame = "base_link",
  odom_frame = "base_link",
  provide_odom_frame = false,
  use_odometry = false,
  use_laser_scan = true,
  use_multi_echo_laser_scan = false,
  num_point_clouds = 0,
  lookup_transform_timeout_sec = 0.2,
  submap_publish_period_sec = 0.3,
  pose_publish_period_sec = 5e-3,
}

MAP_BUILDER.use_trajectory_builder_2d = true
TRAJECTORY_BUILDER_2D.use_imu_data = false

return options

The configuration file can be called from a launch file as so:

<launch>
  <param name="robot_description"
    textfile="$(find cartographer_ros)/urdf/backpack_2d.urdf" />

  <node name="robot_state_publisher" pkg="robot_state_publisher"
    type="robot_state_publisher" />

  <node name="cartographer_node" pkg="cartographer_ros"
      type="cartographer_node" args="
          -configuration_directory $(find cartographer_ros)/configuration_files
          -configuration_basename backpack_2d.lua"
      output="screen">
     <!--<remap from="echoes" to="scan" />-->
  </node>

  <node pkg="tf" type="static_transform_publisher" name="world_to_map_broadcaster" args="0 0 0 0 0 0 world map 50" />
  <node pkg="tf" type="static_transform_publisher" name="base_to_laser_broadcaster" args="0 0 0 0 0 0 base_link laser 50" />

</launch>

Be sure to configure the simtime somewhere too

edit flag offensive delete link more

Comments

did you get any errors when you launch it? can you run: rosrun rqt_graph rqt_graph and rosrun rqt_tf_tree rqt_tf_tree after you launch the cartographer node, and post the result.

farhatm gravatar image farhatm  ( 2017-02-03 14:59:30 -0600 )edit

i cant post any pictures yet, but the tf tree is:

world -> map -> base_link -> laser, and base_link also points to other links which are being ignored based on my configurations.

tb12 gravatar image tb12  ( 2017-02-06 10:54:46 -0600 )edit

in the rqt graph you have cartographer_node subscribed to tf, tf_static, and scan, and publishing the scan matcher, submap list, and tf.

tf gets your robot state publisher as well as the static transforms. and the robot state publisher is also publishing to tf_static.

tb12 gravatar image tb12  ( 2017-02-06 10:59:07 -0600 )edit

and of course your urg_node publishes to scan

tb12 gravatar image tb12  ( 2017-02-06 10:59:20 -0600 )edit

what errors are you getting when you launch cartographer mapping?

tb12 gravatar image tb12  ( 2017-02-06 11:00:27 -0600 )edit

Hi, where does this come from? "TRAJECTORY_BUILDER_2D.use_imu_data = false"

Bill5785 gravatar image Bill5785  ( 2017-02-25 16:43:24 -0600 )edit

Did you check the source code? I couldn't find where it is referred.

Bill5785 gravatar image Bill5785  ( 2017-02-25 16:47:10 -0600 )edit

trajectory_builder_2d is a configuration file that is referenced by default from the tutorial launch file

tb12 gravatar image tb12  ( 2017-02-25 18:13:03 -0600 )edit

Hi Any idea to generate map with a rosbag which was generated using a real robot ?

Vignesh_93 gravatar image Vignesh_93  ( 2020-12-27 16:06:17 -0600 )edit

You need to run your SLAM node and rosbag together. When you run a rosbag the data will be published to ROS similar to if the data were being published from a sensor. When you run your SLAM node, your node will be subscribed to certain topics specified usually in the launch file.

tb12 gravatar image tb12  ( 2020-12-28 08:51:12 -0600 )edit

@tb12 Thanks for the insight. As I understand the overall concept and from your suggestion as well. I created a launch file and a config file for running the cartographer node and the rosbag. I am able to see the sensor messages in the rviz but the map is not getting constructed. Also I read somewhere that the cartographer node can understand only the tf2 nomenclature, so I did convert a rosbag which has tf type (topics with '/' in the string name) So I converted using a python API for the same.

Vignesh_93 gravatar image Vignesh_93  ( 2020-12-28 09:08:43 -0600 )edit

what i would recommend is to make sure your cartographer node is subscribed to the same topics that are being published. run rosnode info *cartographer node* to see what topics it is subscribed to and rosnode info *bagfile node* to see what topics it is publishing. if you need the name of your node you should see it in your system output but you can search it using rosnode list |grep cartographer and rosnode list |grep bag

tb12 gravatar image tb12  ( 2020-12-28 09:29:21 -0600 )edit

Thanks again for the piece of information. I get the following :

rosnode info cartographer_node

Node [/cartographer_node] Publications: * /constraint_list [visualization_msgs/MarkerArray] * /landmark_poses_list [visualization_msgs/MarkerArray] * /rosout [rosgraph_msgs/Log] * /scan_matched_points2 [sensor_msgs/PointCloud2] * /submap_list [cartographer_ros_msgs/SubmapList] * /tf [tf2_msgs/TFMessage] * /trajectory_node_list [visualization_msgs/MarkerArray]

Subscriptions: * /clock [rosgraph_msgs/Clock] * /imu [sensor_msgs/Imu] * /odom [nav_msgs/Odometry] * /scan [sensor_msgs/LaserScan] * /tf [tf2_msgs/TFMessage] * /tf_static [unknown type]

Services: * /cartographer_node/get_loggers * /cartographer_node/set_logger_level * /finish_trajectory * /get_trajectory_states * /read_metrics * /start_trajectory * /submap_query * /trajectory_query * /write_state

Vignesh_93 gravatar image Vignesh_93  ( 2020-12-28 11:00:16 -0600 )edit

ok, and what about the rosbag node?

tb12 gravatar image tb12  ( 2020-12-28 12:12:36 -0600 )edit

Node [/playbag] Publications: * /clock [rosgraph_msgs/Clock] * /imu [sensor_msgs/Imu] * /odom [nav_msgs/Odometry] * /rosout [rosgraph_msgs/Log] * /scan [sensor_msgs/LaserScan] * /tf [tf2_msgs/TFMessage]

Subscriptions: * /clock [rosgraph_msgs/Clock]

Services: * /playbag/get_loggers * /playbag/pause_playback * /playbag/set_logger_level

Vignesh_93 gravatar image Vignesh_93  ( 2020-12-28 12:46:03 -0600 )edit

All of your topics look like they match. While running your node and the bagfile, do you get any output to "/scan_matched_points2"?

tb12 gravatar image tb12  ( 2020-12-28 14:12:08 -0600 )edit

It looks like you need to run the Cartographer grid node in order to save the map. https://google-cartographer-ros.readt... Also, there is a way to run cartographer SLAM in an offline mode where you give it the bagfile directly.

tb12 gravatar image tb12  ( 2020-12-28 14:16:12 -0600 )edit

rostopic list /clicked_point /clock /constraint_list /imu /initialpose /landmark_poses_list /map /move_base_simple/goal /odom /rosout /rosout_agg /scan /scan_matched_points2 /submap_list /tf /tf_static /trajectory_node_list Yes I get that topic /scan_matched_poins2

Vignesh_93 gravatar image Vignesh_93  ( 2020-12-28 15:49:13 -0600 )edit

Question Tools

5 followers

Stats

Asked: 2017-01-16 08:42:56 -0600

Seen: 9,469 times

Last updated: Feb 01 '17