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

From base_laser_link to odom frame transformation?

asked 2017-09-08 04:05:49 -0500

ANY gravatar image

updated 2017-09-09 03:56:57 -0500

gvdhoorn gravatar image

I'm trying to solve a problem related to frame transformations. I have two frames, /odom and /base_laser_link. I can calculate coordinates of obstacle from laser_scan ( base_laser_link is frame), but I'm having a problem transforming those coordinates from /base_laser_link to /odom. I need real coordinates of obstacles. I tried to use tf class, but problem is i don't know how to transform that point from one frame to another using this class.


Edit:

terminate called after throwing an instance of 'tf2::InvalidArgumentException'
  what():  Invalid argument passed to lookupTransform argument source_frame in tf2 frame_ids cannot be empty

This is the error that I got. Anyway I'm trying to calculate coordinates of obstacle points using LaserScan msgs. I made a callback function in witch I'm calculating those coordinates and now I'm trying to recalculate them using TranformListener , so that I can get coordinates in /odom frame. I need this approach in order to exclude points from optimization problem. Template that I used for converting LaserScan msgs to 2D coordinates is as folows:

For the Hokuyo URG-04LX-UG01 (as an example), the angular resolution is 0.36° which is what you would get if you do 240/ranges.size().

Therefore, assuming the X axes (phi=0) is following ROS convention, you have to set -120° to ranges[0] and then increase it by 0.36°. In summary: phi = (i * 0.36)-120. And then, convert to radians.

Hope you understand the problem. And thanks for help :)

edit retag flag offensive close merge delete

Comments

@ANY: please don't post answers unless you are answering your own question. For the rest, please use comments or update your original question. Use the edit link/button for that. Thanks.

gvdhoorn gravatar image gvdhoorn  ( 2017-09-09 03:58:34 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2017-09-08 06:27:50 -0500

bvbdort gravatar image

You can use the function transformPoint from tf::TransformListener.

tf::TransformListener listener;     

geometry_msgs::PointStamped point_in_laser_frame; // fill it with your point in base_laser_link frame
geometry_msgs::PointStamped point_in_base_frame;  

listener.transformPoint("/odom", point_in_laser_frame, point_in_base_frame);

This tutorial will be helpful for your task.

edit flag offensive delete link more

Comments

C:\fakepath\eror.png When I used this approach, I got this error message. Any help please? I define a TransformListener object like a private attribute of the class.

ANY gravatar image ANY  ( 2017-09-08 10:38:22 -0500 )edit

@ANY: don't use screenshots for this. Just copy-paste console text into your comment or question. In this case, please edit your original question to add the update.

gvdhoorn gravatar image gvdhoorn  ( 2017-09-08 10:39:30 -0500 )edit

@ANY, Error says frame ids are empty. You should fill frame_id in header of geometry_msgs::PointStamped. Check this

bvbdort gravatar image bvbdort  ( 2017-09-09 05:55:03 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2017-09-08 04:05:49 -0500

Seen: 649 times

Last updated: Sep 09 '17