robotology / gym-ignition

Framework for developing OpenAI Gym robotics environments simulated with Ignition Gazebo
https://robotology.github.io/gym-ignition
GNU Lesser General Public License v3.0
231 stars 26 forks source link

When inserting multiple robots, few models are only partially loaded #103

Closed diegoferigo closed 4 years ago

diegoferigo commented 4 years ago

I am experiencing a quite strange behaviour when adding multiple (complex) models in a single simulation. In few cases (on average 2/3 models over 10 totally) the recognized joints are not complete. For examples, models with 41 joints would show only 25. When this happens, the numbers are consistent and do not change.

The culprit is this function call, that for some reason fails to find all the joints:

https://github.com/robotology/gym-ignition/blob/86a77cc9ea02ec61a5f16ce44ba5d6fb83b9a11a/ignition/src/IgnitionRobot.cpp#L199-L214

I already checked and it seems that, when inserting the model in the ECM in the first place, the entities and components are all there:

https://github.com/robotology/gym-ignition/blob/86a77cc9ea02ec61a5f16ce44ba5d6fb83b9a11a/ignition/src/GazeboWrapper.cpp#L605-L606

What's strange in that the above method of the IgnitionRobot class is called just few lines after the creation of entities and components, in:

https://github.com/robotology/gym-ignition/blob/86a77cc9ea02ec61a5f16ce44ba5d6fb83b9a11a/ignition/src/GazeboWrapper.cpp#L639-L643

diegoferigo commented 4 years ago

Note: during the first debugging round I did, I found that the following lock was misused and it should be initialized outside the if to be useful. Though, this is not the problem.

https://github.com/robotology/gym-ignition/blob/86a77cc9ea02ec61a5f16ce44ba5d6fb83b9a11a/ignition/src/GazeboWrapper.cpp#L602-L603

diegoferigo commented 4 years ago

Fixed via https://github.com/robotology/gym-ignition/pull/111