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的角度。因此用的欲望不大。

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

visca协议及其实现的简单认识

最近在搞visca协议,在这里写写,算是个记录。从题
  • subfate
  • subfate
  • 2014年06月30日 14:09
  • 3531

SONY VISCA协议及其简单认识

最近在搞visca协议,在这里写写,算是个记录。 visca是索尼公司搞出来的,用来控制相机的协议,一般通过rs232来通信(看了些资料,也有用rs485的)。 一、命令格式 命令通信的基本单元...
  • liusandian
  • liusandian
  • 2016年07月19日 09:46
  • 4632

visca协议及其实现的简单认识

最近在搞visca协议,在这里写写,算是个记录。从题
  • subfate
  • subfate
  • 2014年06月30日 14:09
  • 3531

SONY VISCA协议及其简单认识

最近在搞visca协议,在这里写写,算是个记录。 visca是索尼公司搞出来的,用来控制相机的协议,一般通过rs232来通信(看了些资料,也有用rs485的)。 一、命令格式 命令通信的基本单元...
  • liusandian
  • liusandian
  • 2016年07月19日 09:46
  • 4632

云台控制协议VISCA、PELCO-D、PELCO-P

1. VISCA部分协议命令   控制 命令 格式 备注 预置点 删预置点 8X 01 04 3F 00 ZZ FF X=1-7,8是广播码,下同; ZZ=00...
  • autowanglei
  • autowanglei
  • 2013年12月02日 18:42
  • 5733

Camera Models and Fundamental Concepts Used in Geometric Computer Vision

  • 2017年09月26日 21:49
  • 2.05MB
  • 下载

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
  • 387

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

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

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...
  • xiruanliuwei
  • xiruanliuwei
  • 2012年05月02日 19:41
  • 1008

ROS环境下的camera实时canny滤波

  • 2016年06月10日 16:36
  • 5KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Camera in ROS and VISCA
举报原因:
原因补充:

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