Skip to content

Instantly share code, notes, and snippets.

@protortyp
Created March 19, 2023 08:11
Show Gist options
  • Save protortyp/be3a32b4216a2a7431049260c1b80e63 to your computer and use it in GitHub Desktop.
Save protortyp/be3a32b4216a2a7431049260c1b80e63 to your computer and use it in GitHub Desktop.
import rospy
import tf
from geometry_msgs.msg import Quaternion
# Create a quaternion object
quat = Quaternion()
quat.x = 0.1
quat.y = 0.2
quat.z = 0.3
quat.w = 0.4
# Convert the quaternion to a rotation matrix
rot_matrix = tf.transformations.quaternion_matrix([quat.x, quat.y, quat.z, quat.w])
# Print the rotation matrix
rospy.loginfo("Rotation matrix:\n{}".format(rot_matrix))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment