From 25ad5e16de5fbc229ea167fed7e54986b7b89d2e Mon Sep 17 00:00:00 2001 From: Denise Eng Date: Fri, 27 Apr 2018 15:19:46 -0400 Subject: [PATCH] Convert the period standard deviation in StatisticsLogger to Duration at the end. (#1361) Fixes #1360 --- clients/roscpp/src/libros/statistics.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clients/roscpp/src/libros/statistics.cpp b/clients/roscpp/src/libros/statistics.cpp index 2b0a1c299b..a618936fa8 100644 --- a/clients/roscpp/src/libros/statistics.cpp +++ b/clients/roscpp/src/libros/statistics.cpp @@ -202,7 +202,7 @@ void StatisticsLogger::callback(const boost::shared_ptr& 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::iterator it = stats.arrival_time_list.begin(); it != stats.arrival_time_list.end(); it++) { if (it == stats.arrival_time_list.begin()) @@ -212,11 +212,11 @@ void StatisticsLogger::callback(const boost::shared_ptr& 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 {