Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <twist_mux/twist_mux_diagnostics.h>
00022 #include <twist_mux/twist_mux_diagnostics_status.h>
00023
00024 #include <diagnostic_updater/diagnostic_updater.h>
00025
00026 namespace twist_mux
00027 {
00028
00029 TwistMuxDiagnostics::TwistMuxDiagnostics()
00030 {
00031 diagnostic_.add("Twist mux status", this, &TwistMuxDiagnostics::diagnostics);
00032 diagnostic_.setHardwareID("none");
00033 }
00034
00035 TwistMuxDiagnostics::~TwistMuxDiagnostics()
00036 {}
00037
00038 void TwistMuxDiagnostics::update(const bool force_update)
00039 {
00040 if (force_update)
00041 {
00042 diagnostic_.force_update();
00043 }
00044 else
00045 {
00046 diagnostic_.update();
00047 }
00048 }
00049
00050 void TwistMuxDiagnostics::updateStatus(const status_type::ConstPtr& status)
00051 {
00052 ROS_DEBUG_THROTTLE(1.0, "Updating status.");
00053
00054 const bool has_status_changed =
00055
00056
00057
00058
00059 status_.priority != status->priority;
00060
00061 status_.velocity_hs = status->velocity_hs;
00062 status_.lock_hs = status->lock_hs;
00063 status_.priority = status->priority;
00064
00065 update(has_status_changed);
00066 }
00067
00068 void TwistMuxDiagnostics::diagnostics(diagnostic_updater::DiagnosticStatusWrapper& stat)
00069 {
00070 stat.summary(OK, "ok");
00071
00072 for (const auto& velocity_h : *status_.velocity_hs)
00073 {
00074 stat.addf("velocity " + velocity_h.getName(),
00075 " %s (listening to %s @ %fs with priority #%d)",
00076 (velocity_h.isMasked(status_.priority) ? "masked" : "unmasked"),
00077 velocity_h.getTopic().c_str(),
00078 velocity_h.getTimeout(),
00079 static_cast<int>(velocity_h.getPriority()));
00080 }
00081
00082 for (const auto& lock_h : *status_.lock_hs)
00083 {
00084 stat.addf("lock " + lock_h.getName(),
00085 " %s (listening to %s @ %fs with priority #%d)",
00086 (lock_h.isLocked() ? "locked" : "free"),
00087 lock_h.getTopic().c_str(),
00088 lock_h.getTimeout(),
00089 static_cast<int>(lock_h.getPriority()));
00090 }
00091
00092 stat.add("current lock priority", static_cast<int>(status_.priority));
00093
00094 ROS_DEBUG_THROTTLE(1.0, "Publishing diagnostics.");
00095 }
00096
00097 }