save_urdf_and_srdf.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright 2017 Shadow Robot Company Ltd.
4 #
5 # This program is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the Free
7 # Software Foundation, either version 2 of the License, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 # more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with this program. If not, see <http://www.gnu.org/licenses/>.
17 #
18 
19 import rospy
20 
21 
22 class SaveUrdfAndSrdf(object):
23  def __init__(self):
24  pass
25 
26  def save_urdf_from_param(self, path_to_save_files="/tmp", file_name="robot"):
27  if rospy.has_param('/robot_description'):
28  urdf_str = rospy.get_param('/robot_description')
29  path = path_to_save_files + "/" + file_name + ".urdf"
30  urdf_file = open(path, "wb")
31  urdf_file.write(urdf_str)
32  urdf_file.close()
33  return path
34  else:
35  rospy.logerr("Parameter server does not have /robot_description param")
36 
37  def save_srdf_from_param(self, path_to_save_files="/tmp", file_name="robot"):
38  if rospy.has_param('/robot_description_semantic'):
39  srdf_str = rospy.get_param('/robot_description_semantic')
40  path = path_to_save_files + "/" + file_name + ".srdf"
41  srdf_file = open(path, "wb")
42  srdf_file.write(srdf_str)
43  srdf_file.close()
44  return path
45  else:
46  rospy.logerr("Parameter server does not have /robot_description_semantics param")
47 
48 
49 if __name__ == '__main__':
50  rospy.init_node("saving_urdf_and_srdf_to_files", anonymous=True)
51  save_files = SaveUrdfAndSrdf()
52  save_files.save_urdf_from_param()
53  save_files.save_srdf_from_param()
def save_srdf_from_param(self, path_to_save_files="/tmp", file_name="robot")
def save_urdf_from_param(self, path_to_save_files="/tmp", file_name="robot")


sr_utilities
Author(s): Ugo Cupcic
autogenerated on Tue Oct 13 2020 03:55:49