rviz: cube_list cubes do not disappear
I'm using a cube list. The cubes are displayed correctly they however never disappear. I tried setting the lifetime but this had no effect. How can I fix this?
For code see below:
ros::Rate loop_rate(50);
visualization_msgs::MarkerArray obj_marker_array;
visualization_msgs::Marker obj_marker;
obj_marker.type = visualization_msgs::Marker::CUBE_LIST;
obj_marker.action = visualization_msgs::Marker::ADD;
obj_marker.ns = "cubes";
obj_marker.scale.x = 1;
obj_marker.scale.y = 1;
obj_marker.scale.z = 1;
obj_marker.header.frame_id = "/map"; // shoudl become wepod_base or the like
obj_marker.color.a = 1.0; // Don't forget to set the alpha!
obj_marker.color.r = 1.0;
obj_marker.id = 0;
ros::Duration lifetime;
obj_marker.lifetime = lifetime.fromSec(0.04); // lifetime of 40ms : 25Hz
while(ros::ok())
{
for (int i=o; i<number_of_objects; i++)
{
geometry_msgs::Point obj;
obj.x = obj_msg.objs_[i].x_;
obj.y = obj_msg.objs_[i].y_;
obj.z = 0;
obj_marker.points.push_back(obj);
// Adding a text object here
}
obj_marker.header.stamp = ros::Time::now();
obj_marker_array.markers.push_back(obj_marker);
obj_pub_.publish(obj_marker_array);
loop_rate.sleep();
}