Skip to content

Camera Control Example

Rob Linsalata edited this page Nov 21, 2013 · 1 revision

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.

Quickstart

Close all currently open cameras from an RSDK terminal session, ex:

    $ rosrun baxter_tools camera_control.py -c left_hand_camera
    $ rosrun baxter_tools camera_control.py -c right_hand_camera
    $ rosrun baxter_tools camera_control.py -c head_camera

Open the left_hand_camera at the maximum frame height and width, ex:

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

View the camera feed, ex:

    $ rosrun image_view image_view image:=/cameras/left_hand_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.

Verify that all cameras are closed from an RSDK terminal session, ex:

    $ rosrun baxter_tools camera_control.py -c left_hand_camera
    $ rosrun baxter_tools camera_control.py -c right_hand_camera
    $ rosrun baxter_tools camera_control.py -c head_camera

The reason that we are closing all of the cameras is to avoid the above important note above describing the constraint that only two cameras can be operated simultaneously.

List all of the available cameras:

    $ rosrun baxter_tools camera_control.py -l

The output should show all of Baxter's cameras:

Cameras:
head_camera
left_hand_camera
right_hand_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.

Clone this wiki locally