Tutorials-Markers: Do not overwrite last marker
I try to have mulitple markers via several publishes and then let them fade away if their lifetime is over. Unfortune if I publish a new marker the old marker disappears before its lifetime is up.
I did the basic tutorial on markers, but what bugs me is this line
If a new marker message is received before the lifetime has been reached, the lifetime will be reset to the value in the new marker message.
How do I add another marker on the same topic but not overwrite the marker from the previous publish.
59 marker.action = visualization_msgs::Marker::ADD;
Above action should add but the default behaviour (I guess is), create the marker if not already there, if its already displayed in rviz then overwrite the last one. How to prevent overwriting. Could someone confirm there is no other way than needing a message array or another solution multiple topics
When using an array it also only displays the last marker of the array:
visualization_msgs::MarkerArray marker_array;
marker_array.markers.resize(2);
for(int i=0; i<2; i++) {
make_markerf(marker_array.markers[i], frame_ids[i], pars[i]);
}
pub.publish(marker_array);
with this function making the markers:
void make_markerf(visualization_msgs::Marker &marker, std::basic_string<char> frame_id, double *pars){
marker.header.frame_id = frame_id;
marker.header.stamp = ros::Time::now();
marker.ns = "sensor_processor";
marker.id = 2;
marker.pose.position.x = pars[0];
marker.pose.position.y = pars[1];
marker.pose.position.z = pars[2];
marker.pose.orientation.x = pars[3];
marker.pose.orientation.y = pars[4];
marker.pose.orientation.z = pars[5];
marker.pose.orientation.w = pars[6];
marker.scale.x = pars[7];
marker.scale.y = pars[8];
marker.scale.z = pars[9];
marker.color.r = pars[10];
marker.color.g = pars[11];
marker.color.b = pars[12];
marker.color.a = pars[13];
marker.type = pars[14];
marker.action = pars[15]; //always 0
marker.lifetime = ros::Duration(pars[16],pars[17]); //tried 0, and 10,0
}