Monday, February 6, 2017

rotation - Convert quaternion to a different coordinate system



OSVR has a right-handed system: x is right, y is up, z is near.


I need to convert orientation data from a sensor in OSVR to a different right-handed system in which x is forward, y is left, and z is up.


I need to calculate the transformation that will convert a quaternion from one system to the other.


I naively tried:


void osvrPoseCallback(const geometry_msgs::PoseStampedConstPtr &msg) { // osvr to ros
geometry_msgs::PoseStamped outputMsg;

outputMsg.header = msg->header;
outputMsg.pose.orientation.x = msg->pose.orientation.y;
outputMsg.pose.orientation.y = msg->pose.orientation.z;

outputMsg.pose.orientation.z = msg->pose.orientation.x;
outputMsg.pose.orientation.w = msg->pose.orientation.w;

osvrPosePub.publish(outputMsg);
ros::spinOnce();
}

But that made things really weird. Facing north pitch is pitch, facing west, pitch is yaw, facing south, pitch is negative pitch...


How can I convert my OSVR quaternion to the a corresponding quaternion in the new coordinate system?




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...