文章目录
运行环境:
ubuntu20.04 noetic
usb_cam
宏基暗影骑士笔记本
1.1 usb_cam连接方式:
1)相机usb--电脑usb1.2 ROS包下载和编译
# 创建工作空间
mkdir -p usb_cam_ws/src
# 克隆仓库
cd usb_cam_ws/src
git clone https://github.com/bosch-ros-pkg/usb_cam.git
sudo apt-get update
sudo apt-get install libv4l-dev
# 编译
cd ..
catkin_make
1.2 运行电脑自带cam
source ./devel/setup.bash
roslaunch usb_cam usb_cam-test.launch
1.3 修改launch文件
1)不插入 usb_cam 编号查询
ls /dev/video*
2)插入 usb_cam 编号查询
ls /dev/video*
电脑自带的是video0和video1,外置相机是video2和video3
所以要运行 usb_cam 需要将video0为video2
修改目录:usb_cam / launch
建议修改ros launch文件如下,代码已贴出
<launch>
<node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
<param name="video_device" value="/dev/video0" />
<param name="image_width" value="640" />
<param name="image_height" value="480" />
<param name="pixel_format" value="yuyv" />
<param name="camera_frame_id" value="usb_cam" />
<param name="io_method" value="mmap"/>
</node>
<node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen">
<remap from="image" to="/usb_cam/image_raw"/>
<param name="autosize" value="true" />
</node>
</launch>
1.4 运行usb_cam
Add–Bytopic–Image–OK
source ./devel/setup.bash
roslaunch usb_cam usb_cam-test.launch