Stopping simulation during computations / model swings up [closed]
I am using the update event mechanism to trigger my computations of additional forces in Gazebo, and I call the following line in the load function of my controller (which isn't really a controller, rather does compute simplified aerodynamics for a small blimp):
this->update_connection_ = event::Events::ConnectWorldUpdateStart(
boost::bind(&Blimp_FlightMechanics::UpdateChild, this));
In the UpdateChild()
method, I am doing all the computational stuff. This takes some time, I used ros::WallTime
to determine it. The problem is, I first read some model states, and then I do my math. When I want to apply the forces and torques, which can be seen as a response of the current model state, then some time is gone and the response isn't valid anymore. This effect swings up my model and leads to instability.
My question is: can I stop the simulation, read in the necessary state information, do the math, set the forces and then run the simulation again, until the next event alls my method UpdateChild()
? I guess, the answer is "yes", but I didn't found the programmatic tools to do so.
EDIT: I tried the command ros::Duration(sleep_time).sleep()
, but when using that, the simulation stops completely.
EDIT2: Using the command common::Time::MSleep(2)
works for now. But maybe some workaround for switching the simulation "off" and "on" again does exist anyway?