It seems to me that a good place to start is to look at the occupancy grid map message from the nav_msgs package
http://docs.ros.org/api/nav_msgs/html/msg/OccupancyGrid.html
Also look at the laser scan message from sensor_msgs
http://docs.ros.org/api/sensor_msgs/html/msg/LaserScan.html
To visualize it you will probably want to use rviz with the map display type
http://wiki.ros.org/rviz/DisplayTypes/Map
Now assuming you have a stream of LaserScan messages you just need to figure out the math to map each ray to a grid cell. To do this you need to know the pose of the laser scanner. You will have to translate the ray direction from the laser scanners coordinate frame to the world coordinate frame. The tf package might help with that http://wiki.ros.org/tf
The hard part will be to handle noise and to properly merge together multiple laser scans over time to get a good probabilistic map.
Originally posted by gudjon with karma: 111 on 2017-03-12
This answer was ACCEPTED on the original site
Post score: 3