当前位置:   article > 正文

初试ORB-SLAM2(1):利用外接usb摄像头并测试摄像头节点(详细教程)_[image_view-2] killing on exit [usb_cam-1] killing

[image_view-2] killing on exit [usb_cam-1] killing on exit

【环境及第三方库配置】Ubuntu16.04,已安装ROS、Eigen3、Sophus、Ceres、g2o、OpenCV3.3、PCL等

1、在个人的/home目录下先创建ROS工作空间

  1. $ mkdir -p ~/catkin_ws/src
  2. $ cd ~/catkin_ws/src
  3. $ catkin_init_workspace

2、进入到catkin_ws/src目录下,下载usb_cam的源文件到此目录下

  1. $ cd ~/catkin_ws/src
  2. $ git clone https://github.com/bosch-ros-pkg/usb_cam.git

3、把ORB-SLAM2.tar.gz下载并解压缩到catkin_ws/src目录下,并build好(大概需要一小时)

  1. $ chmod +x build.sh
  2. $ ./build.sh

4、退回到catkin_ws/,运行

$ source ~/catkin_ws/devel/setup.bash

5、安装ros-kinetic-usb-cam

$ sudo apt-get install ros-kinetic-usb-cam

6、如果(其实大部分情况下都是)在虚拟机中运行ORB-SLAM和ROS的话,需要单击VMware Fusion的菜单栏中的“虚拟机—摄像头—……”,选取usb摄像头(默认是笔记本自带摄像头),此时如果一切正常的话,应可以看到摄像头的实时图像。更具体的操作请参见《ubuntu虚拟机下使用摄像头》:https://blog.csdn.net/xiaozi0221/article/details/79135930

7、查看Ubuntu系统检测到的摄像头设备,先在终端中运行lsusb,看看列出的Bus ID后是否有已连接的摄像头型号,如Logitech, Inc. HD Webcam C525等;再到根目录下的dev文件夹中查看是否有video,一般是/dev/video0;这两个条件都满足说明摄像头连上虚拟机并被Ubuntu所识别;

$ ls /dev/video*

8、启用ROS系统和摄像头节点 

  1. $ cd ~/catkin_ws/
  2. $ roscore
  3. ​​​​​​

 此时请打开新的终端,回到catkin_ws目录下,再make一次,然后source一下(注意,每一次catkin_make之后都要source一下):

  1. $ cd ~/catkin_ws/
  2. $ catkin_make
  3. $ source ~/catkin_ws/devel/setup.bash

 最后到usb_cam目录下的launch文件夹中运行roslaunch:

  1. $ cd ~/catkin_ws/src/usb_cam/launch
  2. $ roslaunch usb_cam usb_cam-test.launch

如果一切正常,将会弹出一个窗口,里面显示摄像头的实时映像。

9、如果拔了摄像头后再重新连接,或者中途关掉弹出窗口,请返回第8步重启roscore后再roslaunch。

 

【特殊情况二】

还有可能出现下面的错误,即所谓的“[usb_cam-1] process has died [pid 3546, exit code -11”错误:

  1. kinetic@ros-vm:~/mywork/catkin_ws/src/usb_cam/launch$ roslaunch usb_cam-test.launch
  2. ... logging to /home/kinetic/.ros/log/e8db393a-feca-11e8-9c82-000c291d31c4/roslaunch-ros-vm-3528.log
  3. Checking log directory for disk usage. This may take awhile.
  4. Press Ctrl-C to interrupt
  5. Done checking log file disk usage. Usage is <1GB.
  6. started roslaunch server http://192.168.62.128:35227/
  7. SUMMARY
  8. ========
  9. PARAMETERS
  10. * /image_view/autosize: True
  11. * /rosdistro: kinetic
  12. * /rosversion: 1.12.7
  13. * /usb_cam/camera_frame_id: usb_cam
  14. * /usb_cam/image_height: 480
  15. * /usb_cam/image_width: 640
  16. * /usb_cam/io_method: mmap
  17. * /usb_cam/pixel_format: yuyv
  18. * /usb_cam/video_device: /dev/video0
  19. NODES
  20. /
  21. image_view (image_view/image_view)
  22. usb_cam (usb_cam/usb_cam_node)
  23. ROS_MASTER_URI=http://192.168.62.128:11311
  24. core service [/rosout] found
  25. process[usb_cam-1]: started with pid [3546]
  26. process[image_view-2]: started with pid [3547]
  27. init done
  28. [ INFO] [1544700971.902073651]: Using transport "raw"
  29. [ INFO] [1544700972.025623804]: using default calibration URL
  30. [ INFO] [1544700972.025790930]: camera calibration URL: file:///home/kinetic/.ros/camera_info/head_camera.yaml
  31. [ INFO] [1544700972.025874556]: Unable to open camera calibration file [/home/kinetic/.ros/camera_info/head_camera.yaml]
  32. [ WARN] [1544700972.025906964]: Camera calibration file /home/kinetic/.ros/camera_info/head_camera.yaml not found.
  33. [ INFO] [1544700972.025937876]: Starting 'head_camera' (/dev/video0) at 640x480 via mmap (yuyv) at 30 FPS
  34. [usb_cam-1] process has died [pid 3546, exit code -11, cmd /opt/ros/kinetic/lib/usb_cam/usb_cam_node __name:=usb_cam __log:=/home/kinetic/.ros/log/e8db393a-feca-11e8-9c82-000c291d31c4/usb_cam-1.log].
  35. log file: /home/kinetic/.ros/log/e8db393a-feca-11e8-9c82-000c291d31c4/usb_cam-1*.log
  36. ^C[image_view-2] killing on exit
  37. shutting down processing monitor...
  38. ... shutting down processing monitor complete
  39. done

这种情况原因还不明,但是通过重复第6-9步可以解决。过程就不赘述了。

【备注】本人刚接触ORB-SLAM2不久,也是参考了网上资料亲测总结而成,希望能帮到后来人。如有错误,请回复或联系我更正。谢谢阅读!

 

此教程参考如下链接:

https://blog.csdn.net/weixin_40522162/article/details/79477699

https://blog.csdn.net/panxiying1993/article/details/61922162

Eigen3、Sophus、Ceres、g2o、OpenCV3.3、PCL等的安装请见:

https://www.cnblogs.com/feifanrensheng/p/8227716.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/545967
推荐阅读
相关标签
  

闽ICP备14008679号