Robotics StackExchange | Archived questions

Is it possible to get a robot static TF from params server?

Hi all,

I'm working on a robot equipped with an RGB-D camera.

The pose of the sensor is specified in an urdf file and I can see it has been properly set by running

~$ rosrun tf tf_echo base_link camera_link
At time 0.000
- Translation: [-0.104, 0.018, 0.980]
- Rotation: in Quaternion [0.000, 0.362, 0.000, 0.932]
            in RPY (radian) [0.000, 0.742, 0.000]
            in RPY (degree) [0.000, 42.500, 0.000]

My goal is to retrieve this transformation inside the node I'm implementing. Being a static tf, I can get it by calling a tf::Transformer::lookupTransform inside the constructor of my node:

bool got_tf = false;
while (!got_tf)
{
  try
  {
    listener_.lookupTransform(base_link_frame_id_, robot_camera_frame_id_,
                              ros::Time(0), camera_pose_);
  }
  catch (tf::TransformException ex)
  {
    ROS_ERROR("%s", ex.what());
    ros::Duration(1.0).sleep();
    continue;
  }
  got_tf = true;
}

However, I have some doubts regarding the efficiency of this method:

  1. I need to instantiate a tf::TransformListener
  2. It's possible that I have to wait some seconds

Therefore, my question is: is there another way (offered by roscpp) to get this transformation? Perhaps, it gets stored on the params server through the urdf?

Thanks

Asked by schizzz8 on 2020-07-16 05:37:24 UTC

Comments

To see whats on your param server you can use rosparam dump dump.yaml It saves the server data into the yaml file (the urdf should be in there).

Asked by Dragonslayer on 2020-07-16 10:00:03 UTC

To add more deep to @Dragonslayer comment, you can always use a yaml file with the following params:

my_tf:
  translation_x: 0.0
  translation_y: 0.0
  translation_z: 0.0
  rotation_x: 0.0
  rotation_y: 0.0
  rotation_z: 0.0
  rotation_w: 1.0

You can recover those set of params with:

std::map<std::string, double> map_tf;
nh.getParam("my_tf", map_tf);

Asked by Weasfas on 2020-07-17 03:10:26 UTC

Answers