关闭

Camera in ROS and VISCA

553人阅读 评论(0) 收藏 举报
分类:

本文主要介绍与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的角度。因此用的欲望不大。

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:90796次
    • 积分:2204
    • 等级:
    • 排名:第17797名
    • 原创:99篇
    • 转载:6篇
    • 译文:1篇
    • 评论:22条
    文章分类
    最新评论