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

How to visualize tf data in python?

asked 2019-01-30 03:55:16 -0500

Hakaishin gravatar image

updated 2019-01-31 05:38:29 -0500

I would like to visualize tf data from a bag I have in python(it should look like it looks in rviz). Maybe using rviz, but it doesn't have to be. I know I could use python to call system calls, but this feels very clunky. I currently am visualizing images like this:

 bag = rosbag.Bag(os.path.join(Dataset.bags_path, dataset.name + ".bag"))
    for topic, msg, t in bag.read_messages(topics=topics):
        image = bridge.imgmsg_to_cv2(msg, "bgr8")
        cv2.imshow("Image", image)
        cv2.waitKey(10)
        # visalize tf somehow

Is there a similar way to do this for the tf data?

EDIT: I would like to see a certain feature of the tf data. The feature would be a certain frame not moving too much. This I would like to verify visually and not programmatically, since I'm afraid that might be too finiky. When I verified that, I would like to press space and to record the timestamp of that moment. For that I thought it would be a good idea to visualize the tf tree inside of a python program, so that I can grab the timestamp directly in the code on a space press. Right now I play the bag manually and then pause it and copy paste the timestamp into a file, which is cumbersome. I hope this was enough info, let me know if it is still unclear.

edit retag flag offensive close merge delete

Comments

I currently am visualizing the images l

the question title asks about TF, but the body shows code for visualising images.

Can you clarify what it is you're after exactly?

gvdhoorn gravatar image gvdhoorn  ( 2019-01-30 04:11:18 -0500 )edit

I am after what I asked. How can I visualize tf data, in a fashion similar to the how I do it with images. I am imagining something like: rviz.visualize(msg) or the like

Hakaishin gravatar image Hakaishin  ( 2019-01-30 04:28:29 -0500 )edit

Okay, your question doesn't make that very clear. I would recommend using RVIZ for all of this, that is exactly what it's for.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2019-01-30 07:02:28 -0500 )edit

Yes, but I would like to automate certain tasks in rviz. This is why "simply" using rviz is not useful, because it doesn't allow me to automate my tasks

Hakaishin gravatar image Hakaishin  ( 2019-01-31 05:01:16 -0500 )edit

Can you describe exactly what you're trying to achieve so we can get an idea if it's possible in RVIZ or not. The 3D visualizations in RVIZ are very complex rebuilding them from scratch should not be taken lightly.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2019-01-31 05:34:06 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-01-31 05:55:14 -0500

Okay, I can see a straightforward way to achieve what you want. Correct me if I'm wrong but you want to be able to view data live and easily capture time stamps when the user wants to.

RVIZ publishes a topic /clicked_point which is triggered using the publish point tool (red balloon on the top tool bar) these messages contain the time, frame and 3d location of the point that was clicked on by the user. For example here is one I've just made:

header: 
  seq: 0
  stamp: 
    secs: 1548935423
    nsecs: 325876193
  frame_id: "lidar"
point: 
  x: 0.171642303467
  y: -0.0118083953857
  z: -0.338916778564

If your node subscribes to this topic you can record the time stamps for each received message, as well as the frame and the closest frame origin to the clicked point too if you needed.

Hope this helps.

edit flag offensive delete link more

Comments

Awesome, thank you very much. This was a classical XY problem. Is there a way to keep publish point on? Right now I have to press publish point again and again. I plan on doing it often per bag.

Hakaishin gravatar image Hakaishin  ( 2019-01-31 06:01:27 -0500 )edit

I don't think there's any way of capturing mouse button down and up clicks that would let you capture intervals. You could potentially hack something together so that a double click started an interval and a single click ended it. That could be done just using the point_clicked topic.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2019-01-31 06:24:57 -0500 )edit

It's not the most elegant solution but it could be thrown together very easily.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2019-01-31 06:25:21 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-01-30 03:55:16 -0500

Seen: 568 times

Last updated: Jan 31 '19