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

What does marker.lifetime = rospy.Duration() do?

asked 2020-02-22 07:22:20 -0500

John999991 gravatar image

updated 2020-02-22 07:28:49 -0500

Simple question :

What effect does marker.lifetime = rospy.Duration() have to a marker?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-02-22 07:40:53 -0500

Weasfas gravatar image

As it is stated in the msg definition:

"How long the object should last before being automatically deleted. 0 means forever"

Basically is the amount of time the marker will last.

edit flag offensive delete link more


Consider the following piece of code -

ros::Publisher vis_pub = nh.advertise<visualization_msgs::Marker>( "visualization_markers", 10 );

Since the above mentioned bit of code is not inside a while loop ( while (ros::ok()) { .... publish ... } ), the publisher would publish just once on the topic viualisation_markers.

Assume that the marker object has the lifetime attribute set to 0. Would that mean that Rviz would continue to display the marker?

skpro19 gravatar image skpro19  ( 2021-05-14 05:26:34 -0500 )edit

@skpro19 Indeed, One thing is the publishing time and another thing is the life time of the marker displayed on Rviz. Basically, in the hypothetical case you proposed, even if the marker is published once, Rviz will continue displaying the same marker with the same state, until you force a marker deletion, GUI Reset or clean the topic (by enabling/disabling the topic with the check mark), in that cases the marker item will be recycled by Rviz by deleting it from screen.

Weasfas gravatar image Weasfas  ( 2021-05-14 06:00:28 -0500 )edit

Question Tools

1 follower


Asked: 2020-02-22 07:22:20 -0500

Seen: 1,853 times

Last updated: Feb 22 '20