remote_lab: interactive_marker_client | mjpeg_server | ping | pointcloud_snapshot_service | pr2_pick_and_place_service | robot_booking | rosjs_assisted_teleoperation | rosjs_common | rosjs_pr2interaction | rosjs_remotelabwidgets | rosjs_resources | rosjs_tests | rosjs_tutorials | rosjs_visualization | tf_lister | topic_logger | turtlebot_wviz | wviz | wviz_kinematic_manager | wviz_scene_manager | wviz_tf_manager

Package Summary

A node that provides a mjpeg server which is able to subscribe to any ros image stream.

Overview

A natural means of interacting with and checking upon the progress of the robot is through video. MJPEGs, or motion JPEGs, are a file format in which each frame of a video stream is separately compressed as a JPEG image. The mjpeg_server is streaming server that subscribes to requested image topics in ROS and publishes those topics as MJPEG streams via HTTP to a web browser. While rosjs is capable of streaming video, as it is just another message type from ROS, the web browser is optimized to efficiently download images in binary format. Thus for increased performance benefits this additional communication channel is used. In order to deal with a user’s specific requirements the video streams can be provided at a desired quality and size to accommodate different connection speeds and interface designs.

Running the mjpeg_server node

In a new terminal, run the mjpeg_server:

$ rosrun mjpeg_server mjpeg_server

You will see something similar to:

[ INFO] [1300292044.245883681]: Starting mjpeg server
[ INFO] [1300292044.246300271]: Bind(8080) succeeded
[ INFO] [1300292044.246361548]: waiting for clients to connect

By default the mjpeg server serves streams on port 8080. If this port is already used by another process you will get the following error message:

bind: Address already in use
[ERROR] [1300292110.139864357]: Bind(8080) failed
[ INFO] [1300292110.219179888]: stop requested
[ INFO] [1300292110.219253312]: cleaning up ressources allocated by server thread

Instead of using the standard port 8080, you can set a different port on the command line when launching mjpeg_server, e.g.:

$ rosrun mjpeg_server mjpeg_server _port:=8181

Accessing the mjpeg stream using a web browser

The mjpeg stream can be viewed by any current browser. If the mjpeg_server runs on the local machine you can access the stream using the following URL:

http://localhost:8080/stream?topic=/IMAGE_TOPIC

Here, /IMAGE_TOPIC is a ROS topic generated by the image_transport module, e.g. /wide_stereo/left/image_color in case you are using a PR2. Here is what it should look like in the browser:

mjpeg stream displayed in a browser

Single image snapshots

Instead of displaying a stream of images it is also possible to display a single image snapshot. The URL for snapshots is:

http://localhost:8080/snapshot?topic=/IMAGE_TOPIC

Display parameters

The image stream can be configured by several parameters. The parameters are added to the URL according to the URI scheme:

http://localhost:8080/stream?topic=/IMAGE_TOPIC?param1=value1?param2=value2?param3=value3

Currently the following parameters are available:

width (integer, default: original width)

  • The image stream will be resized to a new width and height. This parameter has to be used in conjunction with the height parameter.
height (integer, default: original height)
  • The image stream will be resized to a new width and height. This parameter has to be used in conjunction with the height parameter.
quality (integer, default: 90)
  • The jpeg image quality (1...100). This parameter can be used to reduce the size of the resulting mjpeg stream.
invert (none, default: )
  • Rotates the image by 180 degrees before streaming.

The following example shows a resized version of an image stream:

  • reduced size stream displayed in a browser

Wiki: mjpeg_server (last edited 2011-06-10 19:06:12 by BenjaminPitzer)