-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Gazebo freezing if YARP_CLOCK is set #537
Conversation
Fix #526 Add also regression test for the issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
I only added few comments regarding a typo and a potential missing sentence in the code comments
plugins/clock/src/Clock.cc
Outdated
m_network = new yarp::os::Network(); | ||
// To avoid deadlock during initialation if YARP_CLOCK is set, | ||
// if the YARP network is not initialized we always initialize | ||
// it with system clock, and then we |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that here the sentence in the comment is truncated.
plugins/clock/src/Clock.cc
Outdated
@@ -68,7 +68,20 @@ namespace gazebo | |||
|
|||
void GazeboYarpClock::Load(int _argc, char **_argv) | |||
{ | |||
m_network = new yarp::os::Network(); | |||
// To avoid deadlock during initialation if YARP_CLOCK is set, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change:
initialation -> initialization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, feel free to do this suggestions with GitHub's integrated system!
Fine with me! |
Fix #526 .
TL;DR: From gazebo-yarp-plugins 3.6.0, you can again set YARP_CLOCK for the Gazebo simulation, meaning that all the threads of YARP Network Wrapper Servers will be executed with the frequency correctly synchronized with the Gazebo simulation. This also means that if you like you can also set
YARP_CLOCK
directly in your.bashrc
orsetup.sh
script.With respect to the solution discussed in #526, i.e. :
in this PR there are two modifications.
First of all, the delayed initialization of the Clock is only done if the yarp::os::Network is not initialized, and this is checked by the
yarp::os::NetworkBase::isNetworkInitialized()
method. Secondly, callingyarp::os::Network::useNetworkClock
does not only need the/clock
port to exists, but also wait until something is published on that port and the NetworkClock becomes valid (see useNetworkClock). For this reason, callinguseNetworkClock
in the Gazebo Physics thread is going to deadlock, as the Gazebo physics thread is also the one that is publish the new time on the clock. To avoid this, theyarp::os::Network::useNetworkClock
is called as part of newstd::thread
that is just created for this.The PR also contains a regression test for the issue, that was failing before the fix. As the issue was quite related to the inner working of YARP, it was not use
NetworkBase::setLocalMode
as in the robotinterface and controlboard tests, but rather yarpserver is actually launched before the tests by usingtiny-process-library
.