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


hrpsys_gazebo_tutorials
Author(s): Yohei Kakiuchi
autogenerated on Tue Oct 7 2014 12:01:15