Different outcome for the same quaternion between geometry_msgs::Pose and tf::Transform
Here is the code I am using to broadcast a transform and publish the path of the same transform.
global_transform_.frame_id_ = "world";
global_transform_.child_frame_id_ = "base_link";
global_transform_.stamp_ = transform_in->header.stamp;
global_transform_.setRotation(q);
global_transform_.setOrigin(p);
broadcaster_.sendTransform(global_transform_);
geometry_msgs::PoseStamped pose;
pose.pose.position.x = p.x();
pose.pose.position.y = p.y();
pose.pose.position.z = p.z();
pose.pose.orientation.x = q.x();
pose.pose.orientation.y = q.y();
pose.pose.orientation.z = q.z();
pose.pose.orientation.x = q.w();
path_.header.frame_id = "world";
path_.header.stamp = transform_in->header.stamp;
path_.poses.push_back(pose);
path_pub_.publish(path_);
Surprisingly, the outcome of the orientation in RViz is different for the two corresponding frames even though I have used the same quaternion value for both (please see the image attached below).
Any idea what is causing this?