1、安装rbx1包
创建一个工作空间,这里以catkin_ws
为例,下载并编译rbx1
安装包:
$ cd ~/catkin_ws/src
$ git clone https://github.com/ncnynl/rbx1.git
$ cd ~/catkin_ws
$ catkin_make
2、安装usb_cam驱动
$ cd ~/catkin_ws/src
$ git clone https://github.com/bosch-ros-pkg/usb_cam.git
$ cd ~/catkin_ws
$ catkin_make
目前新版本的rbx1
已经带有usb_cam
,如果没有添加如下。
在catkin_ws/src/rbx1/rbx1_vision/launch
目录,新建usb_cam.launch
$ cd ~/catkin_ws/src/rbx1/rbx1_vision/launch
$ touch usb_cam.launch
$ vim usb_cam.launch
代码如下:
<launch>
<arg name="video_device" default="/dev/video0" />
<node name="usb_cam" pkg="usb_cam" type="usb_cam_node" clear_params="true" output="screen">
<remap from="usb_cam/image_raw" to="/camera/rgb/image_raw" />
<remap from="usb_cam/camera_info" to="/camera/rgb/camera_info" />
<param name="video_device" value="$(arg video_device)" />
<param name="image_width" value="640" />
<param name="image_height" value="480" />
<param name="framerate" value="30" />
<param name="pixel_format" value="mjpeg" />
<param name="contrast" value="32" />
<param name="brightness" value="32" />
<param name="saturation" value="32" />
<param name="autofocus" value="true" />
<param name="camera_frame_id" value="camera_link" />
</node>
</launch>
3、测试使用
- 启动
roscore
$ roscore
- 启动
rbx1
$ roslaunch rbx1_vision usb_cam.launch video_device:=/dev/video0
- 查看图像
$ rosrun rqt_image_view rqt_image_view
- 查看相机相关发布的话题
$ rostopic list
显示如下:
/camera/rgb/camera_info
/camera/rgb/image_raw
/camera/rgb/image_raw/compressed
/camera/rgb/image_raw/compressed/parameter_descriptions
/camera/rgb/image_raw/compressed/parameter_updates
/camera/rgb/image_raw/compressedDepth
/camera/rgb/image_raw/compressedDepth/parameter_descriptions
/camera/rgb/image_raw/compressedDepth/parameter_updates
/camera/rgb/image_raw/theora
/camera/rgb/image_raw/theora/parameter_descriptions
/camera/rgb/image_raw/theora/parameter_updates
/rosout
/rosout_agg
测试完毕。
小Tips:查看连接的可用设备