ROS 双目视觉之 bumblebee 篇

来源:互联网 发布:大乐透公式算法技巧 编辑:程序博客网 时间:2024/05/17 02:20

10年年初开始学习使用bumblebee, 11年年初学习ROS,3月开始将bumblebee用在了项目中,现在将之前碰到的问题,进行简单的整理。

bumblebee 也算是ptgrey公司的明星产品之一,如果大家购买pioneer或者其他机器人,配置双目视觉,常常可选之一就是bumblebee,由于其提供较好的API,可在windows和linux使用。(当年为了让销售给我证明调试 真的是可以在linux下使用,还费了他们不少功夫。。。。真是辛苦了)

http://www.ptgrey.com/products/stereo.asp

 

 

它提供了几个库,flycapture ,triclops等。

windows环境下,手册上 triclops介绍了直接获取图像等例程,但是用起来的时候,发现手册上的程序会报一些错误,自带的examples里面,全部使用了flycapture库来进行图像,句柄获取等。所以windows下编程,还是需要两个库结合使用。具体可以参见安装的示例程序。

 

而linux下,一般是不再使用flycapture库的。University of New Mexico,的 Yang Song 整理了bumblebee在linux下的设置和调试过程,题目是HOW TO SETUP BUMBLEBEE STEREO CAMERA UNDER LINUX,他使用的系统是debian,但是我们在ubuntu下使用完全没有问题。

http://marhes.ece.unm.edu/index.php/TXT-1_Stereo_Camera

在linux下安装好bumblebee,我们就可以 在ROS系统中调试Bumblebee相机了。3月我查阅ros wiki中所有使用过Triclops的个stack,有两个,一个已经不再继续支持,并且从svn上已经无法找到相应代码,另外一个是UBC提供的包。调试了Bumblebee2的包还是存在问题,完全无法获取到图像。出现的图像杂乱无章的花纹。可能是因为相机配置问题,这个问题出现相对还比较普遍。

通过配制1394节点bumblebee1394,可以获取到单个相机彩色未矫正图像。

配置bumblebee 用上UBC的ros包,先用bumblebee1394 再用bumblebee_stereo 但是还是无法获取有效的图像,得到的图像是单个相机灰度未矫正图像。

 

由于现成的package 无法调试出我们需要的左右相机图像, 我们自己将 http://www.ptgrey.com/support/kb/data/pgr-stereo-examples-libdc-2.0.2.tar.gz 中的示例程序进行修改,来获取左右相机图片,然后用triclops库计算物体深度信息等。
 

而且两个平台上的triclops库中间有一些函数不一样。windows下以前的测距函数不能使用,必须修改成image16的图像格式,不能用RCD8而得用RCD16.的格式。获取测距信息发现测距数据不准,不能直接计算某个像素点的深度信息。必须使用如下:

int pixelinc = disparityImage.rowinc/2;

 int disparity = disparityImage.data[(int)(pic_y *pixelinc) + (int)pic_x];

 

这份记录是2011年3月的,不知道后来ROS系统中是否更新了一些可直接使用的bumblebee相关的包。用

ptgrey公司的例程进行修改,这个的好处就在于独立于相机设置。能在linux下使用的程序,一般可以再ros下使用的。

 

其他常见问题:

1 在六台电脑上配置过bumblebee,其中有四台出现过重启电脑后,无法识别设备的问题,类似的问题还出现在陀螺仪等上。

仔细检查,会发现相机1394口又没被打开等,可将

http://marhes.ece.unm.edu/index.php/TXT-1_Stereo_Camera 中的

# create the 1394 devices
mknod /dev/raw 1394 c 171 0
chmod a+rw /dev/raw1394
mkdir /dev/video1394
mknod /dev/video1394/0 c 171 16
mknod /dev/video1394/1 c 171 17
mknod /dev/video1394/2 c 171 18
mknod /dev/video1394/3 c 171 19
chmod a+rw /dev/video1394/0
chmod a+rw /dev/video1394/1
chmod a+rw /dev/video1394/2
chmod a+rw /dev/video1394/3

# install the modules
modprobe raw1394
modprobe video1394

 

写成bumblebee.script文件,放在etc 中,然后在rc.local 中加上 sh /etc/bumblebee.script。

如果通过脚本文件,有的机器还无法识别设备,而手动输入指令,输入密码之后,可以完成配置,那么解决方法是,在所有命令前加上 sudo。

2 配置环境,相机识别后,运行一会之后就出现segmentation fault。

   仔细检查所有的库函数,不要在链接的多个路径中放置库文件。

 

//2012 /7/6  发现以前记录的一些文档,补录在这里

要求  libdc1394  libraw1394   新得力安装
如果没安装,会报错 找不到dc1394中 头文件

解决方法:

创建设备和设备通道
修改makefile
将triclops库中 三个a库拷贝到 usr/local/lib


ros环境配制
Environment setup

It's convenient if the ROS environment variables are automatically added to your bash session every time a new shell is launched:

echo "source /opt/ros/diamondback/setup.bash" >> ~/.bashrc
. ~/.bashrc

If you have more than one ROS distribution installed, ~/.bashrc must only source the setup.bash for the version you are currently using.

If you just want to change the environment of your current shell, you can type:

source /opt/ros/diamondback/setup.bash

其他一些关键问题: 如果在新的linux系统上进行配置 切记不要拷贝以前的文件夹和包
文件夹最好通过 create stack  
包 create pkg
在 setup.sh 中修改路径,要小心之前存在的 路径失效,导致之后的路径 也无法被加入。


 bumblebee launch 文件 :

<!-- -*- mode: XML -*- -->

<launch>
  <node pkg="bumblebee2" type="bumblebee2" name="bumblebee2"
 output="screen" respawn="false">
    <param name="video_mode" value="1024x768_stereo_mono" />
    <param name="fps" value="15" />
    <param name="gain" value="auto" />  
    <param name="brightness" value="auto" />
    <param name="whitebalance" value="auto" /> 
    <param name="shutter" value="auto" />   
    <param name="bayer_pattern" value="NONE" /> 
    <param name="bayer_method" value="NONE" /> 
  </node>
</launch>

 

bumblebee 调试 时窗口 的一些记录:

 

sudo chmod 777 /dev/raw1394

roscore


coriander

//rosrun camera1394 camera1394_node _guid:=00b09d01007d6d81 _video_mode:=1024x768_rgb8 _iso_speed:=400 _frame_rate:=10


//ROS_NAMESPACE=camera rosrun image_proc image_proc

rosrun image_view image_view image:=camera/image_mono

 rosrun dynamic_reconfigure reconfigure_gui camera1394_node

 

cd ~/ros_package/ubcros/drivers/bumblebee1394/launch
roslaunch bumblebee.launch

ROS_NAMESPACE=bumblebee roslaunch stereo_image_proc.launch
ROS_NAMESPACE=bumblebee2 rosrun stereo_image_proc stereo_image_proc


 rosrun image_view stereo_view stereo:=/bumblebee2 image:=image_mono
//image_rect_color


There were 1 camera(s) found attached to your PC
Camera 0 model = 'Bumblebee2 BB2-08S2C'
Using this camera
Setting stereo video capture mode
libdc1394 error: Error: Failed to allocate iso bandwidth
libdc1394 error: Error: Failed to setup DMA capture
Can't setup Bumblebee capture
Could not set up video capture mode

// open the channal  something like that --hardware problem