mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
Loading...
Searching...
No Matches
profiler.h
Go to the documentation of this file.
1
5#ifndef PROFILER_H
6#define PROFILER_H
7
8#include <rclcpp/rclcpp.hpp>
9#include <mrs_msgs/msg/profiler_update.hpp>
11
12namespace mrs_lib
13{
14
15class Routine {
16
17public:
18 Routine(const rclcpp::Node::SharedPtr& node, const std::string& name, const std::string& node_name,
19 const std::shared_ptr<mrs_lib::PublisherHandler<mrs_msgs::msg::ProfilerUpdate>>& publisher, bool profiler_enabled);
20 ~Routine();
21
22 void end(void);
23
24private:
25 rclcpp::Node::SharedPtr node_;
26
27 std::string _routine_name_;
28 std::string _node_name_;
29
30 std::shared_ptr<mrs_lib::PublisherHandler<mrs_msgs::msg::ProfilerUpdate>> publisher_;
31
32 bool _profiler_enabled_ = false;
33
34 // those are the stats from the execution of the routine
35 rclcpp::Time execution_start_;
36
37 // this will be published
38 mrs_msgs::msg::ProfilerUpdate msg_out_;
39};
40
41class Profiler {
42
43public:
47 Profiler();
48
56 Profiler(const rclcpp::Node::SharedPtr& node, const std::string& node_name, const bool profiler_enabled);
57
63 Profiler(const Profiler& other);
64
72 Profiler& operator=(const Profiler& other);
73
81 Routine createRoutine(const std::string& name);
82
83private:
84 std::shared_ptr<mrs_lib::PublisherHandler<mrs_msgs::msg::ProfilerUpdate>> publisher_;
85 std::string _node_name_;
86 bool _profiler_enabled_ = false;
87
88 rclcpp::Node::SharedPtr node_;
89
90 bool is_initialized_ = false;
91};
92
93} // namespace mrs_lib
94
95#endif
Definition profiler.h:41
Routine createRoutine(const std::string &name)
create a routine for an aperiodic function
Definition profiler.cpp:62
Profiler & operator=(const Profiler &other)
the assignment operator
Definition profiler.cpp:40
Profiler()
the basic constructor
Definition profiler.cpp:10
user wrapper of the publisher handler implementation
Definition publisher_handler.h:127
Definition profiler.h:15
All mrs_lib functions, classes, variables and definitions are contained in this namespace.
Definition attitude_converter.h:24
Defines PublisherHandler and related convenience classes for upgrading the ROS publisher.