0
$\begingroup$

Rosanswers logo

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.


Originally posted by Teo on ROS Answers with karma: 1 on 2016-10-03

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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>
...

Originally posted by jayess with karma: 6155 on 2017-08-14

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.