YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Statistics.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#pragma once
20
21#include <yarp/os/LogStream.h>
22
23#include <string>
24
25#include "Statistics.h"
26
27YARP_LOG_COMPONENT(ULTRAPYTHONSTAT, "yarp.device.UltraPythonStatistics")
28
29Statistics::Statistics(const std::string &info, double exposure) : info_(info), exposure_(exposure)
30{
31 timeStart_ = yarp::os::Time::now();
32};
33
35{
36 ++frameCounter_;
37 double timeNow = yarp::os::Time::now();
38 double timeElapsed;
39 if ((timeElapsed = timeNow - timeStart_) >= statPeriod_)
40 {
41 latestFps_ = (static_cast<double>(frameCounter_)) / statPeriod_;
42 yCInfo(ULTRAPYTHONSTAT) << info_ << " frame number:" << frameCounter_ << " fps:" << latestFps_ << " interval:" << timeElapsed << " sec."
43 << " exposition:" << exposure_ << " msec.";
44 frameCounter_ = 0;
45 timeStart_ = timeNow;
46 }
47}
48
49double Statistics::getFps() const
50{
51 return latestFps_;
52}
53
54void Statistics::setExposure(double value)
55{
56 exposure_ = value;
57}
const yarp::os::LogComponent & ULTRAPYTHONSTAT()
const yarp::os::LogComponent & ULTRAPYTHONSTAT()
void setExposure(double value)
double getFps() const
#define yCInfo(component,...)
#define YARP_LOG_COMPONENT(name,...)
STL namespace.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition Time.cpp:121