#!/usr/bin/python # -*- coding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import sys if __name__=="__main__": if len(sys.argv) < 2: print "Usage:\n\tannotate_pr2dae.py [collada file]\n\nAnnoates the PR2 with the OpenRAVE profile tags.\nThis file will be in existence until URDF can support the extra information providedhere" sys.exit(0) dae = open(sys.argv[1],'r').read() if dae.find('') < 0: index = dae.find('') dae = dae[:index] + """ """ + dae[index:] if dae.find('') dae = dae[:index] + """ -130 129.75 0.023 60.0 0.25 1.73611115315e-05 0.05 BaseLaser2D -90 89.75 0.023 10.0 0.25 1.73611115315e-05 0.025 BaseLaser2D 2448 2050 3 uint8 0.05 2955 0 1224.5 0 2955 1025.5 0 0 0 0 0 BaseCamera 640 480 1 uint8 0.04 395.71449999999999 0.0 335.86279000000002 0.0 395.71449999999999 245.62557000000001 0 0 0 0 0 BaseCamera 640 480 1 uint8 0.04 395.71449999999999 0.0 335.86279000000002 0.0 395.71449999999999 245.62557000000001 0 0 0 0 0 BaseCamera 0.99956000000000012 0.0027200000000000002 -0.029390000000000003 -0.0027700000000000003 0.99999000000000005 -0.0016800000000000001 0.029390000000000003 0.0017600000000000001 0.99957000000000007 0.99941000000000013 0.0035200000000000001 -0.034260000000000006 -0.0034600000000000004 0.99999000000000005 0.0017800000000000001 0.034270000000000002 -0.0016600000000000002 0.99941000000000013 640 480 1 uint8 0.04 426.35142000000002 0.0 313.91464000000002 0.0 426.51092999999997 238.27394000000001 0 0 0 0 0 BaseCamera 640 480 1 uint8 0.04 430.5514 0.0 320.85068000000001 0.0 429.22170999999997 240.4314 0 0 0 0 0 BaseCamera """ + dae[index:] manipulators = [('leftarm',""" 0.18 0 0 0 1 0 90 -1 ikfast_pr2_leftarm """), ('leftarm_torso',""" 0.18 0 0 0 1 0 90 -1 ikfast_pr2_leftarm_torso """), ('rightarm',""" 0.18 0 0 0 1 0 90 -1 ikfast_pr2_rightarm """), ('rightarm_torso',""" 0.18 0 0 0 1 0 90 -1 ikfast_pr2_rightarm_torso """), ('head',""" ikfast_pr2_head """), ('head_torso',""" ikfast_pr2_head_torso """), ('rightarm_camera',""" """), ('leftarm_camera',""" """)] sensors = [('base_laser',""" """), ('tilt_laser',""" """), ('l_forearm_cam_optical_sensor',""" """), ('r_forearm_cam_optical_sensor',""" """), ('narrow_stereo_optical_sensor',""" """), ('wide_stereo_optical_sensor',""" """)] for name,xml in manipulators: if dae.find(''%name) < 0: index = dae.find('')+9 dae = dae[:index] + xml + dae[index:] for name,xml in sensors: if dae.find(''%name) < 0: index = dae.find('')+9 dae = dae[:index] + xml + dae[index:] open(sys.argv[1],'w').write(dae)