Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 import rospy
00032 import re
00033
00034 match_link = "(.*)<link[^>]*name\s*=\s*\"pedestal\"[^>]*>.*?[^<]<\/link>(.*)"
00035 match_joint = "(.*)<joint[^>]*name\s*=\s*\"pedestal_fixed\"[^>]*>.*?[^<]<\/joint>(.*)"
00036
00037 if __name__ == '__main__':
00038 try:
00039 rospy.init_node('urdf_remove_pedestal', anonymous=True)
00040 param_src = rospy.get_param('~param_src', "/robot_description")
00041 param_dest = rospy.get_param('~param_dest', "/robot_description_mod")
00042 urdf = rospy.get_param(param_src, "")
00043 changed = False
00044 if urdf:
00045 obj = re.match(match_link, urdf, re.S)
00046 if obj:
00047 urdf = obj.group(1) + obj.group(2)
00048 changed = True
00049 rospy.loginfo("Removed link 'pedestal'")
00050 else:
00051 rospy.logwarn("Failed to find link 'pedestal'")
00052
00053 obj = re.match(match_joint, urdf, re.S)
00054 if obj:
00055 urdf = obj.group(1) + obj.group(2)
00056 changed = True
00057 rospy.loginfo("Removed joint 'pedestal_fixed'")
00058 else:
00059 rospy.logwarn("Failed to find joint 'pedestal_fixed'")
00060
00061 rospy.set_param(param_dest, urdf)
00062 if changed:
00063 rospy.loginfo("Updated parameter '%s'", param_dest)
00064 else:
00065 rospy.loginfo("Copied parameter '%s' to '%s'", param_src, param_dest)
00066 else:
00067 rospy.logwarn("Parameter '%s' not found", param_src)
00068 except rospy.ROSInterruptException: pass
00069
00070