Gazebo | Ignition | Community
Ask Your Question

Gazebo Topics disappear

asked 2014-11-18 18:09:39 -0500

NickDP gravatar image

I am trying to control a robot in Gazebo through the messaging system. For this I have a model plugin and four different topics. The model plugin subscribes to two of the topics and advertises on the other two. This works fine for one robot.

Now I want to do this with more than one robot in one world. I.e. I want to have two robot models in Gazebo, each with a model plugin and each with its own set of topics.

The problem I have is that some of the topics I create for the first robot seem to disappear once I create the topics for the second robot.

For each robot I create an instance of a controller class that subscribes and advertises to topics (which are named based on the robots' names). After the constructor for the first robot is done, I can see all four topics by opening the Gazebo Topic selector window (Ctrl + T). If I then let the constructor of the second constructor run, two of the four topics of the first robot are no longer listed in the Gazebo Topic selector window. Specifically, the topics that the model plugin subscribes to (i.e. the ones that are advertised in the controller class) disappear.

One thing that I could see being a problem is that each controller object has its own node, i.e. the constructor does

gazebo::transport::NodePtr node(new gazebo::transport::Node());

Is it a problem that the don't both use the same node? If so, how should I avoid this? Otherwise, what else could be the problem?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-11-19 12:52:35 -0500

NickDP gravatar image

I have figured out a solution.

The problem was that both controllers called

gazebo::setupClient(0, NULL);

in their constructors.

It appears that this has to be called exactly once, so I have to take it out of the controller's constructor and call it manually in my main().

edit flag offensive delete link more


P.S.: The documentation says setupClient() starts a Gazebo client. However, I still have to do gazebo in a terminal to actually start Gazebo. Is this the intended behavior?

NickDP gravatar imageNickDP ( 2014-11-19 12:54:45 -0500 )edit

You are running gazebo with a few plugins in one process, and in a separate process a set of controllers, correct? If all the controllers run in one process, then you are correct that you should only call gazebo::setupClient once.

nkoenig gravatar imagenkoenig ( 2014-11-20 14:49:26 -0500 )edit

A gazebo client is just a process that connects to a gazebo server. A client can be anyting (GUI, command line program, etc). A client relies on gzserver or gazebo running.

nkoenig gravatar imagenkoenig ( 2014-11-20 14:51:04 -0500 )edit

Correct, that's what I've been doing. But with all the message passing, the simulation is very slow. That's why I'm looking into running Gazebo as a library in the hopes that simulation will be faster.

NickDP gravatar imageNickDP ( 2014-11-20 15:19:35 -0500 )edit

answered 2014-11-19 12:24:14 -0500

nkoenig gravatar image

Using two separate nodes is good.

Can you try running the command line tool

gz topic -l

to list the topics? If it works, then we have a problem with the GUI.

Also, can you send and receive messages from both nodes even if the topics are not listed?

edit flag offensive delete link more


Thanks for the reply. The way I noticed the problem was that the messages were not being sent/received. I actually figured out the solution to my problem (see my answer). Now I can see all the topics both in the Topic selector window and using gz topic -l.

NickDP gravatar imageNickDP ( 2014-11-19 12:53:19 -0500 )edit

Question Tools


Asked: 2014-11-18 18:09:39 -0500

Seen: 567 times

Last updated: Nov 19 '14