Skip to content

Commit

Permalink
ditch tf_transformations for scipy rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
saransh323 committed Dec 4, 2024
1 parent 24d29fb commit 86da93c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions rb_ws/src/buggy/buggy/buggy_state_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from nav_msgs.msg import Odometry
import numpy as np
import pyproj
from tf_transformations import euler_from_quaternion
from scipy.spatial.transform import Rotation

class BuggyStateConverter(Node):
def __init__(self):
Expand Down Expand Up @@ -78,8 +78,9 @@ def convert_SC_state(self, msg):
# ---- 2. Convert Quaternion to Heading (Radians) ----
qx, qy, qz, qw = msg.pose.pose.orientation.x, msg.pose.pose.orientation.y, msg.pose.pose.orientation.z, msg.pose.pose.orientation.w

# Use euler_from_quaternion to get roll, pitch, yaw
roll, pitch, yaw = euler_from_quaternion([qx, qy, qz, qw])
# Use Rotation.from_quat to get roll, pitch, yaw
roll, pitch, yaw = Rotation.from_quat([qx, qy, qz, qw]).as_euler('xyz');
# roll, pitch, yaw = euler_from_quaternion([qx, qy, qz, qw]) # tf_transformations bad

# Store the heading in the x component of the orientation
converted_msg.pose.pose.orientation.x = roll
Expand Down

0 comments on commit 86da93c

Please sign in to comment.