Robotics StackExchange | Archived questions

Gazebo as Master for Co-Simulation: Handling a large amount of models

Hi guys,

we are currently using Gazebo (version 7.9 and 8.3) as a co-simulation master.

By this, we use WorldPlugins in order to interface other simulation frameworks to receive information about the behavior of objects, which is determined by an external algorithm. The external algorithms typically are interfaced by a linked library via function call as well as using a network API to "talk" with the algorithm running as a separete process.

The WorldPlugin itself is responsible for spawning new models, updating their position, velocity,... and finally deleting the models, when they reach their lifetime. Therefore, we have registered a callback OnUpdate(), which is linked to the OnWorldUpdateBegin() event:

// Register update callback
m_update_connection = event::Events::ConnectWorldUpdateBegin(boost::bind(&Interface::OnUpdate, this, _1));

What we have recognized is, that the real-time factor (indicated by gzclient) seems to jump, if in a simulation step inside the OnUpdate() method several objects, let's say 2 or 3, are spawned and/or deleted. The spawning of objects is done via message passing:

msgs::Factory factory_msg;
msgs::Init(factory_msg, "spawn_model");
factory_msg.set_sdf(sdf_model_description);
msgs::Set(factory_msg.mutable_pose(), pose);
m_factory_pub->Publish(factory_msg);

It seems to need 1-2 additional cycles to spawn the object.

We remove a model using a direct function call provided by the WorldPtr

m_world->RemoveModel(model_identifier);

since message passing in the following way doesn't seem to work, at least with Gazebo 7.9:

msgs::Request *msg = msgs::CreateRequest("entity_delete", model_identifier);
m_request_pub->Publish(*msg);

Updating the models is done via setting their position: model->SetWorldPose(pose, true, true);

As said before, the model handling (which are static sdf models) is done in the OnUpdate() method. Typically we parametrize the simulation to run with 100 Hz and a step size of 0.01[ms] to achieve a 1*RT factor, which is sometimes hardly achievable, for example, when we administrate a lot of objects (> 100) or, when some objects seems to be spawned and deleted within one cycle.

Are there any known issues with administrating such an amount of objects? Can you suggest any optimizations for handling such amount of objects in Gazebo?

Asked by Illuminatur on 2018-03-26 13:22:57 UTC

Comments

Answers