Skip to content

Commit

Permalink
Merge pull request #189 from martinspedro/master
Browse files Browse the repository at this point in the history
/darknet_ros/found_object uses custom msg with Header for improving synchronization
  • Loading branch information
mbjelonic committed Oct 21, 2019
2 parents f183769 + 42e3157 commit 4c733b7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion darknet_ros/include/darknet_ros/YoloObjectDetector.hpp
Expand Up @@ -20,7 +20,6 @@
// ROS
#include <ros/ros.h>
#include <std_msgs/Header.h>
#include <std_msgs/Int8.h>
#include <actionlib/server/simple_action_server.h>
#include <sensor_msgs/image_encodings.h>
#include <sensor_msgs/Image.h>
Expand All @@ -36,6 +35,7 @@
// darknet_ros_msgs
#include <darknet_ros_msgs/BoundingBoxes.h>
#include <darknet_ros_msgs/BoundingBox.h>
#include <darknet_ros_msgs/ObjectCount.h>
#include <darknet_ros_msgs/CheckForObjectsAction.h>

// Darknet.
Expand Down
18 changes: 11 additions & 7 deletions darknet_ros/src/YoloObjectDetector.cpp
Expand Up @@ -157,9 +157,9 @@ void YoloObjectDetector::init()

imageSubscriber_ = imageTransport_.subscribe(cameraTopicName, cameraQueueSize,
&YoloObjectDetector::cameraCallback, this);
objectPublisher_ = nodeHandle_.advertise<std_msgs::Int8>(objectDetectorTopicName,
objectDetectorQueueSize,
objectDetectorLatch);
objectPublisher_ = nodeHandle_.advertise<darknet_ros_msgs::ObjectCount>(objectDetectorTopicName,
objectDetectorQueueSize,
objectDetectorLatch);
boundingBoxesPublisher_ = nodeHandle_.advertise<darknet_ros_msgs::BoundingBoxes>(
boundingBoxesTopicName, boundingBoxesQueueSize, boundingBoxesLatch);
detectionImagePublisher_ = nodeHandle_.advertise<sensor_msgs::Image>(detectionImageTopicName,
Expand Down Expand Up @@ -599,8 +599,10 @@ void *YoloObjectDetector::publishInThread()
}
}

std_msgs::Int8 msg;
msg.data = num;
darknet_ros_msgs::ObjectCount msg;
msg.header.stamp = ros::Time::now();
msg.header.frame_id = "detection";
msg.count = num;
objectPublisher_.publish(msg);

for (int i = 0; i < numClasses_; i++) {
Expand Down Expand Up @@ -629,8 +631,10 @@ void *YoloObjectDetector::publishInThread()
boundingBoxesResults_.image_header = headerBuff_[(buffIndex_ + 1) % 3];
boundingBoxesPublisher_.publish(boundingBoxesResults_);
} else {
std_msgs::Int8 msg;
msg.data = 0;
darknet_ros_msgs::ObjectCount msg;
msg.header.stamp = ros::Time::now();
msg.header.frame_id = "detection";
msg.count = 0;
objectPublisher_.publish(msg);
}
if (isCheckingForObjects()) {
Expand Down
1 change: 1 addition & 0 deletions darknet_ros_msgs/CMakeLists.txt
Expand Up @@ -17,6 +17,7 @@ add_message_files(
FILES
BoundingBox.msg
BoundingBoxes.msg
ObjectCount.msg
)

add_action_files(
Expand Down
2 changes: 2 additions & 0 deletions darknet_ros_msgs/msg/ObjectCount.msg
@@ -0,0 +1,2 @@
Header header
int8 count

0 comments on commit 4c733b7

Please sign in to comment.