Registering pointclouds in ROS with PCL for Robot_Lab_(Spring_2012)
Paths followed, lessons learned, code shared.
Find some data
The data I used is dataset 14 at http://kos.informatik.uni-osnabrueck.de/3Dscans/
My python script, publish_from_file.py, can be easily adjusted to read any similar format, wherein each line gives the coordinates for a point. PLY is another option; PLY pointclouds can be loaded and viewed in Meshlab.
I didn't write any code to read pcl files, but this is the format that the pointcloud library reads and writes, so if you found some pcl data and like c++ that would also work.
Ideally, it would be best to take your own data, then you know everything about it. It turns out the better you know the data (how far did the robot move between images? what unit does your scanner use for measurements -- meters? pixels?) the better off you will be in fine-tuning the registration algorithms.
Learn about registration
The pcl site has a lot of information. I would recommend reading the introductory material on a number of pcl modules, including registration, keypoint estimation, features, and correspondence. There are a number of ways to do this and it would be helpful to get a sense of some of them before starting on one.
Try my scripts
Download a tgz of my scripts.
Uses the pose data from the data set to transform each point cloud into a global frame of reference. Writes PLY files.
# first set the global variables for file locations $ ./pose_registration.py
Reads a pointcloud from a PLY or .3d file, in which each line gives the coordinates a point. Publishes each pointcloud as a message to the a ROS topic.
# first set the global variables for file locations $ rosrun pointclouds_ah public_from_file.py
Reads a pointcloud off the ROS bus (the topic name is set to the same one public_from_file.py writes to). Runs Iterative Closest Point on each pair of pointclouds.
$ rosmake register_pointclouds $ rosrun register_pointclouds register
The results never came out perfectly, but they do nicely show the effects of different types of translation on the data / stages in the process.
Running the original data set through pointcloud registration only:
Pointclouds registered by translating them according to odometry data:
Running the data set through odometry translation and then pointcloud registration:
Do something new
Things I would do if I were to keep working on this project.
- Working odometry into the registration process appears to be key. It would be nice to figure out the best way to do it.
- I don't know whether / how it's possible to send odometry and pointclouds over the ROS bus and correlate them on the other side. Do they need to be combined into a single message? Can the callbacks on the two topics be tied together somehow? It would be easier to start by skipping the ROS bus altogether and just reading in the pointcloud and omdometry data from file.
- A new version of pcl should be coming out any day now as I finish this quarter. A new registration algorithm will take odometry data with each pointcloud; it's called Normal Distributions Transform. That would be worth trying out.
- Further research on Euler angles and rotations in 3d space could be useful. There may be mathematical errors in the script I wrote to do this.
- Cleaning noise from the data could be helpful. I believe the circular artifacts in my images come from noise in the pointclouds. Without them, registration could be more accurate.
- Experiment more with max correspondence and epsilon parameters to registration algorithms.