How to convert GPS Coordinates to Pose Data

Hi there,

For MasteringWithROSJackal unit 2 Exercise U2-3 I was wondering how I can import geonav_transform and import Alvinxy in the rospy script.

Import geonav tranformation module

import geonav_transform.geonav_conversions as gc
reload(gc)

Import AlvinXY transformation module

import alvinxy.alvinxy as axy

It seems its an error in the system because you should be able to import it just like its stated in the notebook and even executed directly in the notebook. Let me post this issue so its fixed as soon as possible. Sorry for the inconvenience. You can continue the rest of the units while this is fixed ;).

Hello there. Was this fixed? I was trying to run the same section but got the same error.

Regards

Hi,

I’ll post a solution update asap, but the issue should be solved by downloading the ros package into the catkin_ws and compiling:

cd /home/user/catkin_ws/src
git clone https://github.com/bsb808/geonav_transform.git
cd /home/user/catkin_ws/
catkin_make
source devel/setup.bash; rospack profile

Now you should be able to import without issues nd execute the code :slight_smile:

#!/usr/bin/env python 

# Import geonav tranformation module
import geonav_transform.geonav_conversions as gc
reload(gc)
# Import AlvinXY transformation module
import alvinxy.alvinxy as axy
reload(axy)
import rospy
import tf
from nav_msgs.msg import Odometry


def get_xy_based_on_lat_long(lat,lon, name):
    # Define a local orgin, latitude and longitude in decimal degrees
    # GPS Origin
    olat = 49.9
    olon = 8.9
    
    xg2, yg2 = gc.ll2xy(lat,lon,olat,olon)
    utmy, utmx, utmzone = gc.LLtoUTM(lat,lon)
    xa,ya = axy.ll2xy(lat,lon,olat,olon)

    rospy.loginfo("#########  "+name+"  ###########")  
    rospy.loginfo("LAT COORDINATES ==>"+str(lat)+","+str(lon))  
    rospy.loginfo("COORDINATES XYZ ==>"+str(xg2)+","+str(yg2))
    rospy.loginfo("COORDINATES AXY==>"+str(xa)+","+str(ya))
    rospy.loginfo("COORDINATES UTM==>"+str(utmx)+","+str(utmy))

    return xg2, yg2

if __name__ == '__main__':
    rospy.init_node('gps_to_xyz_node')
    xg2, yg2 = get_xy_based_on_lat_long(lat=49.9,lon=8.9, name="MAP")
    xg2, yg2 = get_xy_based_on_lat_long(lat=50.9,lon=8.9, name="MAP")

Thank you for your response