Skip to content

Commit a959d33

Browse files
committed
fix(tracking_object_merger): initial fix for flipped mot tracker
Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp>
1 parent 14e016f commit a959d33

File tree

1 file changed

+18
-0
lines changed
  • perception/tracking_object_merger/src/utils

1 file changed

+18
-0
lines changed

perception/tracking_object_merger/src/utils/utils.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,24 @@ autoware_auto_perception_msgs::msg::TrackedObjectKinematics objectKinematicsVXMe
323323
autoware_auto_perception_msgs::msg::TrackedObjectKinematics output_kinematics;
324324
// copy main object at first
325325
output_kinematics = main_obj.kinematics;
326+
// if the main object is run opposite direction, flip the main object
327+
if (output_kinematics.twist_with_covariance.twist.linear.x < 0.0) {
328+
// flip velocity
329+
output_kinematics.twist_with_covariance.twist.linear.x *= -1.0;
330+
output_kinematics.twist_with_covariance.twist.linear.y *= -1.0;
331+
// flip orientation, convert quaternion to have the opposite direction
332+
const auto q = tf2::Quaternion(
333+
output_kinematics.pose_with_covariance.pose.orientation.x,
334+
output_kinematics.pose_with_covariance.pose.orientation.y,
335+
output_kinematics.pose_with_covariance.pose.orientation.z,
336+
output_kinematics.pose_with_covariance.pose.orientation.w);
337+
const auto q_flip = q * tf2::Quaternion(0, 0, 1, 0);
338+
output_kinematics.pose_with_covariance.pose.orientation.x = q_flip.x();
339+
output_kinematics.pose_with_covariance.pose.orientation.y = q_flip.y();
340+
output_kinematics.pose_with_covariance.pose.orientation.z = q_flip.z();
341+
output_kinematics.pose_with_covariance.pose.orientation.w = q_flip.w();
342+
}
343+
326344
auto sub_obj_ = sub_obj;
327345
// do not merge reverse direction objects
328346
if (!objectsHaveSameMotionDirections(main_obj, sub_obj)) {

0 commit comments

Comments
 (0)