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

How can I change transform from "frame A" to "frame B" ?

asked 2019-10-01 06:33:33 -0600

kane_choigo gravatar image

updated 2019-10-01 06:38:36 -0600

Hi, I'm using ROS kinetic on ubuntu 16.04.

I'm working on multi-sensors conditions. (one RGB-D sensor and 2D-Lidar sensor)

As you might expect I have to fuse these two scan data for robustness measurement.

And unfortunately, each of these two topics has different frame names.

In detail, laser topic has "laser" frame but RGB-D topic's frame name is "base_footprint".

As I'm still new to ROS tools, I'm suffering from modifying the two topics.

Below is the warning I got

[ WARN] [1569927078.948303952]: Failed to lookup transform from frame laser into target frame base_footprint! Dropping input DetectedPersons message on topic /spencer/perception_internal/detected_persons/laser_front. Reason: "laser" passed to lookupTransform argument source_frame does not exist.

If anyone happened to know how to do it, can I get some advice? (I decided to modify frame name of "laser" to "base_footprint")

Thanks in advance :)

edit retag flag offensive close merge delete

Comments

Sorry, but why do you want to modify the frame names? It is meant to have a different name, since they probably are two different frames, right? It's not like a pub/sub topic, it is a coordinate frame in which the data is received. You should transform your data from laser into base_footprint or the other way aoround.

Have a look at this and this

LeoE gravatar image LeoE  ( 2019-10-01 07:00:48 -0600 )edit

It would also be helpful for others if the way to change the frame id in a particular message is explained. As stated by the person in the question, if we want to fuse the readings of the camera and a lidar sensor into a single pointcloud / message type by concatenating both the messages into a single message, then we should have the final message frame id to be something common for both the parent messages.

Vignesh_93 gravatar image Vignesh_93  ( 2021-07-01 16:27:08 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2019-10-01 14:05:49 -0600

Hello !

First you should take a look at @LeoE link in the comment, there is all you need to know about tf, take a look at this answers if you want some image.

I you want to fuse the sensor data, you don't want them to have the same Frame as they don't have the same location.

When you publish a Frame, you actually tell Tf that there is 2 frames : The source frame and target frame.

For example, here is the frame from the "rgbd_launch" package (you can see it with rosrun tf view_frames: image description

each broadcaster is broadcasting the target and the source. The Camera link, the source of all frame, is never broadcasted, instead ROS is waiting for an another node (the application node) to tell where is this frame.

If you launch your lidar node, you should have something like this (I don't have a lidar so I just assumed a single tf was published, I used static_transform_publisher :

image description

In this case, lookuptransform will fail, as the tf tree are not connected.

In your application you should tell Tf where are located the camera to the lidar (or the inverse), or even better if you have a reference point (A robot chassis ?) for the camera and the lidar

For example, I can tell TF that the lidar is 20cm above the camera (Z-axis) with rosrun tf static_transform_publisher 0 0 0.2 0 0 0 camera_link laser_base 10: image description

Or if both the camera and the lidar are connected to the same robot, I can tell tf too : image description

You can use different way to tell tf the transform between your sensors, the best way (I think) is an URDF with robot_state_publisher :

http://wiki.ros.org/tf/Tutorials

http://wiki.ros.org/robot_state_publi...

http://wiki.ros.org/urdf/Tutorials

edit flag offensive delete link more

Comments

very helpful merci beaucoup. As you have mentioned rosrun tf static_transform_publisher 0 0 0.2 0 0 0 camera_link laser_base 10 It should be also possible to do this in a launch file or not?

Petros ADLATUS gravatar image Petros ADLATUS  ( 2022-04-02 05:23:32 -0600 )edit
1

answered 2021-07-02 07:44:40 -0600

Vignesh_93 gravatar image

For the question, First you need to transform from one source frame to target frame using the available functions. For example if you are working with pointcloud data then the function would be something like below:

tf::StampedTransform transform;
try{
        transform_listener.lookupTransform(target frame as a string, source frame as a string, ros::Time(0), transform);
    }
    catch (tf::TransformException ex){
        ROS_ERROR("%s",ex.what());
    } 

pcl_ros::transformPointCloud(message_without_transformed, final_transformed_message, transform);

The you need to change the frame if of the transformed message which is final_transformed_message.header.frame_id = "your required name"

Hope that helps and I am not too late!!

edit flag offensive delete link more

Comments

@Vignesh_93 hey very helpfuln because I'm working with Pointcloud data. Might you help me to use it for a special node I want to use?

Petros ADLATUS gravatar image Petros ADLATUS  ( 2022-04-02 05:35:09 -0600 )edit

Apologies for a late reply. Can you be more specific on the node ? Like giving details like what does the node do, what are all the different frames used in the node ?

Vignesh_93 gravatar image Vignesh_93  ( 2022-05-05 05:55:43 -0600 )edit

no problem, seems that it does not work with the old node. I tried a new one, which produces me the right output ;)

Petros ADLATUS gravatar image Petros ADLATUS  ( 2022-05-09 06:48:58 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2019-10-01 06:33:33 -0600

Seen: 3,463 times

Last updated: Jul 02 '21