6 PHM Reliability Estimation Node 11 from std_msgs.msg
import String
12 from phm_msgs.msg
import Reliability
17 Reliability Estimation Node 20 Topic name = /gui_reliability 24 Topic nane = /phm_reliability 25 Message type = Reliability 37 Reliability Estimation Node Main Function 40 publisher_phm_reliability = rospy.Publisher(
'/phm_reliability', Reliability, queue_size=10)
44 phm_reliability = Reliability()
46 while not rospy.is_shutdown():
48 ros_time = rospy.get_rostime()
50 publisher_phm_reliability.publish(phm_reliability)
57 Callback function of /gui_reliability 65 Message function of the /phm_reliability to be published 67 phm_reliability = Reliability()
69 module_names = list(reliability_dict[
"System"].keys())
70 module_names.remove(
"Reliability")
72 system_reliability_keys = list(reliability_dict[
"System"][
"Reliability"].keys())
73 system_reliability_keys.remove(
"Nominal")
75 phm_reliability.stamp = ros_time
76 phm_reliability.system_value = float(reliability_dict[
"System"][
"Reliability"][
"Nominal"])
78 if system_reliability_keys:
79 phm_reliability.system_sensor_based_value = float(reliability_dict[
"System"][
"Reliability"][
"Sensor Based"])
82 module_values = list()
83 module_sensor_based_values = list()
84 phm_reliability.module_names = list(module_names)
86 for module
in module_names:
87 module_reliability_keys = list(reliability_dict[
"System"][str(module)][
"Reliability"].keys())
88 module_reliability_keys.remove(
"Nominal")
90 current_module_value = float(reliability_dict[
"System"][str(module)][
"Reliability"][
"Nominal"])
91 module_values.append(current_module_value)
93 if module_reliability_keys:
94 current_module_sensor_based_value = float(reliability_dict[
"System"][str(module)][
"Reliability"][
"Sensor Based"])
95 module_sensor_based_values.append(current_module_sensor_based_value)
98 module_sensor_based_values.append(float(0.0))
100 phm_reliability.module_values = module_values
101 phm_reliability.module_sensor_based_values = module_sensor_based_values
103 return phm_reliability
106 if __name__ ==
'__main__':
107 rospy.init_node(
'phm_reliability_estimation_node')
110 RELIABILITY_CLASS.main_func()
def phm_gui_reliability_callback_func(self, phm_msg)
def set_reliability_func(cls, reliability_dict, ros_time)