octomap Reference
SLAM拾萃(1):octomap
基于高博的修改
octomap的网页见:https://octomap.github.io
它的github源码在:https://github.com/OctoMap/octomap
它还有ROS下的安装方式:http://wiki.ros.org/octomap
编译octovis提示链接出错
1 | CMakeFiles/octovis.dir/src/ViewerGui.cpp.o: In function `octomap::OcTreeBaseImpl<octomap::ColorOcTreeNode, octomap::AbstractOccupancyOcTree>::writeData(std::ostream&) const': |
编译octovis提示链接出错的解决措施1
2cd octomap
git checkout v1.6.9 //校验为/opt/ros/indigo/share/octpmap/octomap-config-version文件中的自己的版本
重新编译即可
正确安装octomap
1 | git clone https://github.com/OctoMap/octomap |
点云转换为不带颜色的octomap
将点云中的点一个一个地插入到OcTree中1
2
3
4
5
6
7
8
9
10
11
12
13octomap::OcTree tree( 0.05 );
for (auto p:cloud.points)
{
// 将点云里的点插入到octomap中
tree.updateNode( octomap::point3d(p.x, p.y, p.z), true );
}
// 更新octomap
tree.updateInnerOccupancy();
// 存储octomap
tree.writeBinary( output_file );
cout<<"done."<<endl;
点云转换成带颜色的octomap
将点云经过一个变换后,插入到ColorOcTree中1
2
3
4
5
6
7
8
9
10
11
12
13
14
15octomap::ColorOcTree tree( 0.05 ); //全局map
octomap::Pointcloud cloud_octo;
for (auto p:temp->points)
cloud_octo.push_back( p.x, p.y, p.z );
tree.insertPointCloud( cloud_octo,
octomap::point3d( pose(0,3), pose(1,3), pose(2,3) ) );
for (auto p:temp->points)
tree.integrateNodeColor( p.x, p.y, p.z, p.r, p.g, p.b );
tree.updateInnerOccupancy();
tree.write( "./data/map.ot" );
//带颜色的octomap,调用integrateNodeColor来混合颜色。后缀名改成了.ot文件。
cout<<"done."<<endl;