|Note: This tutorial assumes that you have completed the previous tutorials: ROS tutorials.|
|Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.|
How to Configure and Use the WGE100 CameraDescription: This tutorial is an introduction to using the WGE100 camera connected to a desktop. After reading it you should be able to bring up the WGE100 camera, configure the camera, and display the images.
Keywords: camera, ethernet, driver, wge100
Tutorial Level: BEGINNER
Start by getting the dependencies and compiling the driver.
$ rosdep install wge100_camera $ rosmake wge100_camera
Powered On and Plugged in
Make sure that your WGE100 camera is powered at 12V and connected to an Ethernet port on your computer using the cables provided by Willow Garage. You should have a green flashing light like below.
Making Sure the Network is Configured for IPv4 Networking
Before you can find a camera on the network, the network adapter to which the camera is connected must be configured for IPv4 networking. In many cases this will be done already, so try skipping to the next section of this tutorial, and come back here if the discover command can't find your camera.
Configuring a network interface is beyond the scope of this tutorial. The following tips may allow you to get started, but may get you in trouble with your network administrator. Moreover, the setup you get by following these tips will not persist when the computer is rebooted.
On Linux, to check that an interface is configured for IPv4 networking, use the ifconfig command. For example if your camera is connected to eth2, do:
$ ifconfig eth2 eth2 Link encap:Ethernet HWaddr 00:50:b6:03:f4:60 inet6 addr: fe80::250:b6ff:fe03:f460/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:6 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:492 (492.0 B)
In this case, the Ethernet interface has an inet6 addr, but no inet addr, so it is not configured for IPv4 networking.
We can give the interface an IPv4 address with the following command (this address probably won't get you in trouble):
$ sudo ifconfig eth2 192.168.123.1 netmask 255.255.255.0
Now we can check that the interface does indeed have an inet addr:
$ ifconfig eth2 eth2 Link encap:Ethernet HWaddr 00:50:b6:03:f4:60 inet addr:192.168.123.1 Bcast:192.168.123.255 Mask:255.255.255.0 inet6 addr: fe80::250:b6ff:fe03:f460/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:20 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:3641 (3.5 KB)
Finding the Camera on the Network
Use the discover utility to find the camera:
$ rosrun wge100_camera discover
Found camera serial://13 name://test MAC: 00:24:cd:00:00:83 iface: eth2 current IP: 10.0.1.123, PCB rev: C HDL rev: 400 FW rev: 119 Found camera serial://15 name://cam15 MAC: 00:24:cd:00:00:86 iface: eth1 current IP: 10.0.1.125, PCB rev: C HDL rev: 400 FW rev: 119
When discover reports multiple cameras, you can figure out which one is yours by its serial number (written on the back of the camera), by its name, when the name has been set to a descriptive value, or by the interface it is connected to.
Understanding Camera URLs
The tools that work with the WGE100 camera expect to be given a camera URL that tells them which camera to work with, and how to talk to that camera. There are three types of URLs:
name://camera_name[@camera_ip][#local_interface] serial://serial_number[@camera_ip][#local_interface] any://[@camera_ip][#local_interface]
(e.g. name://camera_name, serial://email@example.com, or any://@192.168.0.23#eth2)
A name:// URL identifies the camera by a descriptive name that was given to it, and that is reported by the discover utility. We will see shortly how to set the name. A serial:// URL identifies a camera by its serial number. Finally, the any:// URL will match any camera. In some cases a URL may match many cameras. If that happens, the WGE100 camera tools will refuse to work, and you will have to use a different non-ambiguous URL. For example, you cannot use the any:// URL if there are two cameras visible from your computer. You may be able to use any://#eth2 if only one of the cameras is on interface eth2, or you could use serial://13 to talk to the camera with serial number 13.
Your camera may have been configured with a default IP address. If that IP address is invalid on the network the camera is connected to, you will have to indicate the address for the camera to use in the camera URL. For example, in the examples above, camera 13 is configured to be at IP address 10.0.1.123, but the network interface eth2 it is connected to has an IP of 192.168.123.1. To talk to the camera, you will have to give it an address that is valid for eth2. For example, you might use serial://firstname.lastname@example.org, which would tell a tool to access the camera with serial number 13, and have the camera use IP address 192.168.123.2.
In some cases it is useful to specify the interface over which the camera should be accessed. We have already seen how this can be used to disambiguate the any:// URL; it could also be used if more than one interface can see the camera and you want to access the camera via a specific interface.
For more information on Camera URLs see the wge100_camera main page
Configuring the Camera (optional)
We have just seen that a camera can be accessed using its default IP address, or using a temporary address indicated in its URL. If you are going to permanently set up a camera in a given network environment, you probably want to set its IP address once and for all, simplifying the URLs with which the camera is accessed. Likewise, you will probably want to give the camera a descriptive name rather than referring to it by serial number.
The set_name utility allows the camera's name and IP address to be set:
$ rosrun wge100_camera set_name Usage: set_name <camera_url> <new_name> <new_default_ip> # Sets the camera name and default IP set_name <camera_url> # Reads the camera name and default IP
Here is an example of configuring the camera:
$ rosrun wge100_camera set_name serial://email@example.com my_camera 192.168.123.10 Unable to create ARP entry (are you root?), continuing anyway Previous camera name was: test. Previous camera IP: 10.0.1.123. Success! Restarting camera, should take about 10 seconds to come back up after this.
Thereafter, you can access the camera via the URL name://my_camera, and the camera will be at IP address 192.168.123.10
On the PR2, you may have to set the interface to set the name of a camera:
rosrun wge100_camera set_name serial://180XXXX#lan0 forearm_l 10.68.0.41
If you don't use the "#lan0" syntax, you may see the error message "IP address configuration failed" if the robot tries to use the "lan1" network.
Launching the WGE100 Camera Node
Use the wge100_camera_demo.launch in the wge100_camera directory as an example configuration file. You will have to specify a camera url that the camera should communicate from in camera_url. If you want a tf frame to be associated with the camera, specify a frame_id.
$ roscd wge100_camera
Main fragment of wge100_camera_demo.launch:
<launch> <!-- The camera node --> <node name="wge100_camera_demo" pkg="wge100_camera" type="wge100_camera_node" output="screen"> <param name="camera_url" type="str" value="any://" /> <param name="imager_rate" type="double" value="25" /> <remap from="camera" to="wge100_demo" /> </node> </launch>
Once you have created the launch file:
$ roslaunch your_wge100_camera.launch
This will return something similar to:
[ INFO] 1251220032.176747000: Configured camera. Complete URLs: serial://firstname.lastname@example.org#eth2 name://email@example.com#eth2 [ INFO] 1251220032.250105000: Loaded intrinsics from camera [ INFO] 1251220032.253953000: Camera streaming.
If you see a warning that your camera intrinsics couldn't been loaded, don't worry. It means that your camera has never been calibrated. Refer to camera_calibration for instructions on calibrating a camera. Having an uncalibrated camera will not prevent progress through the rest of this tutorial.
You can verify that frames are streaming by running
rostopic hz wge100_camera_demo/image_raw
Viewing the WGE100 Camera Images
This will display images coming from the WGE100 camera.
First you will need to build image_view. In a new window, run:
$ rosmake image_view
Then you can use image_view to view the raw image stream:
$ rosrun image_view image_view image:=wge100_camera_demo/image_raw
If you have a color camera, the image will be black and white with a strange texture. This is because the image is being returned as a bayer pattern. You will have to use image_proc to convert it to a color image. First build image_proc:
$ rosmake image_proc
Then run image_proc:
ROS_NAMESPACE=wge100_camera_demo rosrun image_proc image_proc
With image_proc still running, open a new window and launch a viewer:
$ rosrun image_view image_view image:=wge100_camera_demo/image_color
You could run all these commands from a launch file if you like. Have a look at the commented example in wge100_camera_demo.launch to see how it is done:
$ rosed wge100_camera wge100_camera_demo.launch