Skip to content

Commit 6a7ebcf

Browse files
provided flag for infering orientation from object velocity
1 parent 0dc3249 commit 6a7ebcf

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

kf_hungarian_tracker/kf_hungarian_tracker/kf_hungarian_node.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def __init__(self):
5050
("height_filter", [-2.0, 2.0]),
5151
("cost_filter", 1.0),
5252
("transform_to_global_frame", False),
53+
("infer_orientation_from_velocity", False),
5354
],
5455
)
5556
self.global_frame = self.get_parameter("global_frame")._value
@@ -64,6 +65,9 @@ def __init__(self):
6465
self.transform_to_global_frame = self.get_parameter(
6566
"transform_to_global_frame"
6667
)._value
68+
self.infer_orientation_from_velocity = self.get_parameter(
69+
"infer_orientation_from_velocity"
70+
)._value
6771

6872
self.obstacle_list = []
6973
self.sec = 0
@@ -215,8 +219,13 @@ def callback(self, msg):
215219
marker.color.b = b
216220
marker.pose.position = obs.msg.position
217221
angle = np.arctan2(obs.msg.velocity.y, obs.msg.velocity.x)
218-
marker.pose.orientation.z = 0.0 # float(np.sin(angle / 2))
219-
marker.pose.orientation.w = 1.0 # float(np.cos(angle / 2))
222+
if self.infer_orientation_from_velocity:
223+
marker.pose.orientation.z = float(np.sin(angle / 2))
224+
marker.pose.orientation.w = float(np.cos(angle / 2))
225+
else:
226+
marker.pose.orientation.z = 0.0
227+
marker.pose.orientation.w = 1.0
228+
220229
marker.scale = obs.msg.size
221230
marker_list.append(marker)
222231
# make an arrow

0 commit comments

Comments
 (0)