-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gz-math: Rotation example #1383
Labels
Comments
Windows 10Could you shared commands to run this on Windows? I can't compile
|
I've updated the gazebo_test_cases readme regarding Windows testing. You'll need to build all the Gazebo Ionic packages from source. |
Thanks @Tiryoh! (gz-ws) C:\Users\User\gazebo-ws\test\gz-math\examples>.\build\Release\quaternion_to_euler.exe 0.5 0.5 0.5 0.5
Normalizing Quaternion components:
W 0.5
X 0.5
Y 0.5
Z 0.5
to
W 0.5
X 0.5
Y 0.5
Z 0.5
Converting to Euler angles
roll 1.570796 radians
pitch -0.000000 radians
yaw 1.570796 radians
roll 90.000000 degrees
pitch -0.000000 degrees
yaw 90.000000 degrees
to Rotation matrix
0.000000 0.000000 1.000000
1.000000 0.000000 0.000000
0.000000 1.000000 0.000000 (gz-ws) C:\Users\User\gazebo-ws\test\gz-math\examples>.\build\Release\quaternion_from_euler.exe 0 0 1.57
Converting Euler angles:
roll 0.000000 radians
pitch 0.000000 radians
yaw 1.570000 radians
roll 0.000000 degrees
pitch 0.000000 degrees
yaw 89.954374 degrees
to Quaternion
W 0.707388
X 0.000000
Y 0.000000
Z 0.706825
to Rotation matrix
0.000796 -1.000000 0.000000
1.000000 0.000796 0.000000
0.000000 0.000000 1.000000 |
Creating objects #include <stdio.h>
#include <gz/math/Quaternion.hh>
#include <iostream>
int main(int argc, char **argv)
{
double w = 0.5;
double x = 0.5;
double y = 0.5;
double z = 0.5;
double v_roll = atan2(2.0 * (w * x + y * z), 1.0 - 2.0 * (x * x + y * y));
double pitch = asin(2.0 * (w * y - z * x));
double yaw = atan2(2.0 * (w * z + x * y), 1.0 - 2.0 * (y * y + z * z));
gz::math::Quaterniond q(v_roll,pitch, yaw);
gz::math::Matrix3d m(q);
gz::math::Vector3d euler(q.Euler());
printf(" W % .6f\n X % .6f\n Y % .6f\n Z % .6f\n", q.W(), q.X(), q.Y(), q.Z());
std::cout << "\nto Rotation matrix\n";
printf(" % .6f % .6f % .6f\n"
" % .6f % .6f % .6f\n"
" % .6f % .6f % .6f\n",
m(0, 0), m(0, 1), m(0, 2),
m(1, 0), m(1, 1), m(1, 2),
m(2, 0), m(2, 1), m(2, 2));
} (gz-ws) C:\Users\User\gazebo-ws\test\gz-math\examples>.\build\Release\object.exe
W 0.500000
X 0.500000
Y 0.500000
Z 0.500000
to Rotation matrix
0.000000 0.000000 1.000000
1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
(gz-ws) C:\Users\User\gazebo-ws\test\gz-math\examples Works as expected |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Configuration
Links
Process
Step 1 - Instructions work
Step 2 - Images (if there are any) match the result
The text was updated successfully, but these errors were encountered: