ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
4

rqt custom imageView. Showing images from different cameras

asked 2015-01-13 05:30:12 -0600

Jose Luis gravatar image

updated 2015-01-15 11:30:36 -0600

130s gravatar image

Hi to all,

On several occasions I have created rqt plugins for monitoring different devices, and for interacting with robots graphically. In this occasion, i have a robot with eight video cameras and i want to visualize all of them in rqt. My idea is to create a menu in "Plugins", with a group named Cameras and within it, all the cameras of the robot. I mean:

Plugins
   |_ Cameras
          |_ Top_camera
          |_ Right_camera
          |_ Left_camera
          |_ ...

I already know that exists the image_view plugin for this type of things. But i need that an end user can choose between all of the cameras easily. When the user select, for example, Top_camera, it should appear an image_view screen with the current images of that camera. (In other words, i need an image_view with the image topic already selected. Totally transparent for the user).

Is possible to do this, reusing the already implemented image_view plugin?

I am modifying the plugin.xml file to launch multiple instances, unsuccessfully:

 <class name="rqt_image_view/ImageView" type="rqt_image_view::ImageView" base_class_type="rqt_gui_cpp::Plugin">
    <description>
       Cameras
    </description>
    <qtgui>

      <group>
        <label>Cameras</label>
        <icon type="theme">folder-new</icon>
      </group>

      <label>PTZ top</label>
      <icon type="theme">camera-photo</icon>
      <statustip>Great user interface.</statustip>
    </qtgui>
  </class>

I should need eight different image_view with the corresponding topic preselected. How can i do it?

Thank you very much in advance ;)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2015-01-19 09:25:42 -0600

Jose Luis gravatar image

Finally I have achieved that i want. I have followed the suggestions of @130s and I have added other things that were necessary.

Perhaps my solution is not the best one or there are another possibilities, but it works perfect.
To obtain a custom ImageView plugin for each camera, I have done the following:

  • I've copied the original code of imageView into my own package.
  • I've modified some lines in the code for getting the image topic that i want for each camera.
  • I've created one class for each camera. (This is necessary because you need to instantiate the classes in the "plugin.xml" file and the attribute must be different for each instance)
  • I only use one .ui file. All the classes are using the same file:
--- CMakelist.txt ---
    set(my_cameras_UIS  src/my_cameras/image_view.ui)
  • The main concept to understand is in plugin.xml:

image description

The Class name tag must be different for each instance.

I have obtained this:

image description

Hopefully this will be useful for others.

edit flag offensive delete link more

Comments

Instead of copying the code it would be much better to reuse the code of the existing plugin. If it does not provide the necessary API for that you might consider providing a pull request to enhance the existing plugin in a way that you can reuse it's functionality for you custom plugin.

Dirk Thomas gravatar image Dirk Thomas  ( 2015-01-19 14:16:06 -0600 )edit

I know what you say, is the best way to do this. But in this case, i needed a very concrete thing, with little changes in the code. It is not very reusable for others. I think that a pull request should be done with generic code.Thus, i have done it by this way.I appreciate your contribution, thanks

Jose Luis gravatar image Jose Luis  ( 2015-01-20 02:35:21 -0600 )edit
2

answered 2015-01-15 11:29:17 -0600

130s gravatar image

updated 2015-01-15 11:40:41 -0600

AFAIK there isn't a way to achieve what you want other than creating a custom rqt plugin on your own. This custom plugin, however, can be relatively low-cost.

Instead of explaining it in the answer thread, I just added a tutorial section for how to re-use exising (r)qt components.

In your particular scenario, I would do the following, in addition to general steps in the tutorial above:

  • In .ui, define the customwidget as many as you need using the right class from rqt_image_view. Differentiate each instance by name attribute (as instructed in the tutorial).
  • In the program, specify which image topics should go to which image_view instance.

Hope the this makes sense, along with the tutorial just added.


Update) @Wolf opened another thread http://answers.ros.org/question/20106... where a simpler workaround is referenced.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2015-01-13 05:30:12 -0600

Seen: 4,182 times

Last updated: Jan 19 '15