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

Not able to find TransformListener.frameExists('marker')

asked 2022-10-27 13:36:16 -0500

akumar3.1428 gravatar image

updated 2023-06-18 10:04:55 -0500

lucasw gravatar image

I want the robot arm to move by detecting the Aruco marker using camera on base. I am using the code below to get translation and rotation between base and the marker, however the condition t.frameExists('marker') is coming false and hence not going into the if loop. Any help would be appreciated. Link to tf graph https://drive.google.com/file/d/1PRsb...

 t = TransformListener()

a = True
if t.frameExists('link_base') and t.frameExists('marker'):

    # lookupTransform(target_frame, source_frame, time) -> (position, quaternion)
    (translation,rotation) = t.lookupTransform("marker","link_base",rospy.Time.now())

below is the frame list

The current list of frames is:
Frame ground_plane_box exists with parent world.
Frame link_eef exists with parent link6.
Frame link6 exists with parent link5.
Frame link_base exists with parent world.
Frame camera_color_optical_frame exists with parent link_base.
Frame marker exists with parent camera_color_optical_frame.
Frame link1 exists with parent link_base.
Frame link2 exists with parent link1.
Frame link3 exists with parent link2.
Frame link4 exists with parent link3.
Frame link5 exists with parent link4.

when I am doing

rosrun tf tf_echo marker camera_color_optical_frame

At time 1666896640.814
- Translation: [-0.145, -0.319, 1.223]
- Rotation: in Quaternion [0.979, 0.020, -0.026, -0.203]
            in RPY (radian) [-2.731, 0.043, 0.050]
            in RPY (degree) [-156.483, 2.442, 2.850]

When I am using the following code to just get into the if loop

if t.frameExists('link_base') and t.frameExists('camera_color_optical_frame'):

    # lookupTransform(target_frame, source_frame, time) -> (position, quaternion)
    (translation,rotation) = t.lookupTransform("marker","link_base",rospy.Time.now())

Getting the following error

Traceback (most recent call last): File "/opt/ros/noetic/lib/python3/dist-packages/rospy/topics.py", line 750, in _invoke_callback cb(msg) File "/home/akumar/catkin_ws/src/xarm_ros/move_xarm/scripts/subscriber.py", line 68, in callback (translation,rotation) = t.lookupTransform("marker","link_base",rospy.Time.now()) File "/opt/ros/noetic/lib/python3/dist-packages/tf/listener.py", line 104, in lookupTransform msg = self._buffer.lookup_transform(strip_leading_slash(target_frame), strip_leading_slash(source_frame), time) File "/opt/ros/noetic/lib/python3/dist-packages/tf2_ros/buffer.py", line 86, in lookup_transform return self.lookup_transform_core(target_frame, source_frame, time) tf2.LookupException: "marker" passed to lookupTransform argument target_frame does not exist.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2022-10-28 15:21:30 -0500

akumar3.1428 gravatar image

updated 2022-10-28 15:22:05 -0500

I resolved this issue, I created a python script that will listen to the tf values and publish it to a topic and then subscribe it to move the robot. Example Code

listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
while not rospy.is_shutdown():
    try:
        now = rospy.Time.now()
        listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
        (trans,rot) = listener.lookupTransform("/turtle2", "/carrot1", now)
edit flag offensive delete link more
0

answered 2022-10-28 03:33:38 -0500

fvd gravatar image

updated 2022-10-28 04:15:49 -0500

After creating a TransformListener, you need to wait for it to receive the transformations. You can just add something like this:

while not rospy.is_shutdown():
    if t.frameExists('link_base') and t.frameExists('marker'):
        break
    rospy.sleep(0.1)
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-10-27 13:36:16 -0500

Seen: 204 times

Last updated: Oct 28 '22