ROS环境下Pointgrey相机的配置方法

1.根据相机型号在官方网站下载驱动,然后根据驱动包里的 README 按顺序安装驱动:

https://www.ptgrey.com/support/downloads

2.安装pointgrey的ROS驱动(建议从源码安装):

http://wiki.ros.org/pointgrey_camera_driver
https://github.com/ros-drivers/pointgrey_camera_driver

安装过程中可能会出现libusb的库冲突,查找冲突然后删掉自己安装的库文件就好了,参考->http://www.cnblogs.com/zhchp-blog/p/7240278.html。

3.相机参数的设置:

   1)修改cfg文件夹下的“PointGrey.cfg”文件中的相关参数,修改后重新编译即可(推荐这种方法)

   2)在../pointgrey_camera_driver/src/PointGreyCamera.cpp源码中的

bool PointGreyCamera::setNewConfiguration(pointgrey_camera_driver::PointGreyConfig &config, const uint32_t &level)

函数中设置。我的设置方式如下,还未真正测试效果:

 bool PointGreyCamera::setNewConfiguration(pointgrey_camera_driver::PointGreyConfig &config, const uint32_t &level)
  {
      .........
      // Check video mode
      VideoMode vMode; // video mode desired
      Mode fmt7Mode; // fmt7Mode to set
      //retVal &= PointGreyCamera::getVideoModeFromString(config.video_mode, vMode, fmt7Mode);
      std::string testMode="640x480_mono8";
      retVal &= PointGreyCamera::getVideoModeFromString(testMode, vMode, fmt7Mode);
     ////////////////////////////
     .........  
     // Set frame rate
     //retVal &= PointGreyCamera::setProperty(FRAME_RATE, false, config.frame_rate);
     ////****************fix the value of frame rate******************************
     double testFrameRate=60.0;
     retVal &= PointGreyCamera::setProperty(FRAME_RATE, false, testFrameRate);
     ////*************************************************************************
 
     // Set exposure
     //retVal &= PointGreyCamera::setProperty(AUTO_EXPOSURE, config.auto_exposure, config.exposure);
     ////****************fix the value of auto exposure***************************
     double testAutoExposure=40.0;
     retVal &= PointGreyCamera::setProperty(AUTO_EXPOSURE, false, testAutoExposure);
     ////*************************************************************************
 
     // Set sharpness
     //retVal &= PointGreyCamera::setProperty(SHARPNESS, config.auto_sharpness, config.sharpness);
     retVal &= PointGreyCamera::setProperty(SHARPNESS, true, config.sharpness);
     /////////////////
 
     // Set saturation
     //retVal &= PointGreyCamera::setProperty(SATURATION, config.auto_saturation, config.saturation);
     retVal &= PointGreyCamera::setProperty(SATURATION, true, config.saturation);
     /////////////////
 
     // Set shutter time
     double shutter = 1000.0 * config.shutter_speed; // Needs to be in milliseconds
     //retVal &= PointGreyCamera::setProperty(SHUTTER, config.auto_shutter, shutter);
     shutter=16.0;
     retVal &= PointGreyCamera::setProperty(SHUTTER, false, shutter);
     /////////////////
     config.shutter_speed = shutter / 1000.0; // Needs to be in seconds
 
     // Set gain
     //retVal &= PointGreyCamera::setProperty(GAIN, config.auto_gain, config.gain);
     retVal &= PointGreyCamera::setProperty(GAIN, true, config.gain);
     /////////////////
 
     // Set pan
     unsigned int pan = config.pan;
     unsigned int not_used = 0;
     retVal &= PointGreyCamera::setProperty(PAN, false, pan, not_used);
     config.pan = pan;
 
     // Set tilt
     unsigned int tilt = config.tilt;
     retVal &= PointGreyCamera::setProperty(TILT, false, tilt, not_used);
     config.tilt = tilt;
 
     // Set brightness
     //retVal &= PointGreyCamera::setProperty(BRIGHTNESS, false, config.brightness);
     ////****************fix the value of frame rate******************************
     double testBrightness=160.0;
     retVal &= PointGreyCamera::setProperty(BRIGHTNESS, false, testBrightness);
     /////////////////
     ////*************************************************************************
 
     // Set gamma
     //retVal &= PointGreyCamera::setProperty(GAMMA, false, config.gamma);
     retVal &= PointGreyCamera::setProperty(GAMMA, true, config.gamma);
     /////////////////
     ...........
 }
View Code

 

ps.有时候发现即使在PointGrey.cfg中把framerate设置到100hz,实际的图像帧率也只有40hz左右,这种情况下:pointgrey相机连接到USB,打开FlyCap2,如果提示“could not find glade file 'FlyCapture2GUI_GTK.glade'”,就搜索这个文件的位置,然后$cd到该位置,再$FlyCap2,然后把framerate那个滑动条拉到最大然后退出即可。再次启动ROS的驱动,既可以看到图像帧率达到60hz

posted on 2017-12-14 22:05  zhch_pan  阅读(3200)  评论(2编辑  收藏  举报

导航