Go to the documentation of this file.00001
00002
00003 import sys
00004 import os
00005 import commands
00006
00007
00008 def make_static_model (name, eusurdf_package_path=commands.getoutput('rospack find eusurdf'), overwrite=True):
00009 urdf_dir_path = eusurdf_package_path + '/models/' + name
00010 static_urdf_dir_path = urdf_dir_path + '_static'
00011 urdf_path = urdf_dir_path + '/' + 'model.urdf'
00012 static_urdf_path = static_urdf_dir_path + '/' + 'model.urdf'
00013
00014 if overwrite:
00015 os.system("rm -rf %s" % static_urdf_dir_path)
00016 else:
00017 if os.path.exists(static_urdf_dir_path):
00018 print '[ERROR] the same name static model already exits'
00019 exit(1)
00020
00021 os.system("cp -r %s %s" % (urdf_dir_path, static_urdf_dir_path))
00022
00023 if len(commands.getoutput("grep \"<static>false</static>\" %s" % static_urdf_path)) != 0:
00024 os.system('sed -i -e \"s@<static>false</static>@<static>true</static>@g\" %s' % static_urdf_path)
00025 elif len(commands.getoutput("grep \"<static>true</static>\" %s" % static_urdf_path)) == 0:
00026 os.system('sed -i -e \"s@ <link @ <gazebo>\\n <static>true</static>\\n </gazebo>\\n <link @g\" %s' % static_urdf_path)
00027
00028
00029 os.system('sed -i -e "s@<robot name=\\"\(.*\)\\"@<robot name=\\"\\1_static\\"@g\" %s' % static_urdf_path)
00030
00031
00032 if __name__ == '__main__':
00033 if len(sys.argv) > 2:
00034 make_static_model(sys.argv[1], eusurdf_package_path=sys.argv[2])
00035 elif len(sys.argv) > 1:
00036 make_static_model(sys.argv[1])