ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Different outcome for the same quaternion between geometry_msgs::Pose and tf::Transform

asked 2019-02-08 06:23:09 -0500

Albtech gravatar image

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?

RViz Frames

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-02-08 06:37:34 -0500

Delb gravatar image

I think it's just a typo :

pose.pose.orientation.x = q.x();
pose.pose.orientation.y = q.y();
pose.pose.orientation.z = q.z();
pose.pose.orientation.x = q.w();

Should be :

pose.pose.orientation.x = q.x();
pose.pose.orientation.y = q.y();
pose.pose.orientation.z = q.z();
pose.pose.orientation.w = q.w();
edit flag offensive delete link more

Comments

1

Thanks a lot.

Albtech gravatar image Albtech  ( 2019-02-08 06:40:38 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-02-08 06:23:09 -0500

Seen: 163 times

Last updated: Feb 08 '19