rtabmap

一、 ROS 下安装和使用乐视体感三合一摄像头
1.1 安装摄像头驱动包
http://wiki.ros.org/rtabmap_ros/Tutorials/SetupOnYourRobot#Kinect_.2B-_Odometry_.2B-_Fake_2D_laser_from_Kinect
sudo apt-get update
sudo apt install ros-$ROS_DISTRO-rgbd-launch ros-$ROS_DISTRO-libuvc ros-$ROS_DISTRO-libuvc-camera ros-$ROS_DISTRO-libuvc-ros
如以上安装不成功:
 解压 Orbbec_Astra_Pro_Linux.zip
 解压 libuvc-master.zip 参考readme.md 编译
       cd libuvc
       mkdir build
       cd build
       cmake ..
       make && sudo make install
 
依赖环境
sudo apt-get install build-essential freeglut3 freeglut3-dev
sudo apt-get install libsfml-dev

创建 udev 规则
执行:
cd /home/iimt/workspace/workspace_ros_guidance/src/slam_vslam/ros_astra_camera
cd ros_astra_camera
sudo cp 56-orbbec-usb.rules /etc/udev/rules.d
sudo service udev reload
sudo service udev restart

1.2
https://my.oschina.net/zhangrelay/blog/4828806
使用catkin_make,如果报错,注意libusb.h的位置。使用locate libusb.h,并
使用locate libusb.h,并将其放到合适位置:
 sudo cp /usr/include/libusb-1.0/libusb.h /usr/local/include/libuvc/
修改下libuvc.h中include中的路径。
sudo gedit /usr/local/include/libuvc/libuvc.h 
#include
在启动roscore后,使用:
 rosrun libuvc_camera camera_node
rosrun astra_camera  camera_node

 机器人端启动摄像头
 roslaunch astrapro_launch astrapro.launch
rqt_image_view
查看rgb。
~$ rosrun libuvc_camera camera_node 
[ INFO] [1481169521.460856223]: Opening camera with vendor=0x0, product=0x0, serial="", index=0
[ERROR] [1481169521.461465837]: Permission denied opening /dev/bus/usb/002/004
出现报错,修改端口权限,重试。
[ERROR] [1481169521.461465837]: Permission denied opening /dev/bus/usb/002/004
relaybotbox@relaybotbox-desktop:~$ sudo chmod 777 /dev/bus/usb/002/004
[sudo] relaybotbox 的密码: 
relaybotbox@relaybotbox-desktop:~$ rosrun libuvc_camera camera_node 
[ INFO] [1481169588.328108966]: Opening camera with vendor=0x0, product=0x0, serial="", index=0
unsupported descriptor subtype: 13
unsupported descriptor subtype: 13
[ WARN] [1481169589.131025001]: Unable to set scanning_mode to 0
[ WARN] [1481169589.132290563]: Unable to set auto_exposure to 8
[ WARN] [1481169589.133330942]: Unable to set auto_exposure_priority to 0
[ WARN] [1481169589.135009273]: Unable to set exposure_absolute to 1
[ WARN] [1481169589.136271211]: Unable to set auto_focus to 1
[ WARN] [1481169589.137170759]: Unable to set focus_absolute to 0
[ WARN] [1481169589.138442322]: Unable to set gain to 0
[ WARN] [1481169589.140162069]: Unable to set iris_absolute to 0
[ WARN] [1481169589.141553880]: Unable to set pantilt to 0, 0
[ INFO] [1481169589.273060465]: using default calibration URL
[ INFO] [1481169589.273198871]: camera calibration URL: file:///home/relaybotbox/.ros/camera_info/camera.yaml
[ INFO] [1481169589.273354822]: Unable to open camera calibration file [/home/relaybotbox/.ros/camera_info/camera.yaml]
[ WARN] [1481169589.273418390]: Camera calibration file /home/relaybotbox/.ros/camera_info/camera.yaml not found.

使用 rqt_image_view ,查看rgb如下:
深度图像 /camera/depth/image
彩色图像 /camera/rgb/image_raw/compressed
红外图像 /camera/ir/image
安装视觉 robot_vslam 相关的包并配置环境变量
安装相关依赖软件
 
sudo apt install ros-$ROS_DISTRO-rtabmap ros-$ROS_DISTRO-rtabmap-ros

# git clone https://github.com/introlab/rtabmap_ros.git

cd /home/iimt/workspace/workspace_ros_guidance/src/slam_vslam/robot_vslam/script/
./setrgbd.sh astrapro
source ~/.bashrcs
#===========================问题=================================

locate libusb.h 找不到的话需要安装 ubuntu14.04 可能出现这个问题
安装libusb  https://www.cnblogs.com/ettie999/p/8142973.html

下载 libusb-1.0.24.tar.bz2   http://sourceforge.net/projects/libusb/

解压源码
cd /下载
tar -xjvf libusb-1.0.24.tar.bz2
4.按照INSTALL文件给出的提示进行安装:./configure - make - sudo make install
先configure:
cd libusb-1.0.24/
./configure

configure失败,configure: error: "udev support requested but libudev not installed"

安装依赖项libudev-dev:
cd
sudo apt-get install libudev-dev

安装libuvc
此时安装libuvc成功,可以找到libusb.h文件了。
#=============================问题=======================================
解决apt-get install E: 无法定位软件包问题
添加源
系统设置->软件和更新—>其它软件 左下角添加
deb http://packages.ros.org/ros/ubuntu xenial main
deb http://packages.ros.org/ros-shadow-fixed/ubuntu xenial main

#==========================草稿======================================
https://blog.csdn.net/sinat_37064286/article/details/102981446?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_baidulandingword-1&spm=1001.2101.3001.4242
Ubuntu 18.04
解决apt-get install E: 无法定位软件包问题
sudo gedit  /etc/apt/sources.list
加入
deb http://archive.ubuntu.com/ubuntu/ trusty main universe restricted multiverse
sudo apt-get update
#阿里云源
deb http://mirrors.aliyun.com/ubuntu/ disco main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ disco main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ disco-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ disco-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ disco-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ disco-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ disco-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ disco-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ disco-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ disco-proposed main restricted universe multiverse
 
#中科大源
deb https://mirrors.ustc.edu.cn/ubuntu/ disco main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ disco main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ disco-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ disco-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ disco-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ disco-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ disco-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ disco-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ disco-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ disco-proposed main restricted universe multiverse
 
#163源
deb http://mirrors.163.com/ubuntu/ disco main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ disco-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ disco-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ disco-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ disco-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ disco main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ disco-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ disco-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ disco-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ disco-backports main restricted universe multiverse
 
#清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-proposed main restricted universe multiverse

Ubuntu 16.04 出现无法定位软件包
#==========================仿真建图======================================
1.启动机器人模型
roslaunch nav_sim myrobot_world.launch
2.启动机器人gmapping
roslaunch nav_sim gmapping.launch
   roslaunch nav_sim move_base.launch

roslaunch robot_vslam camera.launch
roslaunch robot_vslam rtabmap_rgbd_lidar.launch or  roslaunch robot_vslam rtabmap_rgbd_lidar_orbslam2.launch
roslaunch robot_vslam rtabmap_rviz.launch
#==========================仿真建图======================================

建图
   roslaunch turtlebot3_gazebo turtlebot3_house.launch
   开启实时建图功能,算法选择gmapping, 还有多种slam算法, 如cartographer,hector_slam
   roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping
   控制:
   roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch


   roslaunch robot_vslam camera.launch
   roslaunch robot_vslam rtabmap_rgbd_lidar.launch or  roslaunch robot_vslam rtabmap_rgbd_lidar_orbslam2.launch
   roslaunch robot_vslam rtabmap_rviz.launch
   rqt_image_view
   尽可能保证地图闭合,然后保存地图为文件
   rosrun map_server map_saver -f ~/3d/map

   Crtabmap: Saving database/long-term memory... (located at /home/iimt/.ros/rtabmap.db)
   rtabmap: 2D occupancy grid map saved.
   rtabmap: Saving database/long-term memory...done! (located at /home/iimt/.ros/rtabmap.db, 5039 MB)

自动导航
   roslaunch turtlebot3_gazebo turtlebot3_house.launch

   roslaunch turtlebot3_navigation turtlebot3_navigation.launch map_file:=/home/iimt/3d/map.yaml

  
   roslaunch robot_vslam camera.launch
   roslaunch robot_vslam rtabmap_rgbd_lidar.launch localization:=true

   PC 端打开 rviz 终端和 rtabmapviz 可视化工具
   roslaunch robot_vslam rtabmap_rviz.launch
   roslaunch robot_vslam rtabmapviz.launch
   rqt_image_view

#==========================仿真======================================
   roslaunch visualorientation scan_odomety_test.launch
   rosrun visualorientation odometry_my_node
   rosrun visualorientation scan_test_my_node
1.启动机器人模型
roslaunch nav_sim myrobot_world.launch

2.启动机器人gmapping
roslaunch nav_sim gmapping.launch

3.启动机器人模型move_base
roslaunch nav_sim move_base.launch

4.启动机器人模型
在仿真过程中,可以使用rqt_reconfigure在不重新启动仿真的情况下对参数值进行修改,使用以下指令:
rosrun rqt_reconfigure rqt_reconfigure

#============================rosbag==================================

//需要进入存放数据的目录
cd ~/bagfiles
//记录所有topic的数据,建议不要一次性录制所有数据,深度数据可能会录制失败,数据量也非常大11s达到250m
rosbag record -a
-a 选项表示将当前发布的所有 topic 数据都录制保存到一个 rosbag 文件中,录制的数据包名字为日期加时间。也可以只记录某些感兴趣的 topic
rosbag record /topic_name1 /topic_name2 /topic_name3
//需要进入存放数据的目录
cd /home/iimt/3rdparty/ORB_SLAM2/data
rosbag record /camera/rgb/image_raw /camera/depth_registered/image_raw /camera/rgb/camera_info /camera/depth/camera_info 


如果要指定生成数据包的名字,则用-O /-o 参数,如下:
//需要进入存放数据的目录
cd ~/bagfiles
rosbag record -O filename.bag /topic_name1

如果在 launch 文件中使用 rosbag record 命令,如下:
 


rosbag info指令可以显示数据包中的信息:
rosbag info filename.bag

以yaml格式查看
rosbag info -y filename.bag


示例:
//需要进入数据所在目录
cd /home/iimt/3rdparty/ORB_SLAM2/data
//加载读取rosbag数据
rosbag play --pause -l rgbd_dataset_freiburg1_xyz.bag
如果希望 rosbag 循环播放,并且开始的时候暂停,可以用命令,-r播放速度会更快
rosbag play -l --pause  # -l== --loop
 //查看和使用视频数据
 rosrun rqt_image_view rqt_image_view
cd /home/iimt/3rdparty/ORB_SLAM2 右键打开控制台
rosrun ORB_SLAM2 RGBD Vocabulary/ORBvoc.txt Examples/RGB-D/TUM1_rosbag.yaml _rgb:=/camera/rgb/image_color _depth:=/camera/depth/image


#=======================================从乐视相机发布数据==orbslam2======Octomap===========================================

从乐视相机发布数据:
//加载内参,运行orbslam时用这个,会提共 /camera/image_raw 节点 ,在astrapro_su_rgb.launch中 :把camera/image_raw 映射成了camera/rgb/image_ra可以显示点云,但是运行orbslam时需要 camera/image_raw需要这个节点,所以要注释掉,具体进launch文件看;用rqt_image_view查看时刷新一下节点
指定输入的rgb话题和depth话题(可以通过rqt_image_view查看确认)
启动Astra相机
cd /home/iimt/workspace/workspace_ros_guidance
 catkin_make
 source devel/setup.sh 
roslaunch astra_camera astrapro_su.launch

RGBD_pose追踪rgbd进行彩色和深度图的地图的构建和定位修改后同时支持输出(4×4的位姿)相机到世界作表系或世界坐标系到相机的表达
cd /home/iimt/3rdparty/ORB_SLAM2
rosrun ORB_SLAM2 RGBD_pose Vocabulary/ORBvoc.txt Examples/ROS/ORB_SLAM2/astra.yaml _rgb:=/camera/rgb/image_raw _depth:=/camera/depth_registered/image_raw

启动点云及Octomap渲染节点
cd /home/iimt/workspace/workspace_ros_guidance
catkin_make
source devel/setup.sh
roslaunch pointcloud_mapping astra.launch
如果没有数据就移动摄像头,因为没有数据更新

此时会有一个rviz窗口和一个点云的viewer窗口启动

ctrl+c 退出后保存不了数据,需要解决
保存数据的路径配置:
 
!注意:
如果点云没有更新或rviz界面没有变化,但是slam页面又是正常有数据的,那说明关键帧还没有生成,拿起摄像头转一些角度动一动就可以了。

在使用点云渲染节点 pointcloud_mapping 后,会在其源码目录输出.pcd文件,我们可以使用pcl_viewer进行查看
pcl_viewer src/pointcloud_mapping/resultPointCloudFile.pcd

安装一下才有 pcl_viewer 命令

sudo apt install pcl-tools
#==================================================================================
RGBD_pose
/home/iimt/3rdparty/ORB_SLAM2/Examples/ROS/ORB_SLAM2
ros_rgbd_pose.cc与ros_rgbd.cc对比 追踪rgbd进行彩色和深度图的地图的构建和定位修改后同时支持输出(4×4的位姿)相机到世界作表系或世界坐标系到相机的表达     
//创建ROS的发布节点
//彩色图
        pub_rgb = nh.advertise("RGB/Image", 10);
//深度图
        pub_depth = nh.advertise("Depth/Image", 10);
//Tcw位姿信息 世界坐标系在相机下的表达
        pub_tcw = nh.advertise("CameraPose", 10);
//里程计
        pub_odom = nh.advertise("Odometry", 10);
//相机轨迹
        pub_camerapath = nh.advertise("Path", 10);


 

你可能感兴趣的:(python,ros,c++)