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 version 2 of the License.
8 #
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 # more details.
13 #
14 # You should have received a copy of the GNU General Public License along
15 # with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 import rospy
18 
19 
20 class SaveUrdfAndSrdf(object):
21  def __init__(self):
22  pass
23 
24  def save_urdf_from_param(self, path_to_save_files="/tmp", file_name="robot"):
25  if rospy.has_param('/robot_description'):
26  urdf_str = rospy.get_param('/robot_description')
27  path = path_to_save_files + "/" + file_name + ".urdf"
28  urdf_file = open(path, "wb")
29  urdf_file.write(urdf_str)
30  urdf_file.close()
31  return path
32  else:
33  rospy.logerr("Parameter server does not have /robot_description param")
34 
35  def save_srdf_from_param(self, path_to_save_files="/tmp", file_name="robot"):
36  if rospy.has_param('/robot_description_semantic'):
37  srdf_str = rospy.get_param('/robot_description_semantic')
38  path = path_to_save_files + "/" + file_name + ".srdf"
39  srdf_file = open(path, "wb")
40  srdf_file.write(srdf_str)
41  srdf_file.close()
42  return path
43  else:
44  rospy.logerr("Parameter server does not have /robot_description_semantics param")
45 
46 
47 if __name__ == '__main__':
48  rospy.init_node("saving_urdf_and_srdf_to_files", anonymous=True)
49  save_files = SaveUrdfAndSrdf()
50  save_files.save_urdf_from_param()
51  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 Mon Feb 28 2022 23:52:19