Publish static image topic


You may need image topics to try recognition nodes/nodelets in jsk_perception, and this tutorial shows how to create image topic easily.

Step by step

For this purpose, you can use

terminal 1:

$ roscore

terminal 2:

$ rosrun jsk_perception \
  _file_name:=$(rospack find jsk_perception)/sample/kiva_pod_image_color.jpg _rate:=30

_file_name:=... and _rate:=... is remapping of rosparam and you can get the value with:

$ rosparam get /image_publisher/file_name

$ rosparam get /image_publisher/rate

The image is published to topic /image_publisher/output, so you can see it by:

$ rosrun image_view image_view image:=/image_publisher/output

image:=... is remaping of topic, and the image_view will subscribe /image_publisher/output in this case.

The result is as shown below:


A single command

You can run upper programs in a single command with writing roslaunch file:

$ # emacs tutorial_image_publisher.launch
$ vim tutorial_image_publisher.launch

Or you can download the file from:

  <node name="image_publisher"
        pkg="jsk_perception" type="">
    <param name="file_name" value="$(find jsk_perception)/sample/kiva_pod_image_color.jpg" type="str" />
    <param name="rate" value="30" type="int" />
    Below also works.
    See and for detail.
    <rosparam subst_value="true">
      file_name: $(find jsk_perception)/sample/kiva_pod_image_color.jpg
      rate: 30
  <node name="image_view"
        pkg="image_view" type="image_view">
    <remap from="image" to="/image_publisher/output" />
    Below works because image_publisher and image_view is in the same namespace.
    See for detail.
    <remap from="image" to="image_publisher/output" />

You can launch the roslaunch file by:

$ roslaunch ./tutorial_image_publisher.launch