Camera in ROS and VISCA

原创 2016年08月29日 20:10:17

本文主要介绍与camera相关的一些内容,其中首先介绍在ros中使用camera,其次给出了visca库的使用方法,之后我给该库做了一个简单的ros的封装,还有待于改善,最后是一个开源的机载云台。

use ros to read camera

如果是UVC版本的camera,可以是用uvc_camera and image_view 来读取和显示图像。

sudo apt-get install ros-indigo-uvc-camera
sudo apt-get install ros-indigo-image-view

node is called by

$rosrun uvc_camera uvc_camera_node
$rosrun image_view image_view image:=/image_raw

we can check the ros topics

rostopic list

launch file

<launch>
  <node name="uvc_camera" pkg="uvc_camera" type="uvc_camera_node" output="screen" >
  </node>
  <node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen">
    <remap from="image" to="/image_raw"/>
  </node>
</launch>

也可以使用另外一个usb_cam的驱动

$ sudo apt-get install ros-indigo-usb-camera

因此所使用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="mjpeg" />
    <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>

refer

  1. http://www.voidcn.com/blog/tianyi1991/article/p-4719380.html
  2. http://www.voidcn.com/blog/u013453604/article/p-2088068.html
  3. http://blog.csdn.net/heyijia0327/article/details/41623419
  4. http://blog.csdn.net/jasmine_shine/article/details/46715099

libVISCA

libVISCA is a library for controlling a VISCA(tm) compliant camera through the RS232 port of your PC. VISCA, on its side, is a protocol developed by Sony so that a lot of machine vision cameras from Sony are compliant with VISCA. Typical cameras include the FCB-IX47 family of camera block for OEMs. Note that other devices, such as VCRs, can be controlled. Drop me a line f you know other functions that you would like to be implemented and for which you have the opcodes.
The VISCA protocol makes it possible to control multiple cameras that are chained together. The RS232 cable goes from computer to one camera and the camera connects to the next camera, etc.
There is a forked version of libVISCA available at https://github.com/mkoppanen/libVISCA2
This was tested with:
Sony EVI D70p
The chaining mechanism wasn’t tested yet due to lack of suitable cable.
Building

$ tar -xzf libvisca-2.0.0.tar.gz
$ cd libvisca-2.0.0
$ mkdir build
$ cd build
$ cmake ..
$ make

Also, a preliminary RPM package is available from http://fkooman.fedorapeople.org/libvisca/.
Running

This was tested with a RS232 to VISCA cable using a usb2serial device to make it work as a serial device on ttyUSB3. In order to run the included test, we did the following:

$ sudo ./testvisca /dev/ttyUSB3

Some camera info:

vendor: 0x0001
model: 0x040e
ROM version: 0x0105
socket number: 0x02
Zoom value: 0x1234
power status: 0x02
Setting pan tilt home
Setting pan tilt absolute position
Absolute position, Pan value: -16, Tilt value: 15
Setting pan tilt absolute position
Absolute position, Pan value: -16, Tilt value: 15
Setting pan tilt home
libvisca should also work on Windows (untested).
Mac OS X

libvisca works on Mac OS X after PL2303 Driver has been installed. The open source driver can be found here: http://osx-pl2303.sourceforge.net/
After the driver installation the following command can be used to run testvisca:

$ ls -l  /dev/tty.PL2303-*
crw-rw-rw-  1 root  wheel   10,  32 13 Apr 12:00 /dev/tty.PL2303-00002006
$ ./testvisca /dev/tty.PL2303-00002006
Windows

When using USB to RS232 adapter the address for the serial port is usually COM3. So the following testvisca command should work:
testvisca COM3
Hardware

The following RS232 cable has been tested to work on Mac OS X: Startech USB to RS-232 Serial DB9 Adapter
Cable

Visca cable wiring diagram: http://www.chuktech.net/video/visca_connector_and_wiring.pdf
简介:这是一个canera control librarry.
依赖:../visca/libvisca.h
重要函数: setZoomValue –> VISCA_set_zoom_value
getZoomValue –> VSICA_get_zoom_value

初始化:定义 VISCAInterface_t 和一个VISCACAmera_t型的变量。
然后是解析argv参数,(主要是读出串口号,串口设备),然后打开该串口,读取camera information. 所有的信息存储在VISCAcamera_t型变量中,其中信息包含vendor,model, rom version, and socket number.

sleep(500000);

如果需要用到手动聚焦的模式,给lib中没有,需要改动libvisca.c
在libvisca.c中增加

VISCA_set_focus_mode_manual(VISCAInterface_t *iface, VISCACamera_t *camera)
{
  VISCAPacket_t packet;

  _VISCA_init_packet(&packet);
  _VISCA_append_byte(&packet, VISCA_COMMAND);
  _VISCA_append_byte(&packet, VISCA_CATEGORY_CAMERA1);
  _VISCA_append_byte(&packet, VISCA_FOCUS_AUTO);
  _VISCA_append_byte(&packet, VISCA_FOCUS_AUTO_OFF);

  return _VISCA_send_packet_with_reply(iface, camera, &packet);
}

VISCA_set_focus_mode_auto(VISCAInterface_t *iface, VISCACamera_t *camera)
{
  VISCAPacket_t packet;

  _VISCA_init_packet(&packet);
  _VISCA_append_byte(&packet, VISCA_COMMAND);
  _VISCA_append_byte(&packet, VISCA_CATEGORY_CAMERA1);
  _VISCA_append_byte(&packet, VISCA_FOCUS_AUTO);
  _VISCA_append_byte(&packet, VISCA_FOCUS_AUTO_ON);

  return _VISCA_send_packet_with_reply(iface, camera, &packet);
}

在libvisca.h中增加

VISCA_set_focus_mode_manual(VISCAInterface_t *iface, VISCACamera_t *camera);

VISCA_set_focus_mode_auto(VISCAInterface_t *iface, VISCACamera_t *camera);

即可。

ros warper for VISCA

这里不适合使用message定期发布zoom value,因此使用了service,server节点发布service

ros::ServiceServer visca_service = nh.advertiseService("zoom_service_calbak", &viscaControl::zoom_service_calbak,&m_VSCtrl);

用户节点订阅service

ros::ServiceClient visca_client = nh.serviceClient<visca::gs_zv>("zoom_service_calbak");

这里使用srv文件

int32 set_zv
---
int32 get_zv

service 回调函数

bool viscaControl::zoom_service_calbak( visca::gs_zv::Request &req,
                   visca::gs_zv::Response &res)
{
    if (req.set_zv >= 0 )
    {
        setZoomValue(req.set_zv);
    }
    ros::Duration(0.1).sleep();
    if(VISCA_get_zoom_value(&iface,&camera,&zoom_value)!=VISCA_SUCCESS)
                    fprintf(stderr,"error getting zoom value");
                else
                    fprintf(stderr,"get zoom value %x",zoom_value);
                res.get_zv = zoom_value;
}

注意这个回调函数的返回值应该是bool类型的。

云台

本文中主要介绍记载云台,按照电机分类,比较新的是无刷电机电机,另外有舵机云台等。我们这里主要介绍无刷电机云台,机载云台,使用2各陀螺仪,一个置于主控板上,一个置于末端。另有无刷电机控制器(brushless motor controller)。
开源云台
ardupilot stom32,这时一个开源的3轴云台,因此如果想深入研究云台的制作等,可以参考该设计。
wiki page关于该云台的教程,使用方法,github page都在其中.
我在组装飞机的时候买了一个xcam的云台,发现,无法读取 3 axis的角度。因此用的欲望不大。

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Capture Image from Camera and Display in Activity

问: I want to write a module where on a click of a button the camera opens and I can click and captu...
  • Koupoo
  • Koupoo
  • 2012年05月04日 11:23
  • 357

《Ray Tracing in One Weekend》——Chapter 3: Rays, a simple camera, and background

《Ray Tracing in One Weekend》目录 第一部分:学习总结原文中提到的”background”就是咱们的第一个ray tracing图形啦。为什么时第一个,前面不是有输出一张图了...

Projection and camera view in OpenGL ES 1.0

In the ES 1.0 API, you apply projection and camera view by creating each matrix and then adding them...

ROS环境下的camera实时canny滤波

  • 2016年06月10日 16:36
  • 5KB
  • 下载

raspberri pi 3 + v2 camera 树莓派摄像头 发布到ros 节点上 远程电脑查看视频

树莓派3+ros kinetic 版本 远程电脑+ros indigo 版本 首先开启树莓派的摄像头功能 sudo raspi-config 启动摄像头功能 然后重启树莓派 ...

在ROS使用 Kinect 完成3D图像处理(1)-- 测试OpenNI_camera

认识kinect 3D摄像头: https://en.wikipedia.org/wiki/Kinect 有两个包,支持kinect在ROS上的运行: openni_camera & openni_l...
  • sonictl
  • sonictl
  • 2015年09月15日 13:57
  • 2423

gazebo+ros搭建单目仿真环境:贴有二维码的天花板+kobuki+camera(1)

gazebo搭建单目仿真环境:贴有二维码的天花板+kobuki+image 说明          现在要做基于天花板二维码单目slam,之前都是实物跑,太耗时间了,而且贴二维码与布二维码对实物环...

gazebo+ros搭建单目仿真环境:贴有二维码的天花板+kobuki+camera(2)

二 。 实验平台搭建: 机器人kobuki + camera     有了环境后,那得准备实验平台了。  考虑到kobuki有现成的模型,也有gazebo下的仿真。再者,之前改写过turtlebotg...

PS4 eye camera v2 ROS测试

For the I-RC ps4 eye camera 是一款性价比很高的双目摄像头,之前已经有人设计完成了一代产品的ROS驱动程序,代码见GitHub[1],今天要测试的是去年发布的新款摄像头. ...
  • w_tom
  • w_tom
  • 2017年08月06日 11:05
  • 344
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Camera in ROS and VISCA
举报原因:
原因补充:

(最多只允许输入30个字)