-
Couldn't load subscription status.
- Fork 342
Fix reset for rendering sensors #3102
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
base: gz-sim10
Are you sure you want to change the base?
Conversation
In the case where objects are spawned after simulation has started and a Reset occurs, the Sensors system was failing to remove the spawned objects. Subsequent attempts to respawn the same objects also fail because they are likely to be assigned the same Entity IDs. The thing to note here is that the `EachNew` and `EachRemoved` function of the ECM have to be called from the Reset handler, since the newly created/removed entities are cleared by the next PreUpdate. Signed-off-by: Addisu Z. Taddese <[email protected]>
|
Any chance we can get a regression test for this? |
| (this->dataPtr->updateTimeToApply == | ||
| this->dataPtr->updateTimeApplied); | ||
| }); | ||
| this->dataPtr->renderUtil.UpdateFromECM(_info, _ecm); |
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.
I arrived at a very similar fix. I had this call inside the mutex lock block a few lines above, i.e.
std::unique_lock<std::mutex> lock2(this->dataPtr->renderUtilMutex);
this->dataPtr->updateTime = _info.simTime;
this->dataPtr->updateTimeToApply = _info.simTime;
this->dataPtr->updateTimeApplied = _info.simTime;
this->dataPtr->renderUtil.UpdateFromECM(_info, _ecm);but want to check, does this need to be in a separate block with the wait condition?
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.
I'm not 100% sure. Did it work for you? I saw the comment
gz-sim/src/systems/sensors/Sensors.cc
Lines 974 to 980 in 7374a6c
| GZ_PROFILE("UpdateFromECM"); | |
| // Make sure we do not override the state in renderUtil if there are | |
| // still ECM changes that still need to be propagated to the scene, | |
| // i.e. wait until renderUtil.Update(), has taken place in the | |
| // rendering thread | |
| std::unique_lock<std::mutex> lock(this->dataPtr->renderUtilMutex); | |
| this->dataPtr->updateTimeCv.wait(lock, [this]() |
which made me think it was necessary.
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.
yeah it worked for me.
My thinking is that we could just override the state in renderUtil without waiting for any pending updates (updates from before the reset) to be applied because it's going to be reset to the initial state anyway.
🦟 Bug fix
Summary
In the case where objects are spawned after simulation has started and a Reset occurs, the Sensors system was failing to remove the spawned objects. Subsequent attempts to respawn the same objects also fail because they are likely to be assigned the same Entity IDs.
The thing to note here is that the
EachNewandEachRemovedfunction of the ECM have to be called from the Reset handler, since the newly created/removed entities are cleared by the next PreUpdate.TODO:
Checklist
codecheckpassed (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-byandGenerated-bymessages.🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸