@@ -323,22 +323,24 @@ autoware_auto_perception_msgs::msg::TrackedObjectKinematics objectKinematicsVXMe
323
323
autoware_auto_perception_msgs::msg::TrackedObjectKinematics output_kinematics;
324
324
// copy main object at first
325
325
output_kinematics = main_obj.kinematics ;
326
- // if the main object is run opposite direction, flip the main object
326
+
327
+ // if the main object is run opposite direction, flip the main object
327
328
if (output_kinematics.twist_with_covariance .twist .linear .x < 0.0 ) {
328
329
// flip velocity
329
330
output_kinematics.twist_with_covariance .twist .linear .x *= -1.0 ;
330
331
output_kinematics.twist_with_covariance .twist .linear .y *= -1.0 ;
331
- // flip orientation, convert quaternion to have the opposite direction
332
+ // flip orientation, rotate 180 deg
332
333
const auto q = tf2::Quaternion (
333
334
output_kinematics.pose_with_covariance .pose .orientation .x ,
334
335
output_kinematics.pose_with_covariance .pose .orientation .y ,
335
336
output_kinematics.pose_with_covariance .pose .orientation .z ,
336
337
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 ();
338
+ const auto q_rot = tf2::Quaternion (tf2::Vector3 (0 , 0 , 1 ), M_PI);
339
+ const auto q_rotated = q * q_rot;
340
+ output_kinematics.pose_with_covariance .pose .orientation .x = q_rotated.x ();
341
+ output_kinematics.pose_with_covariance .pose .orientation .y = q_rotated.y ();
342
+ output_kinematics.pose_with_covariance .pose .orientation .z = q_rotated.z ();
343
+ output_kinematics.pose_with_covariance .pose .orientation .w = q_rotated.w ();
342
344
}
343
345
344
346
auto sub_obj_ = sub_obj;
0 commit comments