collect_twist_control_eval_data.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00004 #
00005 # Licensed under the Apache License, Version 2.0 (the "License");
00006 # you may not use this file except in compliance with the License.
00007 # You may obtain a copy of the License at
00008 #
00009 #   http://www.apache.org/licenses/LICENSE-2.0
00010 #
00011 # Unless required by applicable law or agreed to in writing, software
00012 # distributed under the License is distributed on an "AS IS" BASIS,
00013 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 # See the License for the specific language governing permissions and
00015 # limitations under the License.
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 # has to be startet with ns param: rosrun cob_twist_controller collect_twist_control_eval_data.py __ns:=arm_right
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             # save data
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.')


cob_twist_controller
Author(s): Felix Messmer , Marco Bezzon , Christoph Mark , Francisco Moreno
autogenerated on Thu Jun 6 2019 21:19:26