ros2 / cartographer_ros

Provides ROS integration for Cartographer.
Apache License 2.0
114 stars 58 forks source link

occupancy_grid_node can't subscribe large topic in real time #36

Open ccy89 opened 4 years ago

ccy89 commented 4 years ago

I use ros2-dashing and cartographer_ros-dashing to test google's demo_backpack_2d.launch. At the beginning, the map can update Immediately. After a while, the submap is large, the map can not update Immediately, the Occupancy grid Node still publish "/map" topic. But the /map topic's time stamp never changes. It means the subscriber don't work. Screenshot from 2019-09-23 16-45-31

I notice that when Occupancy grid Node use 100% CPU, this phenomenon will happen Screenshot from 2019-09-23 16-42-45

In ROS1, don't have this problem.

I test this in my computer, which has i7-6820HQ CPU. My launch file, configuration file and CMakeLists file is in https://github.com/ccy89/cartographer_ros.git

wjwwood commented 4 years ago

@ccy89 are you using rmw_fastrtps_cpp?

ccy89 commented 4 years ago

@wjwwood Yes, I use rmw_fastrtps_cpp as RMW implementation. I also test rmw_opensplice_cpp, the result is same.

wjwwood commented 4 years ago

@clalancette can you triage this issue by figuring out whether or not this is a general performance issue or an implementation issue with the occupancy_grid_node? Given that it is using so much CPU, is it possible it's spending too much time in the user code rather than the middleware?

wjwwood commented 4 years ago

Friendly ping @clalancette.

clalancette commented 4 years ago

So I took a brief look at this. I wasn't able to get the whole thing actually launching; it starts to launch, but then I just get:

[occupancy_grid_node-3] [WARN] [occupancy_grid_node]: submap_slices and last_frame_id is empty

forever.

Regardless, the occupancy_grid_node is the part of this that is the newest to the port. I suspect that @ccy89 is right in that it eventually takes up too much CPU time, and thus can't publish anymore. That is likely a problem specific to the occupancy_grid_node, but I don't know that for certain.

I will not have time to look into it in the near future, so the only things I can do are to:

  1. Ping @routiful as the author to see if any ideas come from there
  2. Look into it yourself. Any patches to fix it will be gladly reviewed.
ccy89 commented 4 years ago

@clalancette Did you play the ros bag file? I converted google's ros1 bag file into the ros2 bag : https://drive.google.com/open?id=1LIxd9o8QAm-FjViOUolyn2icqlJkwCqB