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

rviz 2D nav goal change topic

asked 2016-10-03 09:56:15 -0500

Teo gravatar image

updated 2016-10-04 02:44:27 -0500

Hi all,

I'm developing a GUI with qtcreator for making more usable a ros program that use rviz.

I've implemented an rviz::VisualizationFrame that works fine and i can use rviz tools without problems.

Now i've created some button into a qt frame to export externally some default rviz tools from the VisualizationFrame toolbar, because I want to load a configuration that only show the rendering panel and the menubar.

All tools work fine except for the 2D nav goal, because when I instance it, it change topic from "move_base_simple/goal" to "goal".

That's an example how I instance my tools:

    rviz::VisualizationFrame* vis_frame = new rviz::VisualizationFrame;
    vis_frame->initialize();

    rviz::VisualizationManager* manager = vis_frame->getManager();

    rviz::ToolManager* tool_man = manager->getToolManager();

    //removing tools form toolbar
    tool_man->removeAll();

    rviz::Tool* interact_tool;
    rviz::Tool* nav_goal_tool;
    rviz::Tool* initial_pose_tool;

    //method "addTool" return "Tool*"
    interact_tool = tool_man->addTool("rviz/Interact");
    nav_goal_tool = tool_man->addTool("rviz/SetGoal");
    initial_pose_tool = tool_man->addTool("rviz/SetInitialPose");

Is there a way to change the setGoal tool topic from code? (I can't find a way to do it).

There is another way to instance tools without removing them from toolbar (in this case it works), for example:

nav_goal_tool = tool_man->getTool(6); //the number specify the tool index

The problem is that the tool index can change if I choose a different confinguration when I initialize rviz.

Thanks in advance for your help.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2017-08-14 18:29:47 -0500

jayess gravatar image

I haven't looked into how to do this with code, but you can set it from an rviz config file. So, if you can, read in the config file and set the topic name from there. Here's an example of the portion of the config file:

Visualization Manager:
...
  Tools:
    - Class: rviz/SetGoal
      Topic: /<custom>/<topic>/<name>
...
edit flag offensive delete link more
0

answered 2018-07-15 07:08:26 -0500

RuiJCS gravatar image

This is an answer for ROS indigo you may have a different experience if you're using a different ROS. Hi there this comes a bit late however for future references here comes a solution. I came by the same problem and reading the documentation at the rviz cpp website was able to reach this code:

tm_ = manager_->getToolManager();
rviz::Config c;
tm_->getTool(4)->save(c);
c.mapSetValue("Topic",QVariant("/move_base_simple/goal"));
tm_->getTool(4)->load(c);

Basically this gets the ToolManager (tm_) for the VizualizatioManager (manager_) we want to edit in order to get the tool we want, which is the GoalTool. Once we have the GoalTool we get its configuration in order to edit it the Key "Topic" in the config map to "/move_base_simple/goal". Finally we load the altered configuration to the tool we desire, in this case the GoalTool.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2016-10-03 09:56:15 -0500

Seen: 1,976 times

Last updated: Aug 14 '17