[C++]octomap安装后测试

测试环境:

vs2019

octomap==1.9.6

release x64

代码:

#include <octomap/octomap.h>
#include <octomap/OcTree.h>

using namespace std;
using namespace octomap;
void print_query_info(point3d query, OcTreeNode* node) {
    if (node != NULL) {
        cout << "occupancy probability at " << query << ":\t " << node->getOccupancy() << endl;
    }
    else
        cout << "occupancy probability at " << query << ":\t is unknown" << endl;
}
int main(int argc, char** argv) {

    cout << endl;
    cout << "generating example map" << endl;
    OcTree tree(0.1);  // create empty tree with resolution 0.1
    // insert some measurements of occupied cells
    for (int x = -20; x < 20; x++) {
        for (int y = -20; y < 20; y++) {
            for (int z = -20; z < 20; z++) {
                point3d endpoint((float)x * 0.05f, (float)y * 0.05f, (float)z * 0.05f);
                tree.updateNode(endpoint, true); // integrate 'occupied' measurement
            }
        }
    }
    // insert some measurements of free cells
    for (int x = -30; x < 30; x++) {
        for (int y = -30; y < 30; y++) {
            for (int z = -30; z < 30; z++) {
                point3d endpoint((float)x * 0.02f - 1.0f, (float)y * 0.02f - 1.0f, (float)z * 0.02f - 1.0f);
                tree.updateNode(endpoint, false);  // integrate 'free' measurement
            }
        }
    }
    cout << endl;
    cout << "performing some queries:" << endl;
    point3d query(0., 0., 0.);
    OcTreeNode* result = tree.search(query);
    print_query_info(query, result);
    query = point3d(-1., -1., -1.);
    result = tree.search(query);
    print_query_info(query, result);
    query = point3d(1., 1., 1.);
    result = tree.search(query);
    print_query_info(query, result);
    cout << endl;
    tree.writeBinary("simple_tree.bt");
    cout << "wrote example file simple_tree.bt" << endl << endl;
    cout << "now you can use octovis to visualize: octovis simple_tree.bt" << endl;
    cout << "Hint: hit 'F'-key in viewer to see the freespace" << endl << endl;
}
 

结果:

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FL1623863129

你的打赏是我写文章最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值