diff --git a/launch/monitoring.launch b/launch/monitoring.launch index 05491baa777fdbc218c310649e7ea4dffca1261d..678831e1cdd9af0f9fa823a6709d8126cf190ee4 100644 --- a/launch/monitoring.launch +++ b/launch/monitoring.launch @@ -1,11 +1,12 @@ <launch> + <!-- frequency at which all monitors publish updated values --> + <param name="mon_freq" value="0.1" /> + <!-- <include file="$(find monitoring)/launch/translator.launch" /> - --> - <include file="$(find monitoring)/launch/monitor_distance.launch" /> - <include file="$(find monitoring)/launch/monitor_test_1.launch" /> + --> <include file="$(find monitoring)/launch/monitor_test_2.launch" /> <include file="$(find monitoring)/launch/monitor_test_3.launch" /> </launch> \ No newline at end of file diff --git a/nodes/monitor_distance b/nodes/monitor_distance index deeb3016f9700c0d708665e4445306e1df7895e9..7e977229b588539016cd984bed8b307c3d4529e4 100755 --- a/nodes/monitor_distance +++ b/nodes/monitor_distance @@ -22,13 +22,10 @@ if __name__ == '__main__': rate = rospy.Rate(10) while not rospy.is_shutdown(): - if distance > 0.8: + if distance > 1.0: error = 0 else: - if distance > 0.35: - error = 0.5 - else: - error = 1.0 + error = 1.0 - distance monitor.update_metric("kinect", "distance", distance, "meter", error) rate.sleep() diff --git a/nodes/monitor_test_2 b/nodes/monitor_test_2 index 784689ea95dea6595e93f0005b81377c73a3f7fa..5b910926120f1bced62c9135d2df4dc7207762d1 100755 --- a/nodes/monitor_test_2 +++ b/nodes/monitor_test_2 @@ -1,17 +1,18 @@ #!/usr/bin/env python import rospy + from monitoring.monitor import Monitor def monitor_test_2(): rospy.init_node("monitor_test_2") - monitor = Monitor(1, 0.2) + monitor = Monitor(1) rate = rospy.Rate(1.0) value = 0 while not rospy.is_shutdown(): - monitor.update_metric("test_domain_1", "test_label_2", 10, "unit", value) + monitor.update_metric("test", "test", 10, "unit", value) value = value + 0.1 if value > 1.0: value = 0 diff --git a/nodes/monitor_test_3 b/nodes/monitor_test_3 index 5ed32c90860bd841c25d0c47dc0a71d067c89774..d643edc632f2866591382d83790fadc9ae5ef695 100755 --- a/nodes/monitor_test_3 +++ b/nodes/monitor_test_3 @@ -1,16 +1,17 @@ #!/usr/bin/env python import rospy + from monitoring.monitor import Monitor def monitor_test_3(): rospy.init_node("monitor_test_3") - monitor = Monitor(1, 0.2) + monitor = Monitor(1) rate = rospy.Rate(0.2) while not rospy.is_shutdown(): - monitor.update_metric("test_domain_2", "test_label_3", 10, "unit", 1.0) + monitor.update_metric("a", "a", 10, "unit", 1.0) rate.sleep() diff --git a/src/monitoring/monitor.py b/src/monitoring/monitor.py index e6f71214e245052fa997280fdcff76c28842ee01..942fdc6c1dfd6184821f52d15ee3afe5f1d99aa4 100755 --- a/src/monitoring/monitor.py +++ b/src/monitoring/monitor.py @@ -21,11 +21,12 @@ class Monitor: Furthermore, a monitor publishes messages with a certain frequency. """ - def __init__(self, mon_mode=1, mon_freq=1.0): + def __init__(self, mon_mode=1): self.log = {} # Logging dictionary. Is used to accomplish different publishing modes. self.pub = rospy.Publisher("/monitoring", Monitoring, queue_size=1) self.mon_mode = mon_mode + mon_freq = rospy.get_param("/mon_freq") if not mon_freq > 0.0: rospy.logwarn("The frequency at which a monitor publishes messages must be greater then 0! " "Using 1 as frequency!") @@ -37,7 +38,7 @@ class Monitor: self.monitoring.origin = socket.gethostname() + rospy.get_name() # At the moment the last metric update ist published over and over. - def publish_monitoring(self, event): + def publish_monitoring(self, _): self.pub.publish(self.monitoring) def update_metric(self, domain, label, value, unit, error):