From 2f6d00579940759fb18f8ec5ea1e58acd7c64a22 Mon Sep 17 00:00:00 2001 From: Anton David Guaman Davila Date: Wed, 10 Jan 2024 19:08:09 -0330 Subject: [PATCH] Integration of custom message completed. Although it is hard coded until the JSONparsing is completed. The custom message might change to an array of detected objects --- src/object_detection.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/object_detection.cpp b/src/object_detection.cpp index 389f508..363e8c0 100755 --- a/src/object_detection.cpp +++ b/src/object_detection.cpp @@ -24,7 +24,7 @@ class Image_Finder { Image_Finder() : nh_("") { // Subscribe to camera topic publishing data sub_img_ = nh_.subscribe("/camera/color/image_raw", 1, &Image_Finder::imageCallback, this); - publisher = nh_.advertise("/raw_image_copy", 1); + publisher = nh_.advertise("/raw_image_copy", 1); } // Function to continue the life of the node @@ -87,16 +87,19 @@ class Image_Finder { } void publishImageInfo(const sensor_msgs::Image::ConstPtr& msg) { - // Create a Vector3 message to publish image info - geometry_msgs::Vector3 image_info_msg; - image_info_msg.x = static_cast(msg->width); - image_info_msg.y = static_cast(msg->height); - // Assuming you want to publish encoding information in the z field - // Modify this part if you want to publish other information - image_info_msg.z = 0.0; // You can replace 0.0 with encoding information - - // Publish the message - publisher.publish(image_info_msg); + // Create an instance of the custom message + object_detection_pkg::ObjDetected custom_message; + + // Fill in the custom message fields with hard-coded values + custom_message.class_name = "Buoy"; + custom_message.confidence = 0.48662763833999634; + custom_message.x_min = 0; + custom_message.x_max = 113; + custom_message.y_min = 235; + custom_message.y_max = 450; + + // Publish the custom message + publisher.publish(custom_message); } };