Open jrutgeer opened 1 year ago
I'm able to reproduce this, but not if I just run the server (gz sim -s -r optical_tactile_sensor_plugin.sdf
). It seems to be crashing when accessing depthCameraSdf.Element()
in https://github.com/gazebosim/gz-sim/blob/e007fa2c0b2e795ab1b74c75e48962b8dfacedba/src/systems/optical_tactile_plugin/OpticalTactilePlugin.cc#L561 but it's not clear to me how running the GUI causes the Element()
function to return nullptr
.
I noticed that it is not related to 'server only' but rather to the -r
flag:
This works:
$ gz sim -r optical_tactile_sensor_plugin.sdf
But without -r
flag, it crashes upon click of the start icon.
From what I've understood so far, the Element()
returns nullptr
because DepthCamera
has undergone a roundtrip serialization/deserialization process. This process is not able to retain the original ElementPtr
associated with the DepthCamera
SDFormat object because deserialization uses an SDFormat DOM object constructed programatically (i.e, not loaded from a file or string). The whole process is triggered when the play button is pressed:
https://github.com/gazebosim/gz-sim/blob/f55212eb271a2f2b4d726da45e3aaeebede3b1a2/src/gui/GuiRunner.cc#L181-L198.
I think the best solution is to remove any use of the ElementPtr
of the DepthCamera
component. It's only used for checking if certain SDFormat parameters have been manually set by the user. The actual values of the parameters can be obtained without using the ElementPtr
, so we won't be sacrificing functionality, but we'll lose nice error messages.
Environment
Description
Run the 'optical tactile plugin' demo world:
Start the simulation.
Instant crash.
I checked the sdf for missing or empty fields (e.g. an empty string such as
<namespace></namespace>
but I don't see anything incorrect.I also removed the build and install directory and recompiled, but that did also not resolve the issue.