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

How do I convert camera coordinates to world coordinates in Moveit using tf2?

asked 2023-05-03 02:24:52 -0500

RowBot gravatar image

updated 2023-05-29 22:22:17 -0500

Hey everyone, I would like to convert my object detection pose estimation coordinates to world coordinates so that I can send a pose_target msg to my robotic arm in Moveit. But I do not know what is the first step I should take to perform the task.

I'm running ubuntu 18.04 ros-melodic using an intel realsense D435 depth camera for object detection and pose estimation.

edit retag flag offensive close merge delete

Comments

You should use the tf2 package, that can help you managing the transformation between reference frames.

Is your camera already integrated in ROS, or that is your question?

bluegiraffe-sc gravatar image bluegiraffe-sc  ( 2023-05-22 11:15:36 -0500 )edit

Yes my camera is already integrated in ROS, I have a object detection topic /aricc_dl_detection/dlObjectDetection/dl_output which gives me the position of the object detected as a geometry_msgs/Point. I notice my target_pose_from_req.pose will always give the same coordinates.

Here is what I did using the tf2 package:

    // Construct a PoseStamped message using the detected object's position
    geometry_msgs::PoseStamped target_pose_from_cam;
    target_pose_from_cam.header.frame_id  = "camera_frame";
    target_pose_from_cam.pose.position.x = point.x;
    target_pose_from_cam.pose.position.y = point.y;
    target_pose_from_cam.pose.position.z = point.z;

    // Transform the PoseStamped message to the base frame
    geometry_msgs::PoseStamped target_pose_from_req = buffer_.transform(
    target_pose_from_cam, req.base_frame);

    // Return the transformed pose in the service response
    res.pose = target_pose_from_req.pose
RowBot gravatar image RowBot  ( 2023-05-23 02:51:37 -0500 )edit

Sorry for the late response. What do you mean by "always the same coordinates"? Is target_pose_from_req.pose always giving you a set of values, regardless of changes in the scenario? If so, which are these values? Or do you mean that it is returning the same values you have in target_pose_from_cam?

I think that posting or linking the full script (or a larger part of it, at least) might help.

bluegiraffe-sc gravatar image bluegiraffe-sc  ( 2023-05-29 03:53:01 -0500 )edit
1

Apologies for the confusion. It seems that I forgot to run a node that allows the dynamic storage of the target_pose_from_cam in points. As a result, the transform remains constant. Here is the link to the code for my frame transformation: Code

RowBot gravatar image RowBot  ( 2023-05-29 22:27:53 -0500 )edit

Glad you solved!

Maybe you should add the actual problem as an answer, rather than a comment.

bluegiraffe-sc gravatar image bluegiraffe-sc  ( 2023-05-31 09:35:15 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-06-01 04:37:52 -0500

RowBot gravatar image

It seems that I forgot to run a node that allows the dynamic storage of the target_pose_from_cam in points. As a result, the transform remains constant. Here is the link to the code for my frame transformation: Code

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-05-03 02:24:52 -0500

Seen: 377 times

Last updated: Jun 01 '23