记录一下安装Octomap踩过的坑

最大的坑,就是不能编译octovis,octovis需要 For the viewer octovis: Qt4, OpenGL, QGLViewer (optional)

https://github.com/OctoMap/octomap/tree/devel/octomap

我的ubuntu22.04,装不上这三个库。

E: Unable to locate package libqt4-dev
E: Unable to locate package libqt4-opengl-dev
E: Unable to locate package libqglviewer-dev-qt4

octovis应该就是个可视化的东西,我估计是不影响Octomap的使用,故且就先不用Octovis了。

只安装一个doxygen就好了。

创建工作空间文件夹,在里面再创建include,src,ThirdParty三个文件夹,build.sh 和 CMakeListx.txt文件。

进入ThirdParty文件夹

cd ThirdParty
git clone https://github.com/OctoMap/octomap.git

把Octomap下载进来。修改Octomap的CMakeLists.txt,把与Octovis相关的都删掉,不要编译Octovis。

用vscode打开工作空间,build.sh 和CMakeLists.txt分别这样写

cd /home/user_name/test_octomap/ThirdParty/octomap
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make

cd /home/user_name/test_octomap
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug
make
cmake_minimum_required(VERSION 2.6)
 
project(test_octomap)

find_package(octomap REQUIRED)
include_directories(${OCTOMAP_INCLUDE_DIRS})
link_libraries(${OCTOMAP_LIBRARIES})

add_executable(main ./src/main.cpp)

再创建task.json    launch.json    c_cpp_properties.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "test_octomap",
            "type": "shell",
            "command": "./build.sh",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "/home/user_name/test_octomap/build/main",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}
{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/home/user_name/test_octomap/ThirdParty/octomap/octomap/include"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c17",
            "cppStandard": "gnu++17",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

写一个main.cpp测试

#include <iostream>
#include <vector>
#include <string>
#include <octomap/octomap.h>

using namespace std;

int main()
{
    vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};

    octomap::OcTree tree(0.05);
    
    for (const string& word : msg)
    {
        cout << word << " ";
    }
    cout << endl;
}

如果我们足够幸运的话,Octomap就可以用了。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值