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

Set RViz camera/view on fuerte

asked 2013-02-25 20:48:22 -0500

Josch gravatar image

updated 2013-03-07 00:49:28 -0500

Hi,

I'm writing a RViz plugin which allows the user to play rosbags and record them. During playing the rosbags I would like to make it possible to do a tracking shot in the scene. Therefore I have to set the current view in RViz.

Is there a possibility to do this programmatically?

There are some articles which say it is possible with a RViz plugin, but it's never explained anywhere. If it is not possible in a single plugin, is it possible via librviz?

Thanks in advance, best regards, Josch.

EDIT: The node should run on fuerte and Ubuntu 12.04 LTS.

EDIT 2: New question: How do I get an instance from the VisualizationManager? Creating my own one requires a RenderPanel and a WindowManagerInterface-implementing class.

edit retag flag offensive close merge delete

Comments

1

Hi, please mention your ROS version, and your ubuntu distribution. If you are in Groovy, I guess what you want already exist partly in the package rqt. Bests, Steph

Stephane.M gravatar image Stephane.M  ( 2013-02-25 21:34:17 -0500 )edit

Hi, thanks for your answer. I added the versions to my post. What features from rqt do you think could help me?

Josch gravatar image Josch  ( 2013-02-25 21:39:23 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
6

answered 2013-02-26 05:17:12 -0500

dgossow gravatar image

updated 2013-02-27 18:33:32 -0500

There are multiple options:

  • Add a specialized view controller to your plugin (the most powerful option)
  • Use the animated view controller plugin to control the camera via ROS messages (not released yet): https://github.com/ros-visualization/rviz_animated_view_controller
  • Set the "target frame" to a special tf frame you create for that purpose
  • Use the C++ API (see VisualizationManager::getCurrentViewController, ViewController::setTargetFrame and ViewController:lookAt)

You will find more information in the tutorials and API docs via the ROS Wiki: http://www.ros.org/wiki/rviz

edit flag offensive delete link more

Comments

Thank you very much! When using the custom ViewController, how can I tell RViz to use that ViewController? And when using the C++ API, how can I get the current VisualizationManager? Are these static methods?

Using the target frame my orientation won't bind to the target frame's orientation. :-/

Josch gravatar image Josch  ( 2013-02-26 20:31:55 -0500 )edit
1

If your plugin is a Display, you can access the Visualization Manager via it's member vis_mananger_. Apart from that, the API docs on http://ros.org/doc/fuerte/api/rviz/html/index.html are an excellent reference and will hopefully answer your questions.

dgossow gravatar image dgossow  ( 2013-02-27 04:19:11 -0500 )edit

My plugin is a rviz::Panel plugin, but i just figured out it still has the vis_manager_ variable. Unfortunately it is not set during the hole runtime. Can I set the VisualizationManager and RViz will use it? Or can I get the original instance from somewhere?

Josch gravatar image Josch  ( 2013-03-04 01:20:47 -0500 )edit

Does somebody know if getting the instance from the VisualizationManager used by RViz is possible from an rviz::Panel plugin? Otherwise I will have to create a second plugin and do some service communication.

Josch gravatar image Josch  ( 2013-03-05 21:02:16 -0500 )edit
1

Panel::initialize populates vis_manager_ and then calls your onInitialize method: https://github.com/ros-visualization/rviz/blob/visualization-1.8/src/rviz/panel.cpp

dgossow gravatar image dgossow  ( 2013-03-06 04:15:36 -0500 )edit

Thank you again. So I have to call initialize, since it is obviously not called. But I need to pass a VisualizationManager to the initialize function. Therefore I have to create a vis_manager inststance, which requires a RenderPanel and a WindowManagerInterface-implementing class, am I correct?

Josch gravatar image Josch  ( 2013-03-06 20:29:51 -0500 )edit

I'm saying that because vis_manager_ accessing vis_manager_ in any way ended up in crashing RViz. So it must either be empty or not accessable from my classes.

Josch gravatar image Josch  ( 2013-03-06 20:44:16 -0500 )edit
2

You need to overwrite virtual void onInitialize() in you panel. Before that is called, vis_manager_ will not be initialized.

dgossow gravatar image dgossow  ( 2013-03-07 06:23:59 -0500 )edit
1

answered 2013-02-26 00:57:10 -0500

Calder gravatar image

I'm not aware of any functionality built into RViz directly to do this. Our lab has been working on-and-off on adding programmatic camera support and it (as far as we can tell) involves building a new view controller class and recompiling RViz. We hoped there would be a way to do it using plugins, but the only way to directly access the necessary Ogre camera object is using a special view controller.

edit flag offensive delete link more

Comments

Well I was afraid that it's not possible to access the view controller from RViz out of the box. Did you already try setting the camera view by publishing a transform to the target_frame topic? Or change the /world orientation to have the desired view?

Josch gravatar image Josch  ( 2013-02-26 01:10:32 -0500 )edit
1

That's the easy way to do it, but it doesn't work if the user manipulates the UI, since the user can still change the camera view by hand and you can't get the new view back to change the transform. If you access the underlying Ogre camera, you can get information on the current camera viewpoint.

Calder gravatar image Calder  ( 2013-02-26 08:51:00 -0500 )edit

I really want to try that, but how can I access the ViewController and Ogre camera from the render panel?

Josch gravatar image Josch  ( 2013-02-27 00:08:37 -0500 )edit
0

answered 2018-11-08 07:39:16 -0500

Razlaw gravatar image

For those who need a quick solution or lack a little experience, I've build an rqt plugin you can use as a starting point.
It allows to generate camera trajectories within rviz in a convenient way.
Be aware, that it was implemented for ros kinetic.

edit flag offensive delete link more

Question Tools

4 followers

Stats

Asked: 2013-02-25 20:48:22 -0500

Seen: 2,471 times

Last updated: Nov 08 '18