convert_xml.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright 2019 Shadow Robot Company Ltd.
4 #
5 # This program is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the Free
7 # Software Foundation version 2 of the License.
8 #
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 # more details.
13 #
14 # You should have received a copy of the GNU General Public License along
15 # with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 # Convert the old style XML grasps file to new style YAML.
18 #
19 # rosrun sr_grasp convert_xml.py sr_hand/scripts/sr_hand/grasps.xml > converted.yaml
20 #
21 
22 import sys
23 import genpy
24 from sr_hand.grasps_parser import GraspParser
25 import sr_grasp
26 from sr_robot_msgs.msg import GraspArray
27 
28 parser = GraspParser()
29 parser.parse_tree(xml_filename=sys.argv[1])
30 
31 grasps = GraspArray()
32 for name, g in parser.grasps.iteritems():
34  ng.id = name
35  ng.set_grasp_point(positions=g.joints_and_positions)
36  grasps.grasps.append(ng)
37 
38 # print grasps # oddly fails, but this works.
39 print genpy.message.strify_message(grasps.grasps)


sr_grasp
Author(s): Mark Pitchless
autogenerated on Wed Oct 14 2020 04:05:13