Jetson AGX Orin环境下ROS2 Foxy编译lightning_lm
step1:下载lightning_lm(base)zfjdzfjd-robot:~/zhankun$gitclone https://gitee.com/zhankun3280/lightning-lm Cloning intolightning-lm... remote: Enumerating objects:605, done. remote: Counting objects:100%(605/605), done. remote: Compressing objects:100%(352/352), done. remote: Total605(delta247), reused605(delta247), pack-reused0(from0)Receiving objects:100%(605/605),157.04MiB|6.90MiB/s, done. Resolving deltas:100%(247/247), done. Updating files:100%(246/246), done.step2: 下载依赖google-glog(base)zfjdzfjd-robot:~/zhankun$sudoapt-getinstalllibgoogle-glog-dev Reading package lists... Done Building dependency tree Reading state information... Done libgoogle-glog-dev is already the newest version(0.4.0-1build1). The following packages were automatically installed and are no longer required: gir1.2-goa-1.0 libfwupdplugin1 libxmlb1 Usesudo apt autoremoveto remove them.0upgraded,0newly installed,0to remove and2not upgraded.step3:编译Pangolin(base)zfjdzfjd-robot:~/zhankun/lightning-lm/thirdparty/Pangolin-0.9.3$ ./scripts/install_prerequisites.sh recommended Reading package lists... Done Building dependency tree Reading state information... Done E: Unable tolocatepackage catch2解决办法(base)zfjdzfjd-robot:~/zhankun/lightning-lm/thirdparty/Pangolin-0.9.3/build$sudoaptinstalllibepoxy-dev Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: gir1.2-goa-1.0 libfwupdplugin1 libxmlb1 Usesudo apt autoremoveto remove them. The following NEW packages will be installed: libepoxy-dev0upgraded,1newly installed,0to remove and2not upgraded. Need to get126kB of archives. After this operation,1,689kB of additional disk space will be used. Get:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports focal/main arm64 libepoxy-dev arm641.5.4-1[126kB]Fetched126kBin1s(228kB/s)debconf: delaying package configuration, since apt-utils is not installed Selecting previously unselected package libepoxy-dev:arm64.(Reading database...226773files and directories currently installed.)Preparing to unpack.../libepoxy-dev_1.5.4-1_arm64.deb... Unpacking libepoxy-dev:arm64(1.5.4-1)... Setting up libepoxy-dev:arm64(1.5.4-1)...编译cd/home/zfjd/zhankun/lightning-lm/thirdparty/Pangolin-0.9.3rm-rfbuildmkdirbuildcdbuild cmake..-DCMAKE_CXX_FLAGS-Wno-errorall -Wno-type-limits -Wno-deprecated-copymake-j$(nproc)step4:编译lightning_lm安装依赖(base)zfjdzfjd-robot:~/zhankun/lightning-lm$bashscripts/install_dep.sh Reading package lists... Done Building dependency tree Reading state information... Done libyaml-cpp-dev is already the newest version(0.6.2-4ubuntu1). libgflags-dev is already the newest version(2.2.2-1build1). libgoogle-glog-dev is already the newest version(0.4.0-1build1). libopencv-dev is already the newest version(4.2.0dfsg-5). libpcl-dev is already the newest version(1.10.0dfsg-5ubuntu1). pcl-tools is already the newest version(1.10.0dfsg-5ubuntu1). ros-foxy-pcl-conversions is already the newest version(2.2.1-1focal.20230606.034520). The following packages were automatically installed and are no longer required: gir1.2-goa-1.0 libfwupdplugin1 libxmlb1 Usesudo apt autoremoveto remove them.0upgraded,0newly installed,0to remove and2not upgraded.安装 colcon 工具sudoaptupdatesudoaptinstallpython3-colcon-common-extensionssource/opt/ros/foxy/setup.bash colcon version-check编译报错(base)zfjdzfjd-robot:~/zhankun/lightning-lm$ colcon build --cmake-args-DCMAKE_BUILD_TYPERelease Startinglightning[0.7s][0/1 complete][lightning:cmake -0.1s]--- stderr: lightning CMake Error at cmake/packages.cmake:1(find_package): By not providingFindglog.cmakeinCMAKE_MODULE_PATH this project has asked CMake tofinda package configurationfileprovided byglog, but CMake did notfindone. Could notfinda package configurationfileprovided byglogwith any of the following names: glogConfig.cmake glog-config.cmake Add the installation prefix ofglogto CMAKE_PREFIX_PATH orsetglog_DIRto a directory containing one of the above files. Ifglogprovides a separate development package or SDK, be sure it has been installed. Call Stack(most recent call first): CMakeLists.txt:32(include)--- Failedlightning[0.91s, exited with code1]Summary:0packages finished[1.54s]1package failed: lightning1package had stderr output: lightning解决办法修改 cmake/packages.cmake把第一行find_package(glog REQUIRED)删除替换成下面 pkg-config 代码# glog v0.4.0 find_package(PkgConfig REQUIRED) pkg_check_modules(GLOG REQUIRED libglog)两处额外检查修正下方 include_directories 有一处笔误${pcl_conversions_INCLUDR_DIRS}改成${pcl_conversions_INCLUDE_DIRS}third_party_libs 里glog gflags替换为变量形式pkg-config 标准写法${GLOG_LIBRARIES}源码编译安装新版 CMake# 下载cmake 3.26满足最低要求wgethttps://github.com/Kitware/CMake/releases/download/v3.26.6/cmake-3.26.6.tar.gztar-zxvfcmake-3.26.6.tar.gzcdcmake-3.26.6 ./bootstrapmake-j$(nproc)sudomakeinstall# 刷新动态链接sudoldconfig# 新开终端检查版本cmake--version继续报错importpkg_resources ModuleNotFoundError: No module namedpkg_resourcesCMake Error at /opt/ros/foxy/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41(message): execute_process(/home/zfjd/code/ENTER/bin/python3 /opt/ros/foxy/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py /home/zfjd/zhankun/lightning-lm/build/lightning/ament_cmake_package_templates/templates.cmake)returned error code1Call Stack(most recent call first): /opt/ros/foxy/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:41(include)/opt/ros/foxy/share/pcl_conversions/cmake/ament_cmake_export_include_directories-extras.cmake:8(find_package)/opt/ros/foxy/share/pcl_conversions/cmake/pcl_conversionsConfig.cmake:41(include)cmake/packages.cmake:7(find_package)CMakeLists.txt:32(include)解决办法pipinstallsetuptools58.2.0报错AttributeError: modulepkgutilhas no attributeImpImporter.Did you mean:zipimporter? CMake Error at /opt/ros/foxy/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41(message): execute_process(/home/zfjd/code/ENTER/bin/python3 /opt/ros/foxy/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py /home/zfjd/zhankun/lightning-lm/build/lightning/ament_cmake_package_templates/templates.cmake)returned error code1Call Stack(most recent call first): /opt/ros/foxy/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:41(include)/opt/ros/foxy/share/pcl_conversions/cmake/ament_cmake_export_include_directories-extras.cmake:8(find_package)/opt/ros/foxy/share/pcl_conversions/cmake/pcl_conversionsConfig.cmake:41(include)cmake/packages.cmake:7(find_package)CMakeLists.txt:32(include)解决方法# 编译强制指定系统python3colcon build\--cmake-args\-DPYTHON_EXECUTABLE/usr/bin/python3\-DCMAKE_BUILD_TYPERelease报错c: error: unrecognizedcommandline option ‘-msse’ c: error: unrecognizedcommandline option ‘-msse2’ c: error: unrecognizedcommandline option ‘-msse3’ c: error: unrecognizedcommandline option ‘-msse4’ c: error: unrecognizedcommandline option ‘-msse4.1’ c: error: unrecognizedcommandline option ‘-msse4.2’ c: error: unrecognizedcommandline option ‘-msse’ c: error: unrecognizedcommandline option ‘-msse2’ c: error: unrecognizedcommandline option ‘-msse3’ c: error: unrecognizedcommandline option ‘-msse4’ c: error: unrecognizedcommandline option ‘-msse4.1’ c: error: unrecognizedcommandline option ‘-msse4.2’ make[2]: ***[src/core/miao/utils/CMakeFiles/miao.utils.dir/build.make:76: src/core/miao/utils/CMakeFiles/miao.utils.dir/sampler.cc.o]Error1make[1]: ***[CMakeFiles/Makefile2:1170: src/core/miao/utils/CMakeFiles/miao.utils.dir/all]Error2修改方案打开 cmake/packages.cmake把这两行包裹架构判断原始add_definitions(-msse-msse2-msse3-msse4-msse4.1-msse4.2)set(CMAKE_CXX_FLAGS${CMAKE_CXX_FLAGS}-msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2)替换为if(CMAKE_SYSTEM_PROCESSOR STREQUALx86_64)add_definitions(-msse-msse2-msse4-msse3-msse4.1-msse4.2)set(CMAKE_CXX_FLAGS${CMAKE_CXX_FLAGS}-msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2)endif()说明 add_definitions 现在不推荐用来传编译选项但源码既然这么写原样保留只加条件 aarch64AGX Orin走到这里直接跳过不会追加任何 -msse* 参数 x86 电脑编译依然保留原有 SSE 优化跨平台兼容。或者if(CMAKE_SYSTEM_PROCESSOR STREQUALx86_64)add_definitions(-msse-msse2-msse3-msse4-msse4.1-msse4.2)set(CMAKE_CXX_FLAGS${CMAKE_CXX_FLAGS}-msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2)elseif(CMAKE_SYSTEM_PROCESSOR MATCHESaarch64)set(CMAKE_CXX_FLAGS${CMAKE_CXX_FLAGS}-marchnative)endif()报错AttributeError: modulepkgutilhas no attributeImpImporter.Did you mean:zipimporter? CMake Error at /opt/ros/foxy/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41(message): execute_process(/home/zfjd/code/ENTER/bin/python3 /opt/ros/foxy/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py /home/zfjd/zhankun/lightning-lm/build/lightning/ament_cmake_package_templates/templates.cmake)returned error code1Call Stack(most recent call first): /opt/ros/foxy/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:41(include)/opt/ros/foxy/share/pcl_conversions/cmake/ament_cmake_export_include_directories-extras.cmake:8(find_package)/opt/ros/foxy/share/pcl_conversions/cmake/pcl_conversionsConfig.cmake:41(include)cmake/packages.cmake:10(find_package)CMakeLists.txt:32(include)解决方法确认系统是否存在 python3.8ls/usr/bin/python3.8不存在就安装sudoaptupdatesudoaptinstallpython3.8 python3.8-dev python3.8-distutilscolcon build 强制指定系统 python3.8colcon build\--cmake-args\-DPYTHON_EXECUTABLE/usr/bin/python3.8\-DPYTHON3_EXECUTABLE/usr/bin/python3.8注意事项如果遇到报错彻底清理构建缓存build和cmake文件夹再编译。编译雷达包colcon build --packages-select livox_ros_driver2