Skip to content

Commit

Permalink
Fixed quaternion translation
Browse files Browse the repository at this point in the history
  • Loading branch information
mehulgoel873 committed Apr 6, 2024
1 parent 987ccf6 commit 7a169c1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rb_ws/src/buggy/scripts/auton/pose.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from geometry_msgs.msg import Pose as ROSPose
from tf.transformations import euler_from_quaternion
from tf.transformations import quaternion_from_euler


class Pose:
Expand Down Expand Up @@ -38,6 +39,10 @@ def rospose_to_pose(rospose: ROSPose):
p = Pose(rospose.position.x, rospose.position.y, yaw)
return p

def heading_to_quaternion(heading):
q = quaternion_from_euler(0, 0, heading)
return q

def __init__(self, x, y, theta):
self.x = x
self.y = y
Expand Down
17 changes: 17 additions & 0 deletions rb_ws/src/buggy/scripts/serial/ros_to_bnyahaj.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import argparse
import rospy


#Ros Message Imports
from std_msgs.msg import Float64, Bool, Int8, UInt8
from nav_msgs.msg import Odometry as ROSOdom

from host_comm import *

from world import World
from pose import Pose

class Translator:
def __init__(self, self_name, other_name, teensy_name):
Expand Down Expand Up @@ -90,6 +92,21 @@ def reader_thread(self):
self.odom_publisher.publish(odom)
except Exception as e:
rospy.logwarn("Unable to convert other buggy position to lon lat" + e)

elif isinstance(packet, BnyaTelemetry):
rospy.logdebug("packet", packet)
odom = ROSOdom()
try:
lat, long = World.utm_to_gps(packet.y, packet.x)
odom.pose.pose.position.x = long
odom.pose.pose.position.y = lat
odom.twist.twist.angular.z = packet.heading_rate
odom.pose.pose.orientation = Pose.heading_to_quaternion(packet.heading)

self.odom_publisher.publish(odom)
except Exception as e:
rospy.logwarn("Unable to convert other buggy position to lon lat" + e)


elif isinstance(packet, tuple): #Are there any other packet that is a tuple
# print(packet)
Expand Down

0 comments on commit 7a169c1

Please sign in to comment.