Skip to content

Commit

Permalink
Added converstion from utm -> latlon
Browse files Browse the repository at this point in the history
  • Loading branch information
rk012 committed Jan 7, 2025
1 parent 5571f72 commit 5479b63
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions rb_ws/src/buggy/buggy/visualization/telematics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Runs the conversion script for all telematics data

import rclpy
import utm
from nav_msgs.msg import Odometry
from rclpy.node import Node
from sensor_msgs.msg import NavSatFix
Expand Down Expand Up @@ -35,15 +36,22 @@ def convert_buggystate(self, msg, publisher):
msg (Odometry): Buggy state to convert
publisher (Publisher): Publisher to send NavSatFix message to
"""
lat = msg.pose.pose.position.y
long = msg.pose.pose.position.x
down = msg.pose.pose.position.z
new_msg = NavSatFix()
new_msg.header = msg.header
new_msg.latitude = lat
new_msg.longitude = long
new_msg.altitude = down
publisher.publish(new_msg)
try:
y = msg.pose.pose.position.y
x = msg.pose.pose.position.x
lat, long = utm.to_latlon(x, y, 17, "T")
down = msg.pose.pose.position.z
new_msg = NavSatFix()
new_msg.header = msg.header
new_msg.latitude = lat
new_msg.longitude = long
new_msg.altitude = down
publisher.publish(new_msg)

except Exception as e:
self.get_logger().warn(
"Unable to convert other buggy position to lon lat" + str(e)
)


if __name__ == "__main__":
Expand Down

0 comments on commit 5479b63

Please sign in to comment.