Skip to content

Commit 2b667c3

Browse files
committed
Ensuring KF tracking turned off if operator changes
1 parent 1cfd2cb commit 2b667c3

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

people_tracking_v2/scripts/decision_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def sync_callback(self, comparison_msg, detection_msg):
8787
if hoc_pose_detections:
8888
best_hoc_detection = min(hoc_pose_detections, key=lambda x: x[1])[0]
8989
operator_id = best_hoc_detection
90-
decision_source = "HoC + Pose"
90+
decision_source = "HoC + Pose to start IoU"
9191
else:
9292
operator_id = -1 # Use -1 to indicate no operator found
9393
decision_source = "None"

people_tracking_v2/scripts/yolo_seg.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
import numpy as np
66
from ultralytics import YOLO
77
from sensor_msgs.msg import Image
8-
from people_tracking_v2.msg import Detection, DetectionArray, SegmentedImages
8+
from people_tracking_v2.msg import Detection, DetectionArray, SegmentedImages, DecisionResult
99
from cv_bridge import CvBridge, CvBridgeError
10-
from std_msgs.msg import Int32 # Import the Int32 message type for operator ID
1110

1211
import sys
1312
import os
@@ -37,8 +36,8 @@ def __init__(self):
3736
self.bounding_box_image_pub = rospy.Publisher("/bounding_box_image", Image, queue_size=10)
3837
self.detection_pub = rospy.Publisher("/detections_info", DetectionArray, queue_size=10)
3938

40-
# Subscriber for operator ID
41-
self.operator_id_sub = rospy.Subscriber('/decision/result', Int32, self.operator_id_callback)
39+
# Subscriber for operator ID and decision source
40+
self.operator_id_sub = rospy.Subscriber('/decision/result', DecisionResult, self.operator_id_callback)
4241

4342
# Initialize the Kalman Filter for the operator
4443
self.kalman_filter_operator = KalmanFilterCV()
@@ -74,9 +73,15 @@ def reset_operator_id(self, event):
7473
rospy.loginfo("Operator ID reset to -1")
7574

7675
def operator_id_callback(self, msg):
77-
"""Callback function to update the operator ID."""
78-
self.operator_id = msg.data
79-
rospy.loginfo(f"Received operator ID: {self.operator_id}")
76+
"""Callback function to update the operator ID and handle the decision source."""
77+
self.operator_id = msg.operator_id
78+
self.decision_source = msg.decision_source
79+
rospy.loginfo(f"Received operator ID: {self.operator_id} from {self.decision_source}")
80+
81+
if self.decision_source not in ["IoU", "HoC + Pose to start IoU"]:
82+
self.operator_initialized = False
83+
self.operator_box = None
84+
rospy.loginfo("Kalman Filter stopped due to decision source.")
8085

8186
def depth_image_callback(self, data):
8287
"""Store the latest depth image. Only the most recent depth images are stored."""
@@ -191,7 +196,7 @@ def image_callback(self, data):
191196
cv2.circle(bounding_box_image, (x_center, y_center), 5, (0, 0, 255), -1)
192197

193198
# Initialize the operator using the detection with the specified operator ID
194-
if not self.operator_initialized and self.operator_id is not None:
199+
if not self.operator_initialized and self.operator_id is not None and self.decision_source in ["IoU", "HoC + Pose to start IoU"]:
195200
for detection in detection_array.detections:
196201
if detection.id == self.operator_id:
197202
self.operator_box = [detection.x1, detection.y1, detection.x2, detection.y2]

0 commit comments

Comments
 (0)