I'm currently working on a similar project. I use the laser_assembler package, which is a part of the laser_pipeline, to make point clouds out of laser scans. You should be able to install it using sudo apt-get install ros-indigo-laser-pipeline
, assuming indigo is your distro. Octomap_server requires a PointCloud2 to make the map, so you'll have to adapt the periodic_snapshotter in the laser_assembler github page to use PointCloud2 instead of PointCloud.
[EDIT1]
Whatever laser driver package you are doing publishes the laser scans as a sensor_msgs/LaserScan message on the /scan topic. Laser_assembler subscribes to /scan, reads the LaserScan messages, and converts the range data into sensor_msgs/PointCloud messages (an x, y, z value) in the fixed frame that you specify when you start the node. The point cloud is kept waits for a service call to call them. The periodic_snapshotter example in the github repo I linked you to calls the assemble_scans service, which collects all of the points assembled since the last service call and publishes them on the assembled_cloud topic. As octomap_server requires sensor_msgs/PointCloud2 messages, you will need to adapt periodic_snapshotter to call the assemble_scans2 service and publish PointCloud2 messages. I would also suggest increasing the rate as periodic_snapshotter currently calls the service every 5 seconds. Once you are publishing the point clouds, you run octomap_server. It subscribes to the cloud_in topic (though you can remap that) and builds the octomap.
Another thing you need to look at is some way to determine the height of the sensor, as there is no z value to a laser scan. As well, I would suggest using an IMU and the hector_imu_attitude_to_tf package, which allows the system to know the true orientation of your robot in order to get the most accurate map.
[EDIT2]
You use a launch file to run multiple nodes simultaneously. Launch files run the ROS master, allows you to set parameters, lets you remap topics, and opens multiple nodes at once. Some nodes you may have to write yourself, such as the one adding height to the transform tree, but for the most part you just have to worry about setting parameters and maybe remapping topics.
Originally posted by Icehawk101 with karma: 955 on 2016-06-15
This answer was ACCEPTED on the original site
Post score: 2
Original comments
Comment by ateator on 2016-06-15:
Thank you. I have installed the laser_assembler package with the apt-get command you give. I have cloned the link you gave me into my catkin workspace and will look into it. I still don't understand how to link all of these packages together (laserscan to poincloud2 to octomap)
Comment by ateator on 2016-06-16:
Thank you for your detailed answer. I am starting to understand how the topics, etc. work in this example, but I still don't understand what to do in order to use the code given in these packages. Is it expected that I am writing my own package from scratch and call these codes?
Comment by ateator on 2016-06-16:
heh, I guess i was being mostly ignorant. Now I have a terminal with roscore, a terminal with the Neato drier, and I can rosrun laser_assembler test_assembler. I get an error, but that's kind of expected since I havent modified the code. I'll try to figure it out and let you know :)
Comment by ateator on 2016-06-16:
It's working! I can see the published point clouds in rviz! Thank you for your help!! I will not be rising the planar laser up and down on a Z axis, but instead plan to rotate it on an axis to get an essentially non-moving spherical set of points for a point cloud. Any tips?
Comment by Icehawk101 on 2016-06-16:
That I have not tried before, but you'll definitely need an IMU for that. Please click on the checkmark next to my answer to select it as correct :P
Comment by ateator on 2016-06-16:
Any suggestions for cost-effective IMU's with lots of technical support in reference to ROS?
Comment by Icehawk101 on 2016-06-16:
I'm using an InvenSense MPU6050. It's around $12 CAD, but you'll need an Arduino or similar to connect it. I know there is a working ROS package for the Sparkfun SEN-10724, but again it is running through an Arduino.
Comment by ateator on 2016-06-16:
Heh, I've got the Intel Edison.. what a freakin pain to get working on Ubuntu 16.04. Again, your help has been invaluable. Thank you. I'll look into IMU's and hector_imu_attitude_tf
Comment by Icehawk101 on 2016-06-16:
No problem, happy to help
Comment by Shantnu on 2016-06-17:
Hi IceHawk,
I have MPU 9150 (which is similar to MPU6050) and Arduino. Could you suggest me the right way to publish tf messages using this combo?
Comment by Icehawk101 on 2016-06-17:
Start a new thread for that question, don't add it as a comment here