ros调用摄像头
ros调用摄像头
1、安装功能包
只能在catkin_ws/src 目录下创建功能包,编译
cd catkin_ws/src git clone https://github.com/bosch-ros-pkg/usb_cam.git cd .. catkin_make2、运行usb_cam_node 先打开新的终端,运行roscore 新版本的usb_cam包在launch文件夹下有自带的launch文件,名叫usb_cam-test.launch,我们可以直接cd到这个文件夹下运行它。再打开新终端:
cd catkin_ws/src/usb_cam/launch
roslaunch usb_cam-test.launch
出现如下错误:需要source 一下,环境变量未设置
source ~/catkin_ws/devel/setup.bash如下error,则需要安装image-view ERROR: cannot launch node of type [image_view/image_view]: image_view
sudo apt-get install ros-kinetic-image-view
重新运行launch文件就可以正常弹出摄像头图像窗口
在usb_cam-test.launch文件中,默认用的video0,打开本地摄像头,改成video1,就可以打开外接摄像头
使用USB摄像头,将默认的改为video1(注意需要重新编译一下)
其他属性说明 require ="true" :必要节点,当该节点终止时,launch文件中其他节点也被终止 ns="namespace" 为节点内的相对名称添加命名空间前缀"usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" > pkg--功能包名 name--节点运行名 type--节点可执行文件的名字 output--节点标准输出打印到终端(默认是终端日志) "video_device" value="/dev/video0" /> param--参数说明 ,每个活跃的节点可以通过ros::param::get()接口获取parameter的值 "image_width" value="640" /> "image_height" value="480" /> "pixel_format" value="yuyv" /> "camera_frame_id" value="usb_cam" /> "io_method" value="mmap"/> "image_view" pkg="image_view" type="image_view" respawn="false" output="screen"> respawn--复位属性,该节点停止时,会自动重启 from="image" to="/usb_cam/image_raw"/> remap--重映射 将已有的包直接改名拿来用 "autosize" value="true" />