stopping malfunctioning sensor from cluttering the costmap
I'm having trouble with a sensor that stops providing data at times cluttering my costmap. To reproduce the problem, I start the system, see the costmap update properly, then unplug the sensor. The last sensor reading stays in the costmap.
I tracked this down to the following function:
bool Costmap2DROS::getMarkingObservations(std::vector<Observation>& marking_observations) const {
bool current = true;
//get the marking observations
for(unsigned int i = 0; i < marking_buffers_.size(); ++i){
marking_buffers_[i]->lock();
marking_buffers_[i]->getObservations(marking_observations);
current = marking_buffers_[i]->isCurrent() && current;
marking_buffers_[i]->unlock();
}
return current;
}
getObservations() removes stale observations, but it keeps one observation. As a result, the last reading from the sensor continues to be used as a marking observation.
The following change allows me to drop the sensor as soon as it is detected as no longer active. Are there any implications of this change I'm missing, or do people have other ways of dealing with sensors that stop providing data?
bool Costmap2DROS::getMarkingObservations(std::vector<Observation>& marking_observations) const {
bool current = true;
//get the marking observations
for(unsigned int i = 0; i < marking_buffers_.size(); ++i){
marking_buffers_[i]->lock();
bool obsCurrent = marking_buffers_[i]->isCurrent();
if (obsCurrent) {
marking_buffers_[i]->getObservations(marking_observations);
}
current = obsCurrent && current;
marking_buffers_[i]->unlock();
}
return current;
}
@David Lu is this a good patch?