Camera Control Tool

From sdk-wiki
Jump to: navigation, search

Camera Control Example

Summary

Open, display and close each of the three available cameras [left_hand_camera, right_hand_camera, head_camera] with various settings.

Important Note: As of RSDK 1.1 opening and closing of cameras has changed. Due to 64-bit limitations with the Indigo Baxter's internal USB hub, we can only power on two cameras at once. Previously all cameras could be powered at the same time, but only two could be opened. To accommodate this extra restriction, in RSDK 1.1, closing a camera will also turn power OFF to that camera, and turn power ON to both of Baxter's other cameras. You can turn power OFF to any camera by closing that camera (regardless of whether that camera was actually open or closed previously). Closing another camera is a good way to ensure power is ON on a camera that you are interested in viewing before actually opening it.

Quickstart

Close a camera you are not interested in viewing to enable power to your camera of interest. Let's say you want to view the head_camera. From an RSDK terminal session, close either the left_camera or right_camera, list the powered cameras, and open the head_camera:

    $ rosrun baxter_tools camera_control.py -l
    left_hand_camera  -  (open)
    right_hand_camera  -  (open)
    $ rosrun baxter_tools camera_control.py -c right_hand_camera
    $ rosrun baxter_tools camera_control.py -l
    left_hand_camera  -  (open)
    head_camera  -  (closed)

We see that closing the right_hand_camera has powered it off, removed it from the ROS service list, and turned on power to the head_camera but not opened the head_camera. To open the head_camera at the maximum frame height and width:

    $ rosrun baxter_tools camera_control.py -o head_camera -r 1280x800
    $ rosrun baxter_tools camera_control.py -l
    left_hand_camera  -  (open)
    head_camera  -  (open)

We can now view the camera feed, ex:

    $ rosrun image_view image_view image:=/cameras/head_camera/image

The left_hand_camera will then be displayed using the image_view tool.

Overview

There are three cameras available local to Baxter. A single camera is located in either of Baxter's hands, the 'left_hand_camera' and the 'right_hand_camera'. A third camera is available on Baxter's head, described as 'head_camera'. This example shows usage for listing available cameras, opening each of the three cameras with various parameters, and closing the cameras.

Important Note: Due to limited bandwidth capabilities only two cameras can be operating simultaneously. Starting a camera while both of the other cameras are in operation will result in an error, and the camera will not open.

Important Note: Default behavior on Baxter startup is for both of the hand cameras to be in operation at a resolution of 320x200 at a framerate of 25 fps.

Supported Frame Size Modes: Frame sizes at which the cameras will operate.

  • 1280x800
  • 960x600
  • 640x400
  • 480x300
  • 384x240
  • 320x200

If given an unsupported frame size, this example will exit with the ValueError: Invalid Camera mode.

For more information on Baxter's cameras, see Using the Cameras.


Usage

See the camera controller's usage on the command line by passing camera_controller.py the -h, help argument:

    $ rosrun baxter_tools camera_control.py -h

Usage:

camera_control.py [-h] [-o CAMERA] [-c CAMERA] [-r RESOLUTION XxY] [-l]

Optional Arguments

 -h, --help                  This screen    
 -o, --open [CAMERA]         Open specified camera    
 -c, --close [CAMERA]        Close specified camera    
 -r, --resolution [X]x[Y]    Set camera resolution    
 -l, --list                  List available cameras    

Interfaces

ROS APIs

See the API Reference page for details.

  • List Available Cameras Service: /cameras/list
  • Open a Specified Camera Service : /cameras/open {name: <camera_name>, settings: {<optional settings>}}
  • Close a Specified Camera Service: /cameras/close <camera_name>

baxter_interface APIs

Detailed Walkthrough

This section will described in more detail the usage of the Camera Control Example.


List all of the available cameras RSDK terminal session, ex:

    $ rosrun baxter_tools camera_control.py -l

The output should two of Baxter's cameras:
Cameras:
left_hand_camera
right_hand_camera
Close a camera that will not be used, and list the new set of cameras to be opened:

    $ rosrun baxter_tools camera_control.py -c left_hand_camera

The reason that we are closing a camera that will not be used is to avoid the above important note above describing the constraint that only two cameras can be operated simultaneously. List the cameras currently powered now that the left_hand_camera was closed.

    $ rosrun baxter_tools camera_control.py -l

The output should show power rotated to Baxter's head camera: Cameras: right_hand_camera head_camera Now lets open one of these cameras with default settings:

    $ rosrun baxter_tools camera_control.py -o right_hand_camera

Verify that our camera has opened using the image_view tool:

    $ rosrun image_view image_view image:=/cameras/right_hand_camera/image

You should see the right_hand_camera operating at a frame size of 1280x800.

Echo the describing camera_info topic:

    $ rostopic echo /cameras/right_hand_camera/camera_info

This topic is used by tools such as rviz. It contains camera calibration and operational parameters. Because of discrepancies between rviz and other camera tools such as image_proc regarding the format of the camera_info topic, we have created descriptions satisfying both formats. camera_info - rviz expected format camera_info_std - image pipeline expected format.

View the camera feed in rviz:

    $ rosrun rviz rviz
  • Under the displays tab on the left hand side of rviz, change the 'Global Option - Fixed Frame' from '/map' to '/base'.
  • Select 'Add' in the displays tab of rviz.
  • Select 'Camera' display topic.
  • The 'Camera' topic will now be displayed in a new embedded window.
  • Under the 'Camera' tab on the left display window, choose the 'Image Topic': /cameras/right_hand_camera/image

You should now see the right_hand_camera image in the embedded camera window. Other data displayed in rviz will also be projected onto this image accordingly (ie. turning on the 'RobotModel' display, and moving the right arm to point at the left arm will display the 'RobotModel' overlaid on your live video feed).

Close the right_hand_camera:

    $ rosrun baxter_tools camera_control.py -c right_hand_camera

Open the image_view tool as we prepare to open the left_hand_camera at different resolutions:

    $ rosrun image_view image_view image:=/cameras/left_hand_camera/image

Create a second RSDK terminal session in another tab or window, and open the left_hand_camera at a different supported resolution:

    $ rosrun baxter_tools camera_control.py -o left_hand_camera -r 1280x800

You should now see the live camera feed in your image_view display. Change to different resolutions:

    $ rosrun baxter_tools camera_control.py -o left_hand_camera -r 640x400
    $ rosrun baxter_tools camera_control.py -o left_hand_camera -r 320x200
    $ rosrun baxter_tools camera_control.py -o left_hand_camera -r 960x600

Troubleshooting

For common issues specific to using the camera control example with Baxter, check out the Troubleshooting page.