运行某个版本SLAM报错,多个SLAM版本通用:
首先,检查ros环境路径是否是错的,要和current directory对应
echo $ROS_PACKAGE_PATH
Traceback (most recent call last):
File “/opt/ros/kinetic/share/ros/core/rosbuild/bin/check_same_directories.py”, line 46, in
raise Exception
Exception
CMake Error at /opt/ros/kinetic/share/ros/core/rosbuild/private.cmake:102 (message):
[rosbuild] rospack found package “ORB_SLAM2_PointMap_SegNetM” at “”, but
the current directory is
“/home/xxx/catkin_ws/src/DS-SLAM/Examples/ROS/ORB_SLAM2_PointMap_SegNetM”.
You should double-check your ROS_PACKAGE_PATH to ensure that packages are
found in the correct precedence order.
原因是ROS环境路径没加进去
解决方法
1.在 /opt/ros/kinetic(或者melodic、noetic)/setup.bash文件最后加入
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:这里是自己的路径/slam/orb/point_map/Examples/ROS/ORB_SLAM2_PointMap_SegNetM
比如我的然后在setup.sh所在文件夹执行
source setup.sh
- 同样的执行,路径同上
sudo gedit ~/.bashrc
在里面加入
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/...自己的路径../catkin_ws/src/DS-SLAM/Examples/ROS/ORB_SLAM2_PointMap_SegNetM
我的bashrc:
再执行
source ~/.bashrc
- 检查ros环境路径是否添加成功
echo $ROS_PACKAGE_PATH
我的返回是
xx@xxxxxxxxx:~$ echo $ROS_PACKAGE_PATH
/opt/ros/melodic/share:/home/cs/catkin_ws/src/DS-SLAM/Examples/ROS/ORB_SLAM2_PointMap_SegNetM
至此,添加成功
参考
https://blog.csdn.net/weixin_44401286/article/details/102752767