Skip to content
Snippets Groups Projects
Commit 7ca75e9f authored by bav6096's avatar bav6096
Browse files

fixed loading animations from file

parent 54e2477d
No related branches found
No related tags found
No related merge requests found
...@@ -164,6 +164,7 @@ include_directories( ...@@ -164,6 +164,7 @@ include_directories(
## in contrast to setup.py, you can choose the destination ## in contrast to setup.py, you can choose the destination
catkin_install_python(PROGRAMS catkin_install_python(PROGRAMS
nodes/watchdog nodes/watchdog
nodes/monitor_distance
nodes/monitor_test2 nodes/monitor_test2
nodes/monitor_test nodes/monitor_test
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
......
#!/usr/bin/env pyhton
import rospy
from monitoring.monitor import Monitor
from sensor_msgs.msg import LaserScan
def scan_callback(msg):
global range_ahead
range_ahead = msg.ranges[int(len(msg.ranges) / 2)]
if __name__ == '__main__':
try:
range_ahead = 10
scan_sub = rospy.Subscriber("scan", LaserScan, scan_callback)
rospy.init_node("monitor_distance")
monitor = Monitor(1, 1)
rate = rospy.Rate(10)
while not rospy.is_shutdown():
print(range_ahead)
if range_ahead > 0.8:
critical = 0
else:
if range_ahead > 0.35:
critical = 0.5
else:
critical = 1.0
monitor.update_metric("scan", "distance", range_ahead, "unit", critical)
rate.sleep()
except rospy.ROSInterruptException:
pass
...@@ -21,6 +21,7 @@ class Watchdog: ...@@ -21,6 +21,7 @@ class Watchdog:
rospy.Subscriber("monitoring", Monitoring, self.logging) rospy.Subscriber("monitoring", Monitoring, self.logging)
# TODO: Think about efficiency!
def logging(self, monitoring): def logging(self, monitoring):
origin = monitoring.origin origin = monitoring.origin
metric = monitoring.metric metric = monitoring.metric
...@@ -42,6 +43,7 @@ class Watchdog: ...@@ -42,6 +43,7 @@ class Watchdog:
self.observing[component][origin] = {} self.observing[component][origin] = {}
self.observing[component][origin][label] = {"value": value, "unit": unit, "critical": critical} self.observing[component][origin][label] = {"value": value, "unit": unit, "critical": critical}
# TODO: Add more modes!
def update_states(self, event): def update_states(self, event):
for component in self.observing: for component in self.observing:
# Mode 1: Take the average critical level for a component # Mode 1: Take the average critical level for a component
...@@ -59,6 +61,7 @@ class Watchdog: ...@@ -59,6 +61,7 @@ class Watchdog:
self.publish_states() self.publish_states()
# TODO: Update names!
def publish_states(self): def publish_states(self):
topic = States() topic = States()
for component in self.component_states: for component in self.component_states:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment