Drawing camera frustum in RViz using tf and Visualization Marker

asked 2022-11-30 00:07:09 -0500

hunterlineage1 gravatar image

updated 2022-11-30 00:07:45 -0500

I am trying to draw the camera frustum in RViz using Visualization Markers, specifically the Line Strip (LINE_STRIP=4) marker in Python. I have a rosbag file that contains:

types:       tf2_msgs/TFMessage
topics:      /tf   366 msgs    : tf2_msgs/TFMessage

I would like to draw a frustum that moves with base_link frame, basically indicating my camera's frustum, something like this (red lines indicate camera frustum):

image description

I got the above image from the srs_ui_butROS package, with [this github page.] (https://github.com/ipa320/srs_public)

There is a file called view.cpp in the github repo with directory srs_public/srs_ui_but/src/but_data_fusion/view.cpp that shows how to draw the camera frustum in C++ but I am trying to do this in Python, that too with the frustum being attached to the base_link frame and moving with it.

So far, I looked at this page for seeing an example of how to publish a marker, but it does not show how to make the marker move according to the tf of the base_link. How can I publish a Marker shaped like the camera frustum that moves as though it is attached to the base_link in RViz, in Python? The screenshot below shows the coordinates of my map and base_link, I want the Marker frustum to translate and rotate exactly how the base_link does. Please please help out, thank you.

image description

edit retag flag offensive close merge delete

Comments

1

Not an answer, but would jsk_rviz_plugins/camera_info not do this for you?

gvdhoorn gravatar image gvdhoorn  ( 2022-11-30 05:16:28 -0500 )edit

Thanks for your reply. How do I use jsk_rviz_plugins? As in what is the process of using a plugin with RViz?

hunterlineage1 gravatar image hunterlineage1  ( 2022-11-30 11:37:49 -0500 )edit

You install the package, (re)start RViz and click Add on the Displays section. Then scroll to where the camera_info display plugin is in the list that pops up, add it and then configure it like any other RViz Display.

gvdhoorn gravatar image gvdhoorn  ( 2022-11-30 14:14:31 -0500 )edit

I am a beginner -- sorry if this is a silly question, but how do I install the package? Just to confirm, does this link show the correct way to do it? Thank you again.

hunterlineage1 gravatar image hunterlineage1  ( 2022-11-30 14:45:23 -0500 )edit
1

Just to confirm, does this link show the correct way to do it?

No. Please stay away from compiling packages yourself whenever possible.

See #q320046.

As a tip: try to use Google to search ROS Answers. Append site:answers.ros.org to your query. I dare to say that over the past 12+ years, just about all questions have been asked here on ROS Answers.

To not have to wait on someone answering yours, try and see whether there is already a post discussing the same topic.

gvdhoorn gravatar image gvdhoorn  ( 2022-11-30 15:03:09 -0500 )edit