Added stronger status comparison tests via previous value system and renamed functions/modules to have better naming conventions

This commit is contained in:
MatthewTaylor24
2018-01-20 18:07:01 -08:00
parent bab7111971
commit 299674b726
2 changed files with 143 additions and 61 deletions

View File

@@ -11,21 +11,30 @@
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf> <leaf>
<file leaf-file-name="system_statuses_node.py" pinned="false" current-in-tab="false"> <file leaf-file-name="system_statuses_node.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/system_statuses_node.py"> <entry file="file://$PROJECT_DIR$/system_statuses_node.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="72"> <state relative-caret-position="-648">
<caret line="3" column="32" lean-forward="false" selection-start-line="3" selection-start-column="32" selection-end-line="3" selection-end-column="32" /> <caret line="114" column="41" lean-forward="true" selection-start-line="114" selection-start-column="41" selection-end-line="114" selection-end-column="41" />
<folding /> <folding>
<element signature="e#22#34#0" expanded="true" />
<element signature="e#4801#5092#0" expanded="false" />
<element signature="e#5146#5397#0" expanded="false" />
<element signature="e#5449#5549#0" expanded="false" />
<element signature="e#5602#5824#0" expanded="false" />
<element signature="e#5875#6010#0" expanded="false" />
<element signature="e#6062#6553#0" expanded="false" />
<marker date="1516500076983" expanded="true" signature="4749:6553" ph="..." />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="rover_statuses.py" pinned="false" current-in-tab="true"> <file leaf-file-name="rover_statuses.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/rover_statuses.py"> <entry file="file://$PROJECT_DIR$/rover_statuses.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="168">
<caret line="0" column="4" lean-forward="false" selection-start-line="0" selection-start-column="4" selection-end-line="0" selection-end-column="4" /> <caret line="7" column="23" lean-forward="true" selection-start-line="7" selection-start-column="23" selection-end-line="7" selection-end-column="23" />
<folding> <folding>
<element signature="e#22#34#0" expanded="true" /> <element signature="e#22#34#0" expanded="true" />
</folding> </folding>
@@ -61,9 +70,9 @@
</component> </component>
<component name="ProjectFrameBounds"> <component name="ProjectFrameBounds">
<option name="x" value="1118" /> <option name="x" value="1118" />
<option name="y" value="372" /> <option name="y" value="21" />
<option name="width" value="1595" /> <option name="width" value="1595" />
<option name="height" value="1205" /> <option name="height" value="1556" />
</component> </component>
<component name="ProjectView"> <component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1"> <navigator currentView="ProjectPane" proportions="" version="1">
@@ -129,7 +138,7 @@
<servers /> <servers />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="1118" y="372" width="1595" height="1205" extended-state="0" /> <frame x="1118" y="21" width="1595" height="1556" extended-state="0" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
@@ -184,23 +193,32 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/system_statuses_node.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="72">
<caret line="3" column="32" lean-forward="false" selection-start-line="3" selection-start-column="32" selection-end-line="3" selection-end-column="32" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/rover_statuses.py"> <entry file="file://$PROJECT_DIR$/rover_statuses.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="168">
<caret line="0" column="4" lean-forward="false" selection-start-line="0" selection-start-column="4" selection-end-line="0" selection-end-column="4" /> <caret line="7" column="23" lean-forward="true" selection-start-line="7" selection-start-column="23" selection-end-line="7" selection-end-column="23" />
<folding> <folding>
<element signature="e#22#34#0" expanded="true" /> <element signature="e#22#34#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/system_statuses_node.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-648">
<caret line="114" column="41" lean-forward="true" selection-start-line="114" selection-start-column="41" selection-end-line="114" selection-end-column="41" />
<folding>
<element signature="e#22#34#0" expanded="true" />
<element signature="e#4801#5092#0" expanded="false" />
<element signature="e#5146#5397#0" expanded="false" />
<element signature="e#5449#5549#0" expanded="false" />
<element signature="e#5602#5824#0" expanded="false" />
<element signature="e#5875#6010#0" expanded="false" />
<element signature="e#6062#6553#0" expanded="false" />
<marker date="1516500076983" expanded="true" signature="4749:6553" ph="..." />
</folding>
</state>
</provider>
</entry>
</component> </component>
</project> </project>

View File

@@ -33,38 +33,43 @@ class SystemStatuses:
self.GPS_msg = GPSInfo() self.GPS_msg = GPSInfo()
self.jetson_msg = JetsonInfo() self.jetson_msg = JetsonInfo()
self.misc_msg = MiscStatuses() self.misc_msg = MiscStatuses()
self.__set_msg_values()
# INIT all RoverSysMessage values # init all message values
def __set_msg_values(self): self.__pull_new_message_values()
self.__gps_update()
self.__bogie_connection_statuses() # init all previous values
self.__arm_connection_status() self.__update_all_previous_values()
self.__arm_end_effector_connection_statuses()
# init all RoverSysMessage values
def __pull_new_message_values(self):
self.__set_gps_info()
self.__set_bogie_connection_statuses()
self.__set_arm_connection_status()
self.__set_arm_end_effector_connection_statuses()
self.__set_cameras() self.__set_cameras()
self.__sample_containment_connection_status() self.__set_sample_containment_connection_status()
self.__tower_connection_status() self.__set_tower_connection_status()
self.__chassis_pan_tilt_connection_status() self.__set_chassis_pan_tilt_connection_status()
self.__jetson_usage_information() self.__set_jetson_usage_information()
self.__frsky_controller_connection_status() self.__set_frsky_controller_connection_status()
# Pulls the UTC GPS Time (WIP) # Pulls the UTC GPS Time (WIP)
def __gps_update(self): def __set_gps_info(self):
self.GPS_msg.UTC_GPS_time = 0 self.GPS_msg.UTC_GPS_time = 0
self.GPS_msg.GPS_connection_status = 0 self.GPS_msg.GPS_connection_status = 0
# Pulls bogie connection statuses (WIP) # Pulls bogie connection statuses (WIP)
def __bogie_connection_statuses(self): def __set_bogie_connection_statuses(self):
self.bogie_msg.bogie_connection_1 = 0 self.bogie_msg.bogie_connection_1 = 0
self.bogie_msg.bogie_connection_2 = 0 self.bogie_msg.bogie_connection_2 = 0
self.bogie_msg.bogie_connection_3 = 0 self.bogie_msg.bogie_connection_3 = 0
# Checks arm connection status (WIP) # Checks arm connection status (WIP)
def __arm_connection_status(self): def __set_arm_connection_status(self):
self.misc_msg.arm_connection_status = 0 self.misc_msg.arm_connection_status = 0
# Checks Arm End Effector Connection Statuses (WIP) # Checks Arm End Effector Connection Statuses (WIP)
def __arm_end_effector_connection_statuses(self): def __set_arm_end_effector_connection_statuses(self):
self.misc_msg.arm_end_effector_connection_statuses = 0 self.misc_msg.arm_end_effector_connection_statuses = 0
# Sets the Camera values (zed, undercarriage, chassis, and main_nav # Sets the Camera values (zed, undercarriage, chassis, and main_nav
@@ -79,63 +84,122 @@ class SystemStatuses:
self.camera_msg.camera_main_navigation = 1 if os.path.exists(self.system_path_locations[3]) else 0 self.camera_msg.camera_main_navigation = 1 if os.path.exists(self.system_path_locations[3]) else 0
# Checks Sample Containment Connection Status (WIP) # Checks Sample Containment Connection Status (WIP)
def __sample_containment_connection_status(self): def __set_sample_containment_connection_status(self):
self.misc_msg.sample_containment_connection_status = 0 self.misc_msg.sample_containment_connection_status = 0
def __tower_connection_status(self): def __set_tower_connection_status(self):
self.misc_msg.tower_connection_status = 0 self.misc_msg.tower_connection_status = 0
# Checks Tower Connection Status (WIP) # Checks Tower Connection Status (WIP)
def __chassis_pan_tilt_connection_status(self): def __set_chassis_pan_tilt_connection_status(self):
self.misc_msg.chassis_pan_tilt_connection_status = 0 self.misc_msg.chassis_pan_tilt_connection_status = 0
# Get Jetson Statuses (WIP) # Get Jetson Statuses (WIP)
def __jetson_usage_information(self): def __set_jetson_usage_information(self):
self.jetson_msg.jetson_CPU = 0 self.jetson_msg.jetson_CPU = 0
self.jetson_msg.jetson_RAM = 0 self.jetson_msg.jetson_RAM = 0
self.jetson_msg.jetson_EMMC = 0 self.jetson_msg.jetson_EMMC = 0
self.jetson_msg.jetson_NVME_SSD = 0 self.jetson_msg.jetson_NVME_SSD = 0
# Check FrSky Controller Connection Status (WIP) # Check FrSky Controller Connection Status (WIP)
def __frsky_controller_connection_status(self): def __set_frsky_controller_connection_status(self):
self.FrSky_msg.FrSky_controller_connection_status = 0 self.FrSky_msg.FrSky_controller_connection_status = 0
# Used mainly for init, sets all previous values in one go
def __update_all_previous_values(self):
self.__set_previous_camera_values()
self.__set_previous_jetson_values()
self.__set_previous_frsky_value()
self.__set_previous_bogie_values()
self.__set_previous_gps_values()
self.__set_previous_misc_values()
def __set_previous_camera_values(self):
self.previous_camera_zed = self.camera_msg.camera_zed
self.previous_camera_undercarriage = self.camera_msg.camera_undercarriage
self.previous_camera_chassis = self.camera_msg.camera_chassis
self.previous_camera_main_navigation = self.camera_msg.camera_main_navigation
def __set_previous_jetson_values(self):
self.previous_jetson_CPU = self.jetson_msg.jetson_CPU
self.previous_jetson_RAM = self.jetson_msg.jetson_RAM
self.previous_jetson_EMMC = self.jetson_msg.jetson_EMMC
self.previous_jetson_NVME_SSD = self.jetson_msg.jetson_NVME_SSD
def __set_previous_frsky_value(self):
self.previous_FrSky_controller_connection_status = self.FrSky_msg.FrSky_controller_connection_status
def __set_previous_bogie_values(self):
self.previous_bogie_connection_1 = self.bogie_msg.bogie_connection_1
self.previous_bogie_connection_2 = self.bogie_msg.bogie_connection_2
self.previous_bogie_connection_3 = self.bogie_msg.bogie_connection_3
def __set_previous_gps_values(self):
self.previous_UTC_GPS_time = self.GPS_msg.UTC_GPS_time
self.previous_GPS_connection_status = self.GPS_msg.GPS_connection_status
def __set_previous_misc_values(self):
self.previous_arm_connection_status = self.misc_msg.arm_connection_status
self.previous_arm_end_effector_connection_statuses = self.misc_msg.arm_end_effector_connection_statuses
self.previous_chassis_pan_tilt_connection_status = self.misc_msg.chassis_pan_tilt_connection_status
self.previous_sample_containment_connection_status = self.misc_msg.sample_containment_connection_status
self.previous_tower_connection_status = self.misc_msg.tower_connection_status
def run(self): def run(self):
r = rospy.Rate(10) r = rospy.Rate(10) # 10Hz
while not rospy.is_shutdown(): while not rospy.is_shutdown():
# Camera Check & update if change # Update all message values
if (self.camera_msg.camera_zed != os.path.exists(self.system_path_locations[0]) or self.__pull_new_message_values()
self.camera_msg.camera_undercarriage != os.path.exists(self.system_path_locations[1]) or
self.camera_msg.camera_chassis != os.path.exists(self.system_path_locations[2]) or # Camera Check -- if current value is now different from previous value,
self.camera_msg.camera_main_navigation != os.path.exists(self.system_path_locations[3])): # update the previous value for cameras and publish to listening Subscribers
self.__set_cameras() if (self.camera_msg.camera_zed != self.previous_camera_zed or
self.camera_msg.camera_undercarriage != self.previous_camera_undercarriage or
self.camera_msg.camera_chassis != self.previous_camera_chassis or
self.camera_msg.camera_main_navigation != self.previous_camera_main_navigation):
self.__set_previous_camera_values()
self.pub_camera.publish(self.camera_msg) self.pub_camera.publish(self.camera_msg)
# Placeholder Jetson Info Check # Placeholder Jetson Info Check
if (self.jetson_msg.jetson_CPU != 0 or if (self.jetson_msg.jetson_CPU != self.previous_jetson_CPU or
self.jetson_msg.jetson_RAM != 0 or self.jetson_msg.jetson_RAM != self.previous_jetson_RAM or
self.jetson_msg.jetson_EMMC != 0 or self.jetson_msg.jetson_EMMC != self.previous_jetson_EMMC or
self.jetson_msg.jetson_NVME_SSD != 0): self.jetson_msg.jetson_NVME_SSD != self.previous_jetson_NVME_SSD):
self.__jetson_usage_information() self.__set_previous_jetson_values()
self.pub_jetson.publish(self.jetson_msg) self.pub_jetson.publish(self.jetson_msg)
# Placeholder FrSky Controller Check # Placeholder FrSky Controller Check
if self.FrSky_msg.FrSky_controller_connection_status != 0: if self.FrSky_msg.FrSky_controller_connection_status != self.previous_FrSky_controller_connection_status:
self.__frsky_controller_connection_status() self.__set_previous_frsky_value()
self.pub_FrSky.publish(self.FrSky_msg) self.pub_FrSky.publish(self.FrSky_msg)
# Placeholder bogie status check # Placeholder bogie status check
if (self.bogie_msg.bogie_connection_1 != 0 or if (self.bogie_msg.bogie_connection_1 != self.previous_bogie_connection_1 or
self.bogie_msg.bogie_connection_2 != 0 or self.bogie_msg.bogie_connection_2 != self.previous_bogie_connection_2 or
self.bogie_msg.bogie_connection_3 != 0): self.bogie_msg.bogie_connection_3 != self.previous_bogie_connection_3):
self.__bogie_connection_statuses() self.__set_previous_bogie_values()
self.pub_bogie.publish(self.bogie_msg) self.pub_bogie.publish(self.bogie_msg)
# Placeholder GPS Information check # Placeholder GPS Information check
if (self.GPS_msg.UTC_GPS_time != 0 or self.GPS_msg.UTC_GPS_time != 0): if (self.GPS_msg.UTC_GPS_time != self.previous_UTC_GPS_time or
self.__gps_update() self.GPS_msg.UTC_GPS_time != self.previous_GPS_connection_status):
self.__set_previous_gps_values()
self.pub_GPS.publish(self.GPS_msg) self.pub_GPS.publish(self.GPS_msg)
# Placeholder Misc Information check
if (self.misc_msg.arm_connection_status !=
self.previous_arm_connection_status or
self.misc_msg.arm_end_effector_connection_statuses !=
self.previous_arm_end_effector_connection_statuses or
self.misc_msg.chassis_pan_tilt_connection_status !=
self.previous_chassis_pan_tilt_connection_status or
self.misc_msg.sample_containment_connection_status !=
self.previous_sample_containment_connection_status or
self.misc_msg.tower_connection_status !=
self.previous_tower_connection_status):
self.__set_previous_misc_values()
self.pub_Misc.publish(self.misc_msg)
# rospy.loginfo(self.msg) # rospy.loginfo(self.msg)
r.sleep() r.sleep()