Euler to quaternion conversion error
I try to convert Euler values into quaternion. Some parts of it are as follow:
//data_set[t][8] = yaw = y, data_set[t][7] = pitch = x, data_set[t][6] = roll = z
btQuaternion q(pcl::deg2rad(data_set[t][8]), pcl::deg2rad(data_set[t][7]), pcl::deg2rad(data_set[t][6]));
new_pose.orientation.x = q.x();
new_pose.orientation.y = q.y();
new_pose.orientation.z = q.z();
new_pose.orientation.w = q.w();
cout << "new_pose.orientation.x = " << new_pose.orientation.x << endl;
cout << "new_pose.orientation.y = " << new_pose.orientation.y << endl;
cout << "new_pose.orientation.z = " << new_pose.orientation.z << endl;
cout << "new_pose.orientation.w = " << new_pose.orientation.w << endl;
I have cross-checked with an on-line converter and found that the values returned somehow swapped and have sign(+ve and -ve) problem. The outputs are as below:
From my code:
new_pose.orientation.x = 0.0419219
new_pose.orientation.y = -0.0300053
new_pose.orientation.z = -0.184328
new_pose.orientation.w = 0.981512
From the on-line converter:
u0 = 0.9811347012447917
u1 = -0.18632481923344862
u2 = -0.04192188282716083
u3 = -0.030005257724968114
I guess u0 corresponds to w, u1 corresponds to x and so on..
What is actually the problem of this conversion?