ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Can navsat_transform be used to transform a pose from latlong to odom?

asked 2017-08-01 04:32:35 -0500

linusnie gravatar image

I'm using a gps to localize a mobile robot and ekf_localization_node together with a navsat_transform_node to transform the robot location into a local odom frame.

I would like to be able to send the robot gps-coordinates and use the functions from robot_localization to transform them into the odom frame. However, navsat_transform only publishes odom->utm and I don't think there are any latlong->utm conversion exposed to the user.

What I'm trying right now is to use the utm package in python to convert latlong coodrinates into utm and then using the utm->odom transform provided by navsat_transform_node to get the local coordinates:

utm_coords = utm.from_latlon(latlong[0], latlong[1])

# create PoseStamped message to set up for do_transform_pose 
utm_pose = PoseStamped()
utm_pose.header.frame_id = 'utm'
utm_pose.position.x = utm_coords[0]
utm_pose.position.y = utm_coords[1]

# get the utm->odom transform using tf2_ros
tfbuffer = tf2_ros.Buffer() 
tflistener = tf2_ros.TransformListener(tfbuffer)
T = tfbuffer.lookup_transform('odom', 'utm', rospy.Time())

# apply the transform
odom_pose = tf2_geometry_msgs.do_transform_pose(utm_pose, T)

It seems to work, but I would prefer to use the conversions implemented in robot_localization if possible, for consistency.

edit retag flag offensive close merge delete

Comments

There is a c++ header file in the robot_localization package that allows you to convert from lat/lon to utm. You can replace your python node to use this instead.

ufr3c_tjc gravatar image ufr3c_tjc  ( 2017-08-01 17:44:50 -0500 )edit

Also just be aware, that different lat/lon -> utm conversion packages use very slightly different estimates, that can throw off measurements by a few meters. Make sure that you always use the exact same package/function to do your converting throughout your system.

ufr3c_tjc gravatar image ufr3c_tjc  ( 2017-08-01 17:46:14 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-10-03 02:53:09 -0500

Tom Moore gravatar image

Are you saying that you'd like to be able to do this conversion in code, or are you saying you'd like to expose some kind of service? We can't just add a lat_long->utm transform to the transform tree, because the conversion from LL to UTM is much more complex than the standard rotation + translation that each link of the transform tree represents. If you just want to do it in code, @ufr3c_tjc is correct.

edit flag offensive delete link more

Comments

It would for sure be nice if it was exposed to the user somehow (as a service node for example). In my case the utm package in python worked fine though. But since the code for converting is already implemented it would be helpful to have easy access to it without having to set up a c++ node

linusnie gravatar image linusnie  ( 2017-10-03 03:03:23 -0500 )edit

A while ago I converted the code in the robot_localization header file to Python, in case that helps you. See here.

ufr3c_tjc gravatar image ufr3c_tjc  ( 2017-10-03 20:59:48 -0500 )edit

@linusnie care to open a ticket on the GitHub project page?

Tom Moore gravatar image Tom Moore  ( 2017-10-11 02:54:30 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-08-01 04:32:35 -0500

Seen: 917 times

Last updated: Oct 03 '17