源碼位置
https://github.com/OctoMap/octomap/blob/devel/octovis/README.md
commit 74c48ae on Apr 26, 2020.
本機系統Ubuntu 18.04,qt5,cmake 3.14.6。
編譯
libQGLViewer for octovis
直接cmake configure octomap會報出無法編譯libQGLViewer的錯誤,忽略該錯誤會導致octovis不能編譯,嘗試手工編譯libQGLViewer。具體報錯信息如下
-- QGLViewer includes found in /home/yaoyu/Libraries/octomap/octovis/src/extern/QGLViewer
-- QGLViewer library not found.
-- Trying to build libQGLViewer from source in /home/yaoyu/Libraries/octomap/octovis/src/extern/QGLViewer
-- generating Makefile using qmake
-- building library (this may take some time...)
make: *** No targets specified and no makefile found. Stop.
CMake Warning at octovis/CMakeModules/FindQGLViewer.cmake:111 (MESSAGE):
Could not find libQGLViewer.so, failed to build?
Call Stack (most recent call first):
octovis/CMakeLists.txt:79 (FIND_PACKAGE)
libQGLViewer could not be found or generated.
Unfortunately, the viewer (octovis) can not be built because some requirements are missing.
This will not affect the compilation of the stand-alone library and tools (octomap)
See README.txt or http://octomap.sf.net for further information.
進入octomap/octovis/src/extern/QGLViewer
,執行qmake
和make
。成功生成了libQGLViewer.so
。最後sudo make install
。
OpenGL
cmake configure octomap時還有關於OpenGL的警告,需要用戶手工指定OpenGL_GL_PREFERENCE
。
CMake Warning (dev) at /usr/local/share/cmake-3.14/Modules/FindOpenGL.cmake:275 (message):
Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
available. Run "cmake --help-policy CMP0072" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
FindOpenGL found both a legacy GL library:
OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so
and GLVND libraries for OpenGL and GLX:
OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so
OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
octovis/CMakeLists.txt:71 (FIND_PACKAGE)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
嘗試cmake -DOpenGL_GL_PREFERENCE=GLVND
,但編譯過程中出現錯誤
/usr/bin/ld: CMakeFiles/octovis.dir/src/ViewerWidget.cpp.o: undefined reference to symbol 'glEnable'
//usr/lib/x86_64-linux-gnu/libGL.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
octovis/CMakeFiles/octovis.dir/build.make:356: recipe for target '../bin/octovis' failed
make[2]: *** [../bin/octovis] Error 1
CMakeFiles/Makefile2:2232: recipe for target 'octovis/CMakeFiles/octovis.dir/all' failed
make[1]: *** [octovis/CMakeFiles/octovis.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
嘗試cmake -DOpenGL_GL_PREFERENCE=LEGACY
,編譯未報錯。
prefix
最終cmake configure時指定了custom安裝位置
cmake -DOpenGL_GL_PREFERENCE=LEGACY -DCMAKE_INSTALL_PREFIX=<octomap-install-path>
編譯安裝
make && sudo make install
測試
octomap
解壓octomap/octomap/share/example-project.tgz
,得到octomap-example
文件夾。修改octomap-example/CMakeLists.txt
,將octomap的搜索路徑明確指定。
find_package(octomap REQUIRED PATHS <octomap-install-path>/share/octomap)
執行cmake
進行configure,之後make
。
編譯完畢後得到simple
可執行文件。運行simple
得到如下屏幕輸出
generating example map
performing some queries:
occupancy probability at (0 0 0): 0.971
occupancy probability at (-1 -1 -1): 0.1192
occupancy probability at (1 1 1): is unknown
Writing 801 nodes to output stream...wrote example file simple_tree.bt
now you can use octovis to visualize: octovis simple_tree.bt
Hint: hit 'F'-key in viewer to see the freespace
使用octovis來visualize 生成的octomap
<octomap-install-path>/bin/octovis simple_tree.bt
得到的如下畫面(按F鍵顯示free space)
後記
後期需要利用octomap進行occupancy map的生成。以後再更新。