NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
ros_timer.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 #ifndef LOCALIZATION_COMMON_ROS_TIMER_H_
20 #define LOCALIZATION_COMMON_ROS_TIMER_H_
21 
24 
25 #include <ros/time.h>
26 #include <std_msgs/Header.h>
27 
28 #include <string>
29 
30 namespace localization_common {
31 class RosTimer {
32  public:
33  explicit RosTimer(const std::string& timer_name);
34  void Start();
35  // Uses header time as start time and ros::Time::now as stop time
36  void HeaderDiff(const std_msgs::Header& header);
37  void Stop();
38  void Log() const;
39  void Vlog(const int level = 2) const;
40  void LogEveryN(const int num_timing_events_per_log) const;
41  void VlogEveryN(const int num_timing_events_per_log, const int level = 2) const;
42 
43  private:
44  Averager averager_;
45  ros::Time start_time_;
46 };
47 } // namespace localization_common
48 
49 #endif // LOCALIZATION_COMMON_ROS_TIMER_H_
localization_common
Definition: averager.h:33
localization_common::RosTimer
Definition: ros_timer.h:31
localization_common::RosTimer::Vlog
void Vlog(const int level=2) const
Definition: ros_timer.cc:36
localization_common::Averager
Definition: averager.h:34
localization_common::RosTimer::Stop
void Stop()
Definition: ros_timer.cc:30
localization_common::RosTimer::VlogEveryN
void VlogEveryN(const int num_timing_events_per_log, const int level=2) const
Definition: ros_timer.cc:38
averager.h
time.h
localization_common::RosTimer::Log
void Log() const
Definition: ros_timer.cc:35
localization_common::RosTimer::HeaderDiff
void HeaderDiff(const std_msgs::Header &header)
Definition: ros_timer.cc:25
localization_common::RosTimer::Start
void Start()
Definition: ros_timer.cc:24
localization_common::Time
double Time
Definition: time.h:23
localization_common::RosTimer::RosTimer
RosTimer(const std::string &timer_name)
Definition: ros_timer.cc:23
localization_common::RosTimer::LogEveryN
void LogEveryN(const int num_timing_events_per_log) const
Definition: ros_timer.cc:37