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

Unable to display Interactive Marker in custom QWidget

asked 2016-11-08 05:12:27 -0500

ghkraju gravatar image

updated 2016-11-08 08:21:20 -0500

Hi, I am using basic_controls tutorial to display Interactive Markers. It works fine for rViz whereas in my custom QWidget, I can able to visualize the Marker::MESH_RESOURCE but I can't interact with the mesh resource since the InteractiveMarkerControl is not visible. If i change the position in rViz then the same is updated in my QWidget but I can't change directly in QWidget.

Following snippet I have used to display the Interactive Marker:

obj_ = manager_->createDisplay( "rviz/InteractiveMarkers", "Obj Loader", true );

obj_->subProp("Reference Frame")->setValue("base_link");

obj_->subProp("Update Topic")->setValue("/basic_controls/update");

EDIT 1:

I got some more info as follows:

~/rviz-kinetic-devel$ rostopic info /basic_controls/feedback

Type: visualization_msgs/InteractiveMarkerFeedback

Publishers: * /rviz ( http://xxxx:39181/ )

Subscribers: * /point_cloud_publisher ( http://xxxx:40431/ )

Basically here rviz is publishing the feedback. I have to figure out how can I publish the feedback from QWidget.

Any ideas on this topic?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-11-08 17:32:51 -0500

huanxiner gravatar image

I have always wondered if this is doable myself, so I just spent some time to figure it out. Turned out that InteractiveMarker requires not only the display, but also the 'tool' to enable interaction. The following code is developed based on your snippet.

  rviz::Display *obj_ = visualization_manager_->createDisplay( "rviz/InteractiveMarkers", "Obj Loader", true );
  obj_->subProp("Reference Frame")->setValue("base_link"); // This probably works by itself, I added the next line just in case
  visualization_manager_->setFixedFrame("base_link");
  obj_->subProp("Update Topic")->setValue("/basic_controls/update");
  obj_->initialize(visualization_manager_);
  obj_->setEnabled(true);

  rviz::ToolManager *tool_manager = visualization_manager_->getToolManager();
  tool_manager->initialize();
  rviz::Tool *interact_tool = tool_manager->addTool( "rviz/Interact" );
  tool_manager->setCurrentTool(interact_tool);
  ROS_ASSERT(obj_);

You will need to include rviz/tool_manager.h somewhere.

edit flag offensive delete link more

Comments

Cooooool..... You made my day. Thank you soooo much. It works like a charm.

ghkraju gravatar image ghkraju  ( 2016-11-08 18:21:11 -0500 )edit

May I know, How could you actually figure out that connection(InteractiveMarker needs both Display and ToolManager)? I am little bit curious abt it bcz I was going through the source code for almost a day.

ghkraju gravatar image ghkraju  ( 2016-11-08 18:25:57 -0500 )edit

Glad it helps :) I did quite a bit digging in the source code as well. Since interactive marker requires mouse event handling and stuff, I suspected display by itself is not enough. Then I looked into how rviz is implemented, and found this interactionTool in the default plugin.

huanxiner gravatar image huanxiner  ( 2016-11-08 19:21:22 -0500 )edit

Okay, Thank you for your time.

ghkraju gravatar image ghkraju  ( 2016-11-08 19:40:57 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2016-11-08 05:12:27 -0500

Seen: 511 times

Last updated: Nov 08 '16