collect_twist_control_eval_data.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 
18 import time
19 import rospy
20 
21 from data_collection import JointStateDataKraken
22 from data_collection import ObstacleDistanceDataKraken
23 from data_collection import TwistDataKraken
24 from data_collection import JointVelocityDataKraken
25 
26 # has to be startet with ns param: rosrun cob_twist_controller collect_twist_control_eval_data.py __ns:=arm_right
27 if __name__=="__main__":
28  rospy.init_node("collect_twist_control_eval_data")
29 
30  base_dir = '/home/fxm-mb/Scripts/Tests/FinalTests/'
31  if rospy.has_param('~base_dir'):
32  base_dir = rospy.get_param('~base_dir')
33  else:
34  rospy.logwarn('Could not find parameter ~base_dir. Using default base_dir: ' + base_dir)
35 
36  data_krakens = [JointStateDataKraken(base_dir + 'joint_state_data.csv'),
37  ObstacleDistanceDataKraken(base_dir + 'obst_dist_data.csv'),
38  TwistDataKraken(base_dir + 'twist_data.csv'),
39  JointVelocityDataKraken(base_dir + 'joint_vel_data.csv'), ]
40 
41  status_open = True
42  for data_kraken in data_krakens:
43  status_open = status_open and data_kraken.open()
44  if status_open:
45  rospy.loginfo('Subscribers started for data collection ... \nPress CTRL+C to stop program and write data to the file.')
46  rate = rospy.Rate(10)
47  try:
48  while not rospy.is_shutdown():
49  rate.sleep()
50  except (KeyboardInterrupt, SystemExit) as e:
51  rospy.loginfo('KeyboardInterrupt / SystemExit: ' + str(e))
52  # save data
53  for data_kraken in data_krakens:
54  data_kraken.writeAllData()
55  except:
56  rospy.logerr('Else exception.')
57  else:
58  for data_kraken in data_krakens:
59  data_kraken.writeAllData()
60  else:
61  rospy.logerr('Failed to open DataKraken files.')


cob_twist_controller
Author(s): Felix Messmer , Marco Bezzon , Christoph Mark , Francisco Moreno
autogenerated on Thu Apr 8 2021 02:40:00