Rosanswers logo

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/1PRsbMjhfVs6Pw6zeK7N4jQNUpgZB-gm-/view?usp=sharing

 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

[ERROR] [1666898116.171309]: bad callback: <function callback at 0x7fab3d66e430> 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.

Originally posted by akumar3.1428 on ROS Answers with karma: 61 on 2022-10-27

Post score: 0


1 Answer 1


Rosanswers logo

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():
        now = rospy.Time.now()
        listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
        (trans,rot) = listener.lookupTransform("/turtle2", "/carrot1", now)

Originally posted by akumar3.1428 with karma: 61 on 2022-10-28

This answer was ACCEPTED on the original site

Post score: 0


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.