Running camera node without specifying serial causes crash
Closed this issue ยท 3 comments
When I run the camera node (or nodelet) without specifying the serial number, rosrun ensenso_camera ensenso_camera_node
, I get a crash (segmentation fault)
Looking at the code, the error starts here:
// No serial specified. Try to use the first camera in the tree.
NxLibItem cameras = NxLibItem()[itmCameras][itmBySerialNo];
if (cameras.count() > 0)
{
serial = cameras[0].name();
}
In my item tree, I have no itmBySerialNo
:
and so serial
is actually assigned to byEepromId
. The crash then happens here:
std::string type = NxLibItem()[itmCameras][itmBySerialNo][serial][itmType].asString();
Perhaps this the BySerialNo
was removed in the upgrade to 2.3?
Workaround
Specify the serial
parameter explicitly, don't rely on auto-selection.
System
- Ubuntu 18.04.03
- Ensenso SDK 2.3.1174
On a separate note, hats off to the Ensenso team for creating this package and open sourcing it! Really helpful for us! ๐ โค๏ธ ๐
Hello jornb,
Thanks for your feedback and also the debugging, I really appreciate it!
Yes, since the 2.3.x versions of the EnsensoSDK we removed the itmBySerialNo
constant. If you use it, it does still work. With the 2.3. version this is now just a link to the itmCameras
node.
So if you use
NxLibItem cameras = NxLibItem()[itmCameras][itmBySerialNo];
it is the same as
NxLibItem cameras = NxLibItem()[itmCameras]
.
The crash itself happens, because in the Cameras node the ByEepromId subnode comes first in alphabetical order. So the ByEepromId is accessed, which does not contain any children nodes accessed by
std::string type = NxLibItem()[itmCameras][itmBySerialNo][serial][itmType].asString();
and throws a NxLibException, which is not handled currently.
I want to emphasize that I really love your kind of ticket as it makes debugging very easy for us!
Best Regards
Yasin
Thanks for the quick fix!