在 pi 上使用 RPLIDAR A2 在 catkin_make 命令上出错 HectorSLAM

Error HectorSLAM on catkin_make command using RPLIDAR A2 on pi

对于我正在进行的机器人项目。我们正在建造一辆自动驾驶的遥控车。所以我们使用 ROS 在带有 RPLIDAR SDK 和 HECTOR SLAM 的 raspberryPi 3B+ 上管理所有这些。

catkin_make 命令仅对 RPLIDAR 成功,当将 hector slam 克隆到同一个 src 文件夹时,(src/hector_slam 和 src/rplidar_ros)运行 catkin_make 现在引入了 HECTOR_SLAM 我得到了这些错误,我不确定如何解决

catkin_make
Base path: /home/bres/rplidar_ws
Source space: /home/bres/rplidar_ws/src
Build space: /home/bres/rplidar_ws/build
Devel space: /home/bres/rplidar_ws/devel
Install space: /home/bres/rplidar_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/bres/rplidar_ws/build"
####
####
#### Running command: "make -j4 -l4" in "/home/bres/rplidar_ws/build"
####
[  0%] Built target nav_msgs_generate_messages_nodejs
[  0%] Built target std_msgs_generate_messages_nodejs
[  0%] Built target _hector_nav_msgs_generate_messages_check_deps_GetRecoveryInfo
[  0%] Built target _hector_nav_msgs_generate_messages_check_deps_GetSearchPosition
[  0%] Built target _hector_nav_msgs_generate_messages_check_deps_GetNormal
[  0%] Built target _hector_nav_msgs_generate_messages_check_deps_GetDistanceToObstacle
[  0%] Built target nav_msgs_generate_messages_py
[  0%] Built target nav_msgs_generate_messages_lisp
[  0%] Built target std_msgs_generate_messages_py
[  0%] Built target std_msgs_generate_messages_lisp
[  0%] Built target _hector_nav_msgs_generate_messages_check_deps_GetRobotTrajectory
[  0%] Built target std_msgs_generate_messages_cpp
[  0%] Built target nav_msgs_generate_messages_cpp
[  0%] Built target nav_msgs_generate_messages_eus
[  0%] Built target std_msgs_generate_messages_eus
[  0%] Built target rosgraph_msgs_generate_messages_cpp
[  0%] Built target _catkin_empty_exported_target
[  0%] Built target actionlib_msgs_generate_messages_py
[  0%] Built target actionlib_msgs_generate_messages_eus
[  0%] Built target actionlib_msgs_generate_messages_lisp
[  0%] Built target geometry_msgs_generate_messages_cpp
[  0%] Built target actionlib_msgs_generate_messages_cpp
[  0%] Built target geometry_msgs_generate_messages_eus
[  0%] Built target actionlib_msgs_generate_messages_nodejs
[  0%] Built target geometry_msgs_generate_messages_lisp
[  0%] Built target geometry_msgs_generate_messages_nodejs
[  0%] Built target roscpp_generate_messages_py
[  0%] Built target geometry_msgs_generate_messages_py
[  0%] Built target roscpp_generate_messages_nodejs
[  0%] Built target roscpp_generate_messages_eus
[  0%] Built target rosgraph_msgs_generate_messages_eus
[  0%] Built target roscpp_generate_messages_cpp
[  0%] Built target rosgraph_msgs_generate_messages_lisp
[  0%] Built target rosgraph_msgs_generate_messages_nodejs
[  0%] Built target roscpp_generate_messages_lisp
[  0%] Built target rosgraph_msgs_generate_messages_py
[  1%] Building CXX object hector_slam/hector_compressed_map_transport/CMakeFiles/map_to_image_node.dir/src/map_to_image_node.cpp.o
[  4%] Built target rplidarNodeClient
[ 14%] Built target rplidarNode
[ 17%] Built target imu_attitude_to_tf_node
[ 17%] Built target visualization_msgs_generate_messages_eus
[ 17%] Built target visualization_msgs_generate_messages_cpp
[ 20%] Built target pose_and_orientation_to_imu_node
[ 20%] Built target visualization_msgs_generate_messages_lisp
[ 20%] Built target visualization_msgs_generate_messages_py
[ 20%] Built target visualization_msgs_generate_messages_nodejs
[ 20%] Built target sensor_msgs_generate_messages_eus
[ 20%] Built target sensor_msgs_generate_messages_lisp
[ 20%] Built target sensor_msgs_generate_messages_nodejs
[ 20%] Built target sensor_msgs_generate_messages_cpp
[ 20%] Built target sensor_msgs_generate_messages_py
[ 20%] Built target tf_generate_messages_py
[ 20%] Built target tf_generate_messages_cpp
[ 20%] Built target actionlib_generate_messages_cpp
[ 20%] Built target tf_generate_messages_eus
[ 20%] Built target actionlib_generate_messages_eus
[ 20%] Built target actionlib_generate_messages_lisp
[ 20%] Built target actionlib_generate_messages_nodejs
[ 20%] Built target tf_generate_messages_lisp
[ 20%] Built target tf2_msgs_generate_messages_eus
[ 20%] Built target tf_generate_messages_nodejs
[ 20%] Built target tf2_msgs_generate_messages_nodejs
[ 20%] Built target actionlib_generate_messages_py
[ 20%] Built target tf2_msgs_generate_messages_lisp
[ 20%] Built target tf2_msgs_generate_messages_py
[ 20%] Built target tf2_msgs_generate_messages_cpp
[ 20%] Built target _hector_mapping_generate_messages_check_deps_HectorDebugInfo
[ 20%] Built target _hector_mapping_generate_messages_check_deps_HectorIterData
[ 35%] Built target hector_nav_msgs_generate_messages_nodejs
[ 35%] Built target hector_nav_msgs_generate_messages_py
[ 42%] Built target hector_nav_msgs_generate_messages_lisp
[ 50%] Built target hector_nav_msgs_generate_messages_cpp
[ 58%] Built target hector_nav_msgs_generate_messages_eus
[ 61%] Built target hector_mapping_generate_messages_cpp
[ 65%] Built target hector_mapping_generate_messages_py
[ 70%] Built target hector_mapping_generate_messages_eus
[ 72%] Built target hector_mapping_generate_messages_lisp
[ 75%] Built target hector_mapping_generate_messages_nodejs
[ 75%] Built target hector_nav_msgs_generate_messages
[ 77%] Building CXX object hector_slam/hector_trajectory_server/CMakeFiles/hector_trajectory_server.dir/src/hector_trajectory_server.cpp.o
[ 78%] Building CXX object hector_slam/hector_map_server/CMakeFiles/hector_map_server.dir/src/hector_map_server.cpp.o
[ 81%] Built target geotiff_writer
[ 82%] Building CXX object hector_slam/hector_mapping/CMakeFiles/hector_mapping.dir/src/HectorMappingRos.cpp.o
virtual memory exhausted: Cannot allocate memory
hector_slam/hector_map_server/CMakeFiles/hector_map_server.dir/build.make:62: recipe for target 'hector_slam/hector_map_server/CMakeFiles/hector_map_server.dir/src/hector_map_server.cpp.o' failed
make[2]: *** [hector_slam/hector_map_server/CMakeFiles/hector_map_server.dir/src/hector_map_server.cpp.o] Error 1
CMakeFiles/Makefile2:3580: recipe for target 'hector_slam/hector_map_server/CMakeFiles/hector_map_server.dir/all' failed
make[1]: *** [hector_slam/hector_map_server/CMakeFiles/hector_map_server.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
hector_slam/hector_mapping/CMakeFiles/hector_mapping.dir/build.make:62: recipe for target 'hector_slam/hector_mapping/CMakeFiles/hector_mapping.dir/src/HectorMappingRos.cpp.o' failed
make[2]: *** [hector_slam/hector_mapping/CMakeFiles/hector_mapping.dir/src/HectorMappingRos.cpp.o] Error 4
make[2]: *** Waiting for unfinished jobs....
[ 84%] Building CXX object hector_slam/hector_mapping/CMakeFiles/hector_mapping.dir/src/main.cpp.o
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
hector_slam/hector_trajectory_server/CMakeFiles/hector_trajectory_server.dir/build.make:62: recipe for target 'hector_slam/hector_trajectory_server/CMakeFiles/hector_trajectory_server.dir/src/hector_trajectory_server.cpp.o' failed
make[2]: *** [hector_slam/hector_trajectory_server/CMakeFiles/hector_trajectory_server.dir/src/hector_trajectory_server.cpp.o] Error 4
CMakeFiles/Makefile2:3689: recipe for target 'hector_slam/hector_trajectory_server/CMakeFiles/hector_trajectory_server.dir/all' failed
make[1]: *** [hector_slam/hector_trajectory_server/CMakeFiles/hector_trajectory_server.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
hector_slam/hector_compressed_map_transport/CMakeFiles/map_to_image_node.dir/build.make:62: recipe for target 'hector_slam/hector_compressed_map_transport/CMakeFiles/map_to_image_node.dir/src/map_to_image_node.cpp.o' failed
make[2]: *** [hector_slam/hector_compressed_map_transport/CMakeFiles/map_to_image_node.dir/src/map_to_image_node.cpp.o] Error 4
CMakeFiles/Makefile2:2767: recipe for target 'hector_slam/hector_compressed_map_transport/CMakeFiles/map_to_image_node.dir/all' failed
make[1]: *** [hector_slam/hector_compressed_map_transport/CMakeFiles/map_to_image_node.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
hector_slam/hector_mapping/CMakeFiles/hector_mapping.dir/build.make:86: recipe for target 'hector_slam/hector_mapping/CMakeFiles/hector_mapping.dir/src/main.cpp.o' failed
make[2]: *** [hector_slam/hector_mapping/CMakeFiles/hector_mapping.dir/src/main.cpp.o] Error 4
CMakeFiles/Makefile2:3758: recipe for target 'hector_slam/hector_mapping/CMakeFiles/hector_mapping.dir/all' failed
make[1]: *** [hector_slam/hector_mapping/CMakeFiles/hector_mapping.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

virtual memory exhausted: Cannot allocate memory

以上显示您 运行 内存不足。您可以通过增加系统上的交换 space 来解决此问题。以下命令将在您的系统

上创建 4GB 的额外交换 space
sudo dd if=/dev/zero of=/swapfile bs=1024 count=4194304
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

要使更改永久生效,请添加到 /etc/fstab

/swapfile swap swap defaults 0 0

编译时,您可以使用

在其他终端查看swap使用情况
sudo swapon --show

如果仍然不够,请增加交换大小。

有2个选项:

  • 按照建议添加交换文件
  • 使用-j1编译以停止溢出