Skip to content

Commit

Permalink
making service caller
Browse files Browse the repository at this point in the history
  • Loading branch information
Minha-Song committed May 7, 2024
1 parent 1a0cb22 commit 368cd60
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions yolov8_ros/yolov8_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ rosidl_generate_interfaces(${PROJECT_NAME}
"msg/DetectionInfo.msg"
"msg/FaceBox.msg"
"msg/FaceBoxArray.msg"
"srv/Person.srv"
DEPENDENCIES std_msgs geometry_msgs
)
ament_export_dependencies(rosidl_default_runtime)
Expand Down
9 changes: 0 additions & 9 deletions yolov8_ros/yolov8_msgs/action/DetectionAction.action

This file was deleted.

4 changes: 4 additions & 0 deletions yolov8_ros/yolov8_msgs/srv/Person.srv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Wanted person name
string person_name
---
string success_name
19 changes: 13 additions & 6 deletions yolov8_ros/yolov8_ros/yolov8_ros/debug_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from yolov8_msgs.msg import DetectionArray, DetectionInfo
from yolov8_msgs.msg import FaceBox
from yolov8_msgs.msg import FaceBoxArray
from yolov8_msgs.srv import Person


class DebugNode(Node):
Expand All @@ -67,6 +68,9 @@ def __init__(self) -> None:
self.declare_parameter("person_name",'Unintialized')
self.person_name = self.get_parameter("person_name").get_parameter_value().string_value

self.get_logger().info('-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-')
self.get_logger().error(f'The Person Who You Want To Detect Is {self.person_name} !!!!')
self.get_logger().info('-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-')
# pubs
self._dbg_pub = self.create_publisher(Image, "dbg_image", 10)
self._center_pub = self.create_publisher(DetectionInfo, "center_point", 10)
Expand All @@ -76,18 +80,22 @@ def __init__(self) -> None:
self, Image, "image_raw", qos_profile=image_qos_profile)
detections_sub = message_filters.Subscriber(
self, DetectionArray, "detections", qos_profile=10)
###
face_sub = message_filters.Subscriber(
self, FaceBoxArray, "/adaface/adaface_msg",qos_profile=10)
###
self._synchronizer = message_filters.ApproximateTimeSynchronizer(
(image_sub, detections_sub,face_sub), 10, 0.5)
#self._synchronizer = message_filters.ApproximateTimeSynchronizer((image_sub, detections_sub), 10, 0.5)
self._synchronizer.registerCallback(self.detections_cb)

# services
self._srv = self.create_service(Person, 'person_name', self.person_setting)

def person_setting(self, req: Person.Request, res: Person.Response ) -> Person.Response:
self.person_name = req.person_name
res.success_name = self.person_name
return res

def draw_box(self, cv_image: np.array, detection: Detection, face_detection: FaceBox) -> np.array:

# get detection info
score = detection.score
box_msg: BoundingBox2D = detection.bbox
Expand Down Expand Up @@ -188,11 +196,10 @@ def detections_cb(self, img_msg: Image, person_detection_msg: DetectionArray, fa
self._face_name[detection.id] = face_detection.name
self._face_id[face_detection.name] = detection.id
detection.name = face_detection.name

else:
detection.name = self._face_name[detection.id]
# self.get_logger().info(f'known person : {detection.name}')
cv_image = self.draw_mask(cv_image, detection)
# cv_image = self.draw_mask(cv_image, detection)
cv_image,sh_point = self.draw_keypoints(cv_image, detection)
# When the input person is detected
if detection.name == self.person_name:
Expand All @@ -201,7 +208,7 @@ def detections_cb(self, img_msg: Image, person_detection_msg: DetectionArray, fa
person_center.x = sh_point[0]
person_center.y = sh_point[1]
self._center_pub.publish(person_center)
self.get_logger().info('Person name : {} | depth point {}'.format(str(detection.name),[sh_point[0],sh_point[1]]))
# self.get_logger().info('Person name : {} | depth point {}'.format(str(detection.name),[sh_point[0],sh_point[1]]))
cv_image = self.draw_box(cv_image, detection,face_detection)

# publish dbg image
Expand Down

1 comment on commit 368cd60

@yeonju52
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update for #7

Please sign in to comment.