42 #define INTERVAL_DEBUG(fmt, ...) \ 43 ROS_DEBUG_NAMED("IntervalCalc", fmt,##__VA_ARGS__) 50 const std::vector<double>& tolerances,
55 ROS_WARN(
"max_spacing is negative (%.3f). Should be positive", max_spacing.
toSec());
56 max_spacing = -max_spacing;
59 if (signal.size() == 0)
61 ROS_WARN(
"Can't compute range of an empty signal");
62 return calibration_msgs::Interval();
65 std::deque<DeflatedConstPtr>::const_reverse_iterator rev_it = signal.rbegin();
69 const unsigned int N = (*rev_it)->channels_.size();
74 calibration_msgs::Interval result;
75 result.end.sec = std::numeric_limits<uint32_t>::max();
79 assert(tolerances.size() == N);
80 vector<double> channel_max( (*rev_it)->channels_ );
81 vector<double> channel_min( (*rev_it)->channels_ );
82 vector<double> channel_range(N);
84 calibration_msgs::Interval result;
85 result.end = (*signal.rbegin())->
header.stamp;
86 result.start = result.end;
90 while( rev_it != signal.rend() )
92 if ( (*rev_it)->channels_.size() != N)
94 ROS_WARN(
"Num channels has changed. Cutting off interval prematurely ");
98 ros::Duration cur_step = result.start - (*rev_it)->header.stamp;
99 if ( cur_step > max_spacing)
101 INTERVAL_DEBUG(
"Difference between interval.start and it.stamp is [%.3fs]" 102 "Exceeds [%.3fs]", cur_step.
toSec(), max_spacing.
toSec());
106 ostringstream max_debug;
107 ostringstream min_debug;
108 ostringstream range_debug;
109 max_debug <<
" max: ";
110 min_debug <<
" min: ";
111 range_debug <<
" range:";
112 for (
unsigned int i=0; i<N; i++)
114 channel_max[i] = fmax( channel_max[i], (*rev_it)->channels_[i] );
115 channel_min[i] = fmin( channel_min[i], (*rev_it)->channels_[i] );
116 channel_range[i] = channel_max[i] - channel_min[i];
118 max_debug <<
" " << channel_max[i];
119 min_debug <<
" " << channel_min[i];
120 range_debug <<
" " << channel_range[i];
124 max_debug.str().c_str(),
125 min_debug.str().c_str(),
126 range_debug.str().c_str());
128 for (
unsigned int i=0; i<N; i++)
130 if (channel_range[i] > tolerances[i])
132 INTERVAL_DEBUG(
"Channel %u range is %.3f. Exceeds tolerance of %.3f", i, channel_range[i], tolerances[i]);
137 result.start = (*rev_it)->header.stamp;
#define INTERVAL_DEBUG(fmt,...)
std_msgs::Header * header(M &m)
Adds helper routines to the STL Deque for holding messages with headers.