Skip to content

Commit a557af9

Browse files
python uuid and ROS uuid compatability fix
1 parent d999c99 commit a557af9

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

kf_hungarian_tracker/kf_hungarian_tracker/kf_hungarian_node.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,12 @@ def callback(self, msg):
165165
marker_list = []
166166
# add current active obstacles
167167
for obs in filtered_obstacle_list:
168-
(r, g, b) = colorsys.hsv_to_rgb(obs.msg.uuid.int % 360 / 360., 1., 1.) # encode id with rgb color
168+
obstacle_uuid = uuid.UUID(bytes=bytes(obs.msg.uuid.uuid))
169+
(r, g, b) = colorsys.hsv_to_rgb(obstacle_uuid.int % 360 / 360., 1., 1.) # encode id with rgb color
169170
# make a cube
170171
marker = Marker()
171172
marker.header = msg.header
172-
marker.ns = str(obs.msg.uuid)
173+
marker.ns = str(obstacle_uuid)
173174
marker.id = 0
174175
marker.type = 1 # CUBE
175176
marker.action = 0
@@ -186,7 +187,7 @@ def callback(self, msg):
186187
# make an arrow
187188
arrow = Marker()
188189
arrow.header = msg.header
189-
arrow.ns = str(obs.msg.uuid)
190+
arrow.ns = str(obstacle_uuid)
190191
arrow.id = 1
191192
arrow.type = 0
192193
arrow.action = 0
@@ -202,15 +203,15 @@ def callback(self, msg):
202203
arrow.scale.z = 0.05
203204
marker_list.append(arrow)
204205
# add dead obstacles to delete in rviz
205-
for idx in dead_object_list:
206+
for uuid in dead_object_list:
206207
marker = Marker()
207208
marker.header = msg.header
208-
marker.ns = str(idx)
209+
marker.ns = str(uuid)
209210
marker.id = 0
210211
marker.action = 2 # delete
211212
arrow = Marker()
212213
arrow.header = msg.header
213-
arrow.ns = str(idx)
214+
arrow.ns = str(uuid)
214215
arrow.id = 1
215216
arrow.action = 2
216217
marker_list.append(marker)
@@ -239,7 +240,8 @@ def death(self, obj_ind, num_of_obstacle):
239240
if self.obstacle_list[obs].dying < self.death_threshold:
240241
new_object_list.append(self.obstacle_list[obs])
241242
else:
242-
dead_object_list.append(self.obstacle_list[obs].msg.uuid)
243+
obstacle_uuid = uuid.UUID(bytes=bytes(self.obstacle_list[obs].msg.uuid.uuid))
244+
dead_object_list.append(obstacle_uuid)
243245

244246
# add newly born obstacles
245247
for obs in range(num_of_obstacle, len(self.obstacle_list)):

kf_hungarian_tracker/kf_hungarian_tracker/obstacle_class.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import numpy as np
22
import cv2
3-
import uuid
3+
import raw_uuid
4+
from unique_identifier_msgs.msg import UUID
45

56
class ObstacleClass:
67
"""wrap a kalman filter and extra information for one single obstacle
@@ -17,7 +18,11 @@ class ObstacleClass:
1718
def __init__(self, obstacle_msg, top_down, measurement_noise_cov, error_cov_post, process_noise_cov):
1819
'''Initialize with an Obstacle msg and an assigned id'''
1920
self.msg = obstacle_msg
20-
self.msg.uuid = uuid.uuid4()
21+
22+
uuid_msg = UUID()
23+
uuid_msg.uuid = list(uuid.uuid4().bytes)
24+
self.msg.uuid = uuid_msg
25+
2126
position = np.array([[obstacle_msg.position.x, obstacle_msg.position.y, obstacle_msg.position.z]]).T # shape 3*1
2227
velocity = np.array([[obstacle_msg.velocity.x, obstacle_msg.velocity.y, obstacle_msg.velocity.z]]).T
2328

0 commit comments

Comments
 (0)