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
15 class Routine
16 {
17
18 public:
19 Routine(const rclcpp::Node::SharedPtr& node, const std::string& name, const std::string& node_name,
20 const std::shared_ptr<mrs_lib::PublisherHandler<mrs_msgs::msg::ProfilerUpdate>>& publisher, bool profiler_enabled);
21 ~Routine();
22
23 void end(void);
24
25 private:
26 rclcpp::Node::SharedPtr node_;
27
28 std::string _routine_name_;
29 std::string _node_name_;
30
31 std::shared_ptr<mrs_lib::PublisherHandler<mrs_msgs::msg::ProfilerUpdate>> publisher_;
32
33 bool _profiler_enabled_ = false;
34
35 // those are the stats from the execution of the routine
36 rclcpp::Time execution_start_;
37
38 // this will be published
39 mrs_msgs::msg::ProfilerUpdate msg_out_;
40 };
41
43 {
44
45 public:
49 Profiler();
50
58 Profiler(const rclcpp::Node::SharedPtr& node, const std::string& node_name, const bool profiler_enabled);
59
65 Profiler(const Profiler& other);
66
74 Profiler& operator=(const Profiler& other);
75
83 Routine createRoutine(const std::string& name);
84
85 private:
86 std::shared_ptr<mrs_lib::PublisherHandler<mrs_msgs::msg::ProfilerUpdate>> publisher_;
87 std::string _node_name_;
88 bool _profiler_enabled_ = false;
89
90 rclcpp::Node::SharedPtr node_;
91
92 bool is_initialized_ = false;
93 };
94
95} // namespace mrs_lib
96
97#endif
Definition profiler.h:43
Routine createRoutine(const std::string &name)
create a routine for an aperiodic function
Definition profiler.cpp:70
Profiler & operator=(const Profiler &other)
the assignment operator
Definition profiler.cpp:45
Profiler()
the basic constructor
Definition profiler.cpp:10
user wrapper of the publisher handler implementation
Definition publisher_handler.h:130
Definition profiler.h:16
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.