障碍层(三) purgeStaleObservations

purgeStaleObservations

将timestamp较早的点都移除出observation_list_ 类型std::list<Observation>
唯一调用的地方是bufferCloud

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
if (!observation_list_.empty() )
{
list<Observation>::iterator obs_it = observation_list_.begin();
// if keeping observations for no time, only keep one observation

// observation_keep_time_ 就是参数 observation_persistence
if (observation_keep_time_ == ros::Duration(0.0))
{
observation_list_.erase(++obs_it, observation_list_.end());
return;
}
// or loop through the observations to see which ones are stale
for ( obs_it = observation_list_.begin(); obs_it != observation_list_.end();
++obs_it )
{
Observation& obs = *obs_it;
// if observation is out of date, remove it and those follow from the list
// kinetic: ros::Duration time_diff = last_updated_ - pcl_conversions::fromPCL(obs.cloud_->header).stamp;
if ((last_updated_ - obs.cloud_->header.stamp) > observation_keep_time_)
{
observation_list_.erase(obs_it, observation_list_.end());
return;
}
}
}