From 86ad1f141a32e2e6957261dae2c1ec51a603db6c Mon Sep 17 00:00:00 2001 From: MatthewTaylor24 Date: Mon, 22 Jan 2018 20:03:13 -0800 Subject: [PATCH] Modified rover_statuses.py for subscriber example on how to pull data from system_statuses_node.py for ground control station -- very rough idea, I expect only the subscription calls really being used in actual implementation --- .../scripts/.idea/workspace.xml | 28 +++--- .../system_statuses/scripts/rover_statuses.py | 87 ++++++++++++------- 2 files changed, 71 insertions(+), 44 deletions(-) diff --git a/rover/system_statuses/scripts/.idea/workspace.xml b/rover/system_statuses/scripts/.idea/workspace.xml index b0b8fc6..4454e84 100644 --- a/rover/system_statuses/scripts/.idea/workspace.xml +++ b/rover/system_statuses/scripts/.idea/workspace.xml @@ -14,8 +14,8 @@ - - + + @@ -33,8 +33,8 @@ - - + + @@ -57,8 +57,8 @@ @@ -143,15 +143,15 @@ - - + + - + - + - + @@ -195,8 +195,8 @@ - - + + @@ -205,8 +205,8 @@ - - + + diff --git a/rover/system_statuses/scripts/rover_statuses.py b/rover/system_statuses/scripts/rover_statuses.py index 08588ab..772c831 100755 --- a/rover/system_statuses/scripts/rover_statuses.py +++ b/rover/system_statuses/scripts/rover_statuses.py @@ -1,48 +1,75 @@ #!/usr/bin/env python import rospy -from system_statuses.msg import RoverSysStatus +from system_statuses.msg import CameraStatuses, BogieStatuses, FrSkyStatus, GPSInfo, MiscStatuses, JetsonInfo +# THIS IS A SUPER ROUGH EXAMPLE OF HOW TO PULL THE DATA +# You can create your own message formats in the msg folder +# This is a simple example of pulling data from system_statuses_node.py +# and storing them into self values. +# The ground control code sounds like it'll be fairly different in format. + class RoverStatuses: def __init__(self): rospy.init_node('RoverStatuses') - self.pub = rospy.Publisher('rover_statuses_chatter', RoverSysStatus, queue_size=10) + # self.pub = rospy.Publisher('rover_statuses_chatter', RoverSysStatus, queue_size=10) - # Test Subscription for updating camera_undercarriage - rospy.Subscriber('rover_system_status_chatter', RoverSysStatus, self.__sub_callback) + # Subscription examples on pulling data from system_statuses_node.py + rospy.Subscriber('camera_system_status_chatter', CameraStatuses, self.__camera_callback) + rospy.Subscriber('bogie_system_status_chatter', BogieStatuses, self.__camera_callback) + rospy.Subscriber('FrSky_system_status_chatter', FrSkyStatus, self.__camera_callback) + rospy.Subscriber('GPS_system_status_chatter', GPSInfo, self.__camera_callback) + rospy.Subscriber('jetson_system_status_chatter', JetsonInfo, self.__camera_callback) + rospy.Subscriber('misc_system_status_chatter', MiscStatuses, self.__camera_callback) - self.msg = RoverSysStatus() + self.camera_msg = CameraStatuses() + self.bogie_msg = BogieStatuses() + self.FrSky_msg = FrSkyStatus() + self.GPS_msg = GPSInfo() + self.jetson_msg = JetsonInfo() + self.misc_msg = MiscStatuses() - def __sub_callback(self, data): - self.msg.UTC_GPS_time = data.UTC_GPS_time - self.msg.bogie_connection_1 = data.bogie_connection_1 - self.msg.bogie_connection_2 = data.bogie_connection_2 - self.msg.bogie_connection_3 = data.bogie_connection_3 - self.msg.arm_connection_status = data.arm_connection_status - self.msg.arm_end_effector_connection_statuses = data.arm_end_effector_connection_statuses - self.msg.camera_zed = data.camera_zed - self.msg.camera_undercarriage = data.camera_undercarriage - self.msg.camera_chassis = data.camera_chassis - self.msg.camera_main_navigation = data.camera_main_navigation - self.msg.sample_containment_connection_status = data.sample_containment_connection_status - self.msg.tower_connection_status = data.tower_connection_status - self.msg.chassis_pan_tilt_connection_status = data.chassis_pan_tilt_connection_status - self.msg.GPS_connection_status = data.GPS_connection_status - self.msg.jetson_CPU = data.jetson_CPU - self.msg.jetson_RAM = data.jetson_RAM - self.msg.jetson_EMMC = data.jetson_EMMC - self.msg.jetson_NVME_SSD = data.jetson_NVME_SSD - self.msg.FrSky_controller_connection_status = data.FrSky_controller_connection_status - rospy.loginfo(self.msg) + def __camera_callback(self, data): + self.camera_msg.camera_zed = data.camera_zed + self.camera_msg.camera_undercarriage = data.camera_undercarriage + self.camera_msg.camera_chassis = data.camera_chassis + self.camera_msg.camera_main_navigation = data.camera_main_navigation + + def __frsky_callback(self, data): + self.FrSky_msg.FrSky_controller_connection_status = data.FrSky_controller_connection_status + + def __bogie_callback(self, data): + self.bogie_msg.bogie_connection_1 = data.bogie_connection_1 + self.bogie_msg.bogie_connection_2 = data.bogie_connection_2 + self.bogie_msg.bogie_connection_3 = data.bogie_connection_3 + + def __jetson_callback(self, data): + self.jetson_msg.jetson_CPU = data.jetson_CPU + self.jetson_msg.jetson_RAM = data.jetson_RAM + self.jetson_msg.jetson_EMMC = data.jetson_EMMC + self.jetson_msg.jetson_NVME_SSD = data.jetson_NVME_SSD + + def __gps_callback(self, data): + self.GPS_msg.UTC_GPS_time = data.UTC_GPS_time + self.GPS_msg.GPS_connection_status = data.GPS_connection_status + + def __misc_callback(self, data): + self.misc_msg.arm_connection_status = data.arm_connection_status + self.misc_msg.arm_end_effector_connection_statuses = data.arm_end_effector_connection_statuses + self.misc_msg.sample_containment_connection_status = data.sample_containment_connection_status + self.misc_msg.tower_connection_status = data.tower_connection_status + self.misc_msg.chassis_pan_tilt_connection_status = data.chassis_pan_tilt_connection_status def run(self): - rospy.Subscriber('rover_system_status_chatter', RoverSysStatus, self.__sub_callback) - - # Update GUI Here? (Most likely) - + rospy.Subscriber('camera_system_status_chatter', CameraStatuses, self.__camera_callback) + rospy.Subscriber('bogie_system_status_chatter', BogieStatuses, self.__camera_callback) + rospy.Subscriber('FrSky_system_status_chatter', FrSkyStatus, self.__camera_callback) + rospy.Subscriber('GPS_system_status_chatter', GPSInfo, self.__camera_callback) + rospy.Subscriber('jetson_system_status_chatter', JetsonInfo, self.__camera_callback) + rospy.Subscriber('misc_system_status_chatter', MiscStatuses, self.__camera_callback) rospy.spin()