Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 import time
00019 import rospy
00020
00021 from data_collection import JointStateDataKraken
00022 from data_collection import ObstacleDistanceDataKraken
00023 from data_collection import TwistDataKraken
00024 from data_collection import JointVelocityDataKraken
00025
00026
00027 if __name__=="__main__":
00028 rospy.init_node("collect_twist_control_eval_data")
00029
00030 base_dir = '/home/fxm-mb/Scripts/Tests/FinalTests/'
00031 if rospy.has_param('~base_dir'):
00032 base_dir = rospy.get_param('~base_dir')
00033 else:
00034 rospy.logwarn('Could not find parameter ~base_dir. Using default base_dir: ' + base_dir)
00035
00036 data_krakens = [JointStateDataKraken(base_dir + 'joint_state_data.csv'),
00037 ObstacleDistanceDataKraken(base_dir + 'obst_dist_data.csv'),
00038 TwistDataKraken(base_dir + 'twist_data.csv'),
00039 JointVelocityDataKraken(base_dir + 'joint_vel_data.csv'), ]
00040
00041 status_open = True
00042 for data_kraken in data_krakens:
00043 status_open = status_open and data_kraken.open()
00044 if status_open:
00045 rospy.loginfo('Subscribers started for data collection ... \nPress CTRL+C to stop program and write data to the file.')
00046 rate = rospy.Rate(10)
00047 try:
00048 while not rospy.is_shutdown():
00049 rate.sleep()
00050 except (KeyboardInterrupt, SystemExit) as e:
00051 rospy.loginfo('KeyboardInterrupt / SystemExit: ' + str(e))
00052
00053 for data_kraken in data_krakens:
00054 data_kraken.writeAllData()
00055 except rospy.ROSInterruptException as e:
00056 rospy.logwarn('ROSInterruptException: ' + str(e))
00057 except:
00058 rospy.logerr('Else exception.')
00059 else:
00060 for data_kraken in data_krakens:
00061 data_kraken.writeAllData()
00062 else:
00063 rospy.logerr('Failed to open DataKraken files.')