orbslam2搭建栅格地图 ORB_SLAM2-gridmap编译运行(前提:成功编译运行orbslam2)

orbslam2运行编译网上很多教程,找一下就可以成功

环境:ubuntu18.04

下载源码

cd
git clone https://github.com/skylook/ORB_SLAM2-gridmap.git
cd ORB_SLAM2-girdmap
chmod +x build.sh
chmod +x build_ros.sh

运行build.sh

./build.sh

报错

Tracking.cc:39:33: fatal error: cv_bridge/cv_bridge.h: No such file or directory

解决方法:在CMakeLists.txt上加入

include_directories( ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include ${EIGEN3_INCLUDE_DIR} ${Pangolin_INCLUDE_DIRS} /opt/ros/melodic/include )

↑这里我用的是ubuntu18.04 所以是melodic

继续运行build.sh

./build.sh

按理说ORBSLAM2编译成功,这里不会再有报错

先进行一个操作

vim ~/.bashrc
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/自己的用户名/ ORB_SLAM2-girdmap /Examples/ROS
source ~/.bashrc

运行build_ros.sh

./build_ros.sh

报错

[rosbuild] rospack found package "ORB_SLAM2" at

  "/home/bo/orbslam_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2", but the current

  directory is "/home/bo/ORB_SLAM2-gridmap/Examples/ROS/ORB_SLAM2".  You

  should double-check your ROS_PACKAGE_PATH to ensure that packages are found

  in the correct precedence order.

这是由于在ROS环境下编译使用了多个版本的ORB-SLAM2工程造成的,比如我运行了原版的ORB-SLAM2,对新的orbslam2工程编译,就报了这个错误。因为原工程已经在/opt/ros/melodic/share文件夹下建立了一个软连接ORB_SLAM2,这里包含有原工程的一些信息,我们需要做的就是把该软连接,替换为现在工程的软连接

解决:

cd /opt/ros/melodic/share
sudo rm -r ORB_SLAM2
sudo ln -s /home/bo/ORB_SLAM2-gridmap/Examples/ROS/ORB_SLAM2 /opt/ros/melodic/share/ORB_SLAM2

再运行build_ros.sh

./build_ros.sh

按照道理来说是成功了

 测试运行(参照steps)根据自己的需求选择合适命令

run on TUM-RGBD with:

./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUM3.yaml /home/abhineet/TUM-RGBD/rgbd_dataset_freiburg3_walking_halfsphere

navigate using the map and visualize with:

roslaunch turtlebot_gazebo turtlebot_world.launch

or

roslaunch turtlebot_gazebo turtlebot_world.launch world_file:=/opt/ros/indigo/share/turtlebot_gazebo/worlds/empty.world

for empty world

roslaunch turtlebot_gazebo amcl_demo.launch map_file:=/home/abhineet/ORB_SLAM2/grid_map.yaml

roslaunch turtlebot_rviz_launchers view_navigation.launch

running orb slam with gmapping:

rosrun ORB_SLAM2 Mono Vocabulary/ORBvoc.txt Examples/Monocular/KITTI00-02.yaml  /home/abhineet/KITTI/00

rosrun pointcloud_to_laserscan pointcloud_to_laserscan_node

rosrun gmapping slam_gmapping

rosrun rviz rviz

Displays->Add->Map

set Topic to /map

get all map points for the rosbag:

rosrun ORB_SLAM2 Mono Vocabulary/ORBvoc.txt Examples/Monocular/demo_cam.yaml /camera/image_raw:=usb_cam/image_raw

start publisher with dataset:

rosrun ORB_SLAM2 Monopub Vocabulary/ORBvoc.txt Examples/Monocular/KITTI00-02.yaml /home/abhineet/KITTI/00 0

rosrun ORB_SLAM2 Monopub Vocabulary/ORBvoc.txt Examples/Monocular/TUM3.yaml /home/abhineet/TUM-RGBD/rgbd_dataset_freiburg3_walking_halfsphere

start publisher with camera:

rosrun ORB_SLAM2 Monopub Vocabulary/ORBvoc.txt Examples/Monocular/mono.yaml 0

start publisher with default topic (/camera/image_raw):

rosrun ORB_SLAM2 Monopub Vocabulary/ORBvoc.txt Examples/Monocular/mono.yaml -1

start publisher with custom topic:

rosrun ORB_SLAM2 Monopub Vocabulary/ORBvoc.txt Examples/Monocular/demo_cam.yaml -1 /usb_cam/image_raw

start subscriber on kitti 00:

rosrun ORB_SLAM2 Monosub 5 3 29 -25 48 -12 0.55 0.50 1 5

rosrun ORB_SLAM2 Monosub 10 1 29 -25 48 -12 0.55 0.50 1 5

start subscriber on rosbag:

rosrun ORB_SLAM2 Monosub 30 5 2 -2 2 -2 0.55 0.50 1 5

rosrun ORB_SLAM2 Monosub 30 2 6 -6 6 -6 0.55 0.50 1 5

rosrun ORB_SLAM2 Monosub 10 0.5 20 -10 20 -10 0.55 0.50 1 5

running rosbag of recording:

rosbag play "/media/abhineet/Win 8/bags/2017-04-03-20-35-36.bag" -r 0.5

rosbag play 2017-04-09-22-08-04.bag -r 0.5

rosbag play "/media/abhineet/Win 8/bags/2017-04-03-13-37-07.bag" -r 0.5

参考链接

https://blog.csdn.net/weixin_44401286/article/details/102752767

https://blog.csdn.net/weixin_44452848/article/details/127023523

https://blog.csdn.net/chengmo123/article/details/104906376

https://blog.csdn.net/cyx610481953/article/details/115378494

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值