koide3 / hdl_localization

Real-time 3D localization using a (velodyne) 3D LIDAR
BSD 2-Clause "Simplified" License
775 stars 309 forks source link

Make map server publish point cloud map more reliably at startup #52

Closed robustify closed 3 years ago

robustify commented 3 years ago

I noticed that the localization nodelet frequently does not receive the point cloud map from the global map server when launching hdl_localization.launch. I did some testing and realized that both initializing the ros::Publisher and publishing the map message in the onInit() method causes the publisher to not have enough time to start up and the message is lost.

I tried fixing this with a normal delay with sleep(), and with ros::Duration().sleep(), but the way the threading works in the nodelet prevented that from being successful. I settled on a oneshot ros::WallTimer to provide the delay, which is what you see in this PR.

The localization node receives the global map message every time now.

koide3 commented 3 years ago

Looks good. Just one minor thing. Can you rename timer_ to globalmap_pub_timer for naming consistency?

robustify commented 3 years ago

Done!