dusty-nv / ros_deep_learning

Deep learning inference nodes for ROS / ROS2 with support for NVIDIA Jetson and TensorRT
862 stars 258 forks source link

Not a bug persay but a question! #126

Open bulldogc opened 1 year ago

bulldogc commented 1 year ago

I have a custom node to receive the outgoing detections topic and would like to display the detection IDs and confidence. I was able to output hypothesis.class_id and .score to do this but the ID is not the real text ID but instead (I assume?) the internal network ID. Based on the detectnet code I assume I am suppose to call GetModelPath, but that requires setting up a full detectNet object on the receiving node. Seems like this subscriber node shouldn't care about the network at all if all it wants is the data hat the node is spitting out. Am i missing something in the message structure that stores the plain text objects? OR is there a better way to convert the coded object id to plain text?

dusty-nv commented 1 year ago

Hi @bulldogc, the detectNet node follows the vision_msgs paradigm of exposing the class labels through ROS params, and the database name info you are looking for (based on a hash of the model path and model name) is published through the vision_info topic:

https://github.com/dusty-nv/ros_deep_learning/blob/9b5a668ba2cb24708d35eb13f734f343be223bd0/src/node_detectnet.cpp#L269

so subscribe to vision_info, and this will give you a vision_msgs::VisionInfo message where the database_location is the ROS param to query that contains the class label list. Then fetch that ROS param, and it will return you a list of the class names (the raw IDs correspond to their index in the list)

bulldogc commented 1 year ago

Thanks for the quick replay, so I checked my setup, and I am seeing /detectnet/class_labels_3185375291238328062 as the topic stored with database_location but no matching published topic for it if I try to ros2 topic echo it. also doesn't show up in ros2 topic list. Do I a param in detect net to publish this topic or something?

If it matters any I have re-mapped some the various detectnet nodes to "/sensors/video0/..." there is no similar looking topic being published in that grouping either though as reported by topic list.

dusty-nv commented 1 year ago

/detectnet/class_labels_3185375291238328062 as the topic stored with database_location but no matching published topic for it if I try to ros2 topic echo it

/detectnet/class_labels_3185375291238328062 isn't a topic, it's a param. Try listing the params instead and see if you can find it that way.

bulldogc commented 1 year ago

oooo yep there it is indeed! thanks!

bulldogc commented 3 months ago

Got locked away from a while so finally got back to this. Having some issues accessing the params, might not be the best place to ask but figured I'd try.

So I was able to pull the info from the vision topic and see that it points me to a param xxx/class_labels_XXXX. in my subscriber I am attempting to access the param using

auto parameters_client = std::make_shared<rclcpp::SyncParametersClient>(this, "detectnetnodename"); while (!parameters_client->wait_for_service(1s)) { if (!rclcpp::ok()) { RCLCPP_ERROR(this->get_logger(), "Interrupted while waiting for the service. Exiting."); rclcpp::shutdown(); } RCLCPP_INFO(this->get_logger(), "service not available, waiting again..."); }

but it never seems to connect, jsut spins on service not available waiting again. any ideas what im doing wrong?

bulldogc commented 3 months ago

Additional thing that I noticed, it looks like the path published to vision_info doesn't match up with the node name, in my case I am launching detect net with the node name /detectnet/video0_detectnet and the ros2 param list is showing that the params are being published to /detectnet/video0_detectnet/class_labels_XXX but the topic is reporting that they are at database_location: /detectnet/classlabels