Skip to content

Commit

Permalink
Convert the period standard deviation in StatisticsLogger to Duration…
Browse files Browse the repository at this point in the history
… at the end. (#1361)

Fixes #1360
  • Loading branch information
deng02 authored and dirk-thomas committed Aug 20, 2018
1 parent 1cf9ec9 commit 25ad5e1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions clients/roscpp/src/libros/statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void StatisticsLogger::callback(const boost::shared_ptr<M_string>& connection_he
msg.period_mean *= 1.0 / (stats.arrival_time_list.size() - 1);

// then, calc the stddev
msg.period_stddev = ros::Duration(0);
double period_variance = 0.0;
for(std::list<ros::Time>::iterator it = stats.arrival_time_list.begin(); it != stats.arrival_time_list.end(); it++)
{
if (it == stats.arrival_time_list.begin())
Expand All @@ -212,11 +212,11 @@ void StatisticsLogger::callback(const boost::shared_ptr<M_string>& connection_he
}
ros::Duration period = *it - prev;
ros::Duration t = msg.period_mean - period;
msg.period_stddev += ros::Duration(t.toSec() * t.toSec());
period_variance += t.toSec() * t.toSec();
prev = *it;
}
msg.period_stddev = ros::Duration(sqrt(msg.period_stddev.toSec() / (stats.arrival_time_list.size() - 1)));

double period_stddev = sqrt(period_variance / (stats.arrival_time_list.size() - 1));
msg.period_stddev = ros::Duration(period_stddev);
}
else
{
Expand Down

0 comments on commit 25ad5e1

Please sign in to comment.