From 674fc297aa8b28a0a7af40c79871a8af27ea026a Mon Sep 17 00:00:00 2001 From: Mario Garzon Date: Fri, 22 May 2020 19:53:21 +0200 Subject: [PATCH] Add script for objetive error observer --- .../observers/objetive_error_observer.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/rosgraph_monitor/observers/objetive_error_observer.py diff --git a/src/rosgraph_monitor/observers/objetive_error_observer.py b/src/rosgraph_monitor/observers/objetive_error_observer.py new file mode 100644 index 0000000..f75d801 --- /dev/null +++ b/src/rosgraph_monitor/observers/objetive_error_observer.py @@ -0,0 +1,27 @@ +from rosgraph_monitor.observer import TopicObserver +from std_msgs.msg import Bool +from diagnostic_msgs.msg import DiagnosticStatus, KeyValue + + +class ObjetiveErrorObserver(TopicObserver): + def __init__(self, name): + topics = [("/obj_error", Bool)] # list of pairs + + super(ObjetiveErrorObserver, self).__init__( + name, 10, topics) + + def calculate_attr(self, msgs): + status_msg = DiagnosticStatus() + + attr = str("False") + if msgs[0].data: + attr = str("True") + + status_msg = DiagnosticStatus() + status_msg.level = DiagnosticStatus.OK + status_msg.name = self._id + status_msg.values.append( + KeyValue("objetive_error", attr)) + status_msg.message = "QA status" + + return status_msg