make_static_model.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 import sys
4 import os
5 import commands
6 
7 
8 def make_static_model (name, eusurdf_package_path=commands.getoutput('rospack find eusurdf'), overwrite=True):
9  urdf_dir_path = eusurdf_package_path + '/models/' + name
10  static_urdf_dir_path = urdf_dir_path + '_static'
11  urdf_path = urdf_dir_path + '/' + 'model.urdf'
12  static_urdf_path = static_urdf_dir_path + '/' + 'model.urdf'
13 
14  if overwrite:
15  os.system("rm -rf %s" % static_urdf_dir_path)
16  else:
17  if os.path.exists(static_urdf_dir_path):
18  print '[ERROR] the same name static model already exits'
19  exit(1)
20 
21  os.system("cp -r %s %s" % (urdf_dir_path, static_urdf_dir_path))
22 
23  if len(commands.getoutput("grep \"<static>false</static>\" %s" % static_urdf_path)) != 0:
24  os.system('sed -i -e \"s@<static>false</static>@<static>true</static>@g\" %s' % static_urdf_path)
25  elif len(commands.getoutput("grep \"<static>true</static>\" %s" % static_urdf_path)) == 0:
26  os.system('sed -i -e \"s@ <link @ <gazebo>\\n <static>true</static>\\n </gazebo>\\n <link @g\" %s' % static_urdf_path)
27  # os.system('sed -i -e \"s@</robot>@ <gazebo>\\n <static>true</static>\\n </gazebo>\\n</robot>@g\" %s' % static_urdf_path)
28 
29  os.system('sed -i -e "s@<robot name=\\"\(.*\)\\"@<robot name=\\"\\1_static\\"@g\" %s' % static_urdf_path)
30 
31 
32 if __name__ == '__main__':
33  if len(sys.argv) > 2:
34  make_static_model(sys.argv[1], eusurdf_package_path=sys.argv[2])
35  elif len(sys.argv) > 1:
36  make_static_model(sys.argv[1])
def make_static_model(name, eusurdf_package_path=commands.getoutput('rospack find eusurdf'), overwrite=True)


eusurdf
Author(s): Kei Okada , Youhei Kakiuchi , Masaki Murooka
autogenerated on Mon May 4 2020 03:39:35