AprilRobotics / apriltag_ros

A ROS wrapper of the AprilTag 3 visual fiducial detector
Other
377 stars 341 forks source link

Initialize detections_ with empty struct #125

Closed maximilianwulf closed 2 years ago

maximilianwulf commented 2 years ago

Maybe a special case of usage here, but

Running the node and not providing any input messages gives the following error when closing the node

^C[apriltag_ros_continuous_node-2] killing on exit
apriltag_ros_continuous_node: /tmp/binarydeb/ros-noetic-apriltag-3.2.0/common/zarray.h:132: zarray_size: Assertion `za != NULL' failed.

This is because in the constructor of the TagDetector

   detections_ = NULL;

The desctructor wants to destroy detections_ with

  apriltag_detections_destroy(detections_);

But zarray_size asserts if the pointer points to NULL.

Is it possible to initialize detections_ with something else than NULL ?

wxmerkt commented 2 years ago

Hi @maximilianwulf, Thank you very much for reporting this issue - I guess we haven't observed this since we rarely build in Debug mode. A simple check if detections_ is a valid pointer, i.e. if (detections_) apriltag_detections_destroy(detections_); might fix it?

maximilianwulf commented 2 years ago

Hi @wxmerkt, yes that should solve it. Do you want me to test and submit that issue?

wxmerkt commented 2 years ago

Yes, can you please test this and make a PR? Many thanks! :-)

maximilianwulf commented 2 years ago

https://github.com/AprilRobotics/apriltag_ros/pull/126