8 def make_fixed_model (name, eusurdf_package_path=commands.getoutput(
'rospack find eusurdf'), overwrite=
True):
9 urdf_dir_path = eusurdf_package_path +
'/models/' + name
10 fixed_urdf_dir_path = urdf_dir_path +
'_fixed' 11 urdf_path = urdf_dir_path +
'/' +
'model.urdf' 12 fixed_urdf_path = fixed_urdf_dir_path +
'/' +
'model.urdf' 15 os.system(
"rm -rf %s" % fixed_urdf_dir_path)
17 if os.path.exists(fixed_urdf_dir_path):
18 print '[ERROR] the same name fixed model already exits' 21 os.system(
"cp -r %s %s" % (urdf_dir_path, fixed_urdf_dir_path))
23 root_link_name = commands.getoutput(
'grep "link name=".*">" %s | head -n 1 | sed -e "s/ <link name=\\\"\(.*\)\\\">/\\1/"' % fixed_urdf_path)
24 os.system(
'sed -i -e \"s@</robot>@ <!-- Used for fixing robot to Gazebo \'base_link\' -->\\n <link name=\\\"world\\\"/>\\n <joint name=\\\"fixed\\\" type=\\\"fixed\\\">\\n <parent link=\\\"world\\\"/>\\n <child link=\\\"%s\\\"/>\\n </joint>\\n</robot>@g\" %s' % (root_link_name, fixed_urdf_path))
26 os.system(
'sed -i -e "s@<robot name=\\"\(.*\)\\"@<robot name=\\"\\1_fixed\\"@g\" %s' % fixed_urdf_path)
29 if __name__ ==
'__main__':
32 elif len(sys.argv) > 1:
def make_fixed_model(name, eusurdf_package_path=commands.getoutput('rospack find eusurdf'), overwrite=True)