Closed traversaro closed 1 month ago
I consider adding tests for this, but the race condition that results in errors such as:
ODE INTERNAL ERROR 1: assertion "!colliders_initialized" failed in dInitColliders() [collision_kernel.cpp:168]
is extremely complex to reproduce (I was able to do so just with apt dependencies and in Debug mode) so I am not sure it is useful to try to reproduce this in a test.
🦟 Bug fix
Summary
This is done to avoid that non-thread-safe ODE functions are called at the same time, causing errors such as
Why this happens? As the
GzOdeCollisionDetector
constructor calls the DART'sOdeCollisionDetector
constructor, that instead calls the non-thread-safedInitODE2(0)
ode function. IfdInitODE2(0)
is called at different times, everything seems to be working fine, so we enforce this by adding a static std::mutex in theGzOdeCollisionDetector::create
.This fixes part of https://github.com/gazebosim/gz-sim/issues/18 . Note that this does not solve all the ODE-related multi-threading problems, but at least allows to set a different collision manager without having errors such as:
That happens as
GzOdeCollisionDetector
is allocated before the requested collision detector is set byWorldFeatures::SetWorldCollisionDetector
, so it is not possible to avoid to construct`GzOdeCollisionDetector
by specifying a custom collision detector in the SDF, unless we want to change the default collision detector, that is something we want to avoid (at least at the moment) as discussed in https://github.com/gazebosim/gz-sim/issues/18 .Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.