Created
June 4, 2021 12:05
-
-
Save heuristicus/09cff24a447e90283bb135d4c30523b7 to your computer and use it in GitHub Desktop.
Converting roll,pitch,yaw to quaternion with transforms3d
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import math | |
| import argparse | |
| from transforms3d.euler import euler2quat, quat2euler | |
| if __name__ == "__main__": | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("roll", type=float) | |
| parser.add_argument("pitch", type=float) | |
| parser.add_argument("yaw", type=float) | |
| parser.add_argument( | |
| "--radians", | |
| action="store_true", | |
| help="Pass this argument if your values for rpy are in radians", | |
| ) | |
| args = parser.parse_args() | |
| if not args.radians: | |
| args.roll = math.radians(args.roll) | |
| args.pitch = math.radians(args.pitch) | |
| args.yaw = math.radians(args.yaw) | |
| quat = euler2quat(args.roll, args.pitch, args.yaw) | |
| print("Output format for quaternion is wxyz") | |
| print(quat) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment