42 #include <boost/thread/mutex.hpp>
43 #include <boost/bind.hpp>
50 IntervalIntersector::IntervalIntersector(boost::function<
void (
const calibration_msgs::Interval&)> output_callback):
52 output_callback_(output_callback)
67 for (
size_t i=0; i<n; i++) {
74 mutexes[n].reset(
new boost::mutex());
75 for (
size_t i=0; i<n; i++) {
88 ROS_DEBUG(
"Got message on stream [%zu]", i);
89 boost::mutex::scoped_lock lock(*
mutexes[i]);
91 queues[i].push_back(interval_ptr);
93 if( interval_ptr->start == interval_ptr->end ) {
108 int queue_to_pop = -1;
110 for (
size_t i=0; i<
queues.size(); i++) {
123 boost::mutex::scoped_lock lock(*
mutexes[i]);
132 if (
queues[i][0]->end < end) {
138 if (queue_to_pop < 0) {
139 ROS_ERROR(
"IntervalIntersection logic error");
146 calibration_msgs::Interval interval;
147 interval.start =
start;
154 calibration_msgs::Interval interval;
155 interval.start =
start;
156 interval.end =
start;
160 boost::mutex::scoped_lock lock(*
mutexes[queue_to_pop]);
161 queues[queue_to_pop].pop_front();
168 calibration_msgs::IntervalStatus status;
174 status.names.resize(n);
175 status.yeild_rates.resize(n);
176 for (
size_t i=0; i<n; i++) {
177 boost::mutex::scoped_lock lock(*
mutexes[i]);
180 status.yeild_rates[i] = 0.0;
183 status.yeild_rates[i] = good / count;