twist_mux_diagnostics.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (CC BY-NC-SA 4.0 License)
3  *
4  * Copyright (c) 2014, PAL Robotics, S.L.
5  * All rights reserved.
6  *
7  * This work is licensed under the Creative Commons
8  * Attribution-NonCommercial-ShareAlike 4.0 International License.
9  *
10  * To view a copy of this license, visit
11  * http://creativecommons.org/licenses/by-nc-sa/4.0/
12  * or send a letter to
13  * Creative Commons, 444 Castro Street, Suite 900,
14  * Mountain View, California, 94041, USA.
15  *********************************************************************/
16 
17 /*
18  * @author Enrique Fernandez
19  */
20 
23 
25 
26 namespace twist_mux
27 {
28 
30 {
31  diagnostic_.add("Twist mux status", this, &TwistMuxDiagnostics::diagnostics);
32  diagnostic_.setHardwareID("none");
33 }
34 
36 {}
37 
39 {
41 }
42 
44 {
45  ROS_DEBUG_THROTTLE(1.0, "Updating status.");
46 
47  status_.velocity_hs = status->velocity_hs;
48  status_.lock_hs = status->lock_hs;
49  status_.priority = status->priority;
50 
51  status_.main_loop_time = status->main_loop_time;
52  status_.reading_age = status->reading_age;
53 
54  update();
55 }
56 
58 {
61  stat.summary(ERROR, "loop time too long");
63  stat.summary(ERROR, "data received is too old");
64  else
65  stat.summary(OK, "ok");
66 
67  for (const auto& velocity_h : *status_.velocity_hs)
68  {
69  stat.addf("velocity " + velocity_h.getName(),
70  " %s (listening to %s @ %fs with priority #%d)",
71  (velocity_h.isMasked(status_.priority) ? "masked" : "unmasked"),
72  velocity_h.getTopic().c_str(),
73  velocity_h.getTimeout(),
74  static_cast<int>(velocity_h.getPriority()));
75  }
76 
77  for (const auto& lock_h : *status_.lock_hs)
78  {
79  stat.addf("lock " + lock_h.getName(),
80  " %s (listening to %s @ %fs with priority #%d)",
81  (lock_h.isLocked() ? "locked" : "free"),
82  lock_h.getTopic().c_str(),
83  lock_h.getTimeout(),
84  static_cast<int>(lock_h.getPriority()));
85  }
86 
87  stat.add("current priority", static_cast<int>(status_.priority));
88 
89  stat.add("loop time in [sec]", status_.main_loop_time);
90  stat.add("data age in [sec]", status_.reading_age);
91 
92  ROS_DEBUG_THROTTLE(1.0, "Publishing diagnostics.");
93 }
94 
95 } // namespace twist_mux
void summary(unsigned char lvl, const std::string s)
void setHardwareID(const std::string &hwid)
boost::shared_ptr< TwistMux::velocity_topic_container > velocity_hs
void add(const std::string &name, TaskFunction f)
void addf(const std::string &key, const char *format,...)
void updateStatus(const status_type::ConstPtr &status)
void diagnostics(diagnostic_updater::DiagnosticStatusWrapper &stat)
static constexpr double MAIN_LOOP_TIME_MIN
boost::shared_ptr< TwistMux::lock_topic_container > lock_hs
diagnostic_updater::Updater diagnostic_
static constexpr double READING_AGE_MIN
void add(const std::string &key, const T &val)
#define ROS_DEBUG_THROTTLE(period,...)


twist_mux
Author(s): Enrique Fernandez , Siegfried-A. Gevatter Pujals
autogenerated on Wed Oct 26 2022 02:14:17