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

How do I get a tf from specific sensor?

asked 2022-06-21 06:33:22 -0600

mth_sousa gravatar image

I'm doing a visual servoing aplication. I want a robotic arm to reach a desired position given by camera data. I have 2 cameras in my setup to detect a single apriltag tag. The first camera is fixed far way from the tag and the other one is coupled in the arm.

The fixed camera has a wide range of vision and the arm camera has more precise position data. I want to get the transform between the tag using the data from the arm camera and, if it's not available, then get the data from the fixed camera.

I know the tf msgs have an frame_id in the header. Is it possible to use this id to get the transform?

Now I'm using "lookupTransform('world', tagString, rospy.Time(0))" to get the position but I'm not sure from which camera the data comes from.

Using Ros Melodic and Ubuntu 18.04

---
transforms: 
  - 
    header: 
      seq: 0
      stamp: 
        secs: 207
        nsecs: 170049000
      frame_id: "sim_camera_arm/armcameraframe_color_optical_frame"
    child_frame_id: "tag_2"
    transform: 
      translation: 
        x: -0.459798174616
        y: -0.109403070212
        z: 1.45586707359
      rotation: 
        x: 0.884761772023
        y: -0.197385909851
        z: 0.344390176089
        w: 0.244194217728
---
transforms: 
  - 
    header: 
      seq: 0
      stamp: 
        secs: 207
        nsecs: 210051000
      frame_id: "sim_camera/cameraframe_color_optical_frame"
    child_frame_id: "tag_2"
    transform: 
      translation: 
        x: -0.699637507022
        y: -0.524468569595
        z: 3.26440053099
      rotation: 
        x: 0.998620267484
        y: 0.00357684425666
        z: -0.0517392437204
        w: 0.0082351814975
---
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-06-21 13:40:44 -0600

Mike Scheutzow gravatar image

By having two frames that are different, but both named "tag_2", you are violating the TF assumption that the tree is a simple branching structure. You need to somehow create unique names for the tag objects identified by each camera e.g. "tag_2a" and "tag_2b".

That solution also answers the question you asked: do a lookup for the (now unique) child_frame_id.

edit flag offensive delete link more

Comments

Thanks for your answer! Indeed, It's possible to publish different names for the tags frames. I just needed to edit the tags.yaml file in apriltag_ros.

mth_sousa gravatar image mth_sousa  ( 2022-06-22 07:31:03 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2022-06-21 06:33:22 -0600

Seen: 114 times

Last updated: Jun 21 '22