Destroy temporary command slot via Python API (NxLibRemote)

General Information

  • Product: X36-2CP
  • Serial Number: 229093
  • Ensenso SDK Version: 4.1.1033
  • Operating System: Ubuntu 24.04 LTS
  • ROS2 Jazzy

Problem / Question

Hi,

we are encountering an issue with a ROS2 node, where we are using the python API for calling PartFinder. It seems that during each computation cycle temporary command slots are continuously added until maximum unique count is reached. At that point the following exception occurs:

According to the changelog, this issue should have been fixed in version 3.4.743. So we are wondering, what are we doing wrong?
We are using the NxLibRemote class to interact with the remote NxLib instance (in this case a ROS2 node which initalizes the camera and capture images similar to: ros_driver/ensenso_camera/scripts/request_data at master · ensenso/ros_driver
Each call to NxLibCommand within a context manager seems to add an temporary slot:

Any suggestions would be greatly appreciated.

Thanks in advance!

Hello @matthias,

I suspect that the following happens:

  • At then end of the NxLibRemote block, the NxLibRemote context manager disconnects.
  • The cmdPartFinder variable is still alive at this point.
  • At the end of the function, cmdPartFinder is destroyed, but finds the connection closed, so it is unable to cleaned up its slot.

You can force deterministic and timely cleanup by using the NxLibCommand also as a context manager:

with NxLibRemote("127.0.0.1", 24001), NxLibCommand(CMD_PART_FINDER) as cmdPartFinder:
  ...

Hi Raphael,

thanks so much for your quick reply. It does indeed seem to be the issue you described. I tested your suggestion briefly, and in each computation cycle, only two temporary command slots are added - not five. But we’ll track down the leftover ones.

Best regards