4 Publish a visualization_marker for specified link
8 from visualization_msgs.msg
import Marker
9 from xml.dom.minidom
import parse, parseString
11 if __name__ ==
"__main__":
12 rospy.init_node(
"link_marker_publisher")
13 link_name = rospy.get_param(
"~link")
14 rgb = rospy.get_param(
"~rgb", [1, 0, 0])
15 alpha = rospy.get_param(
"~alpha", 1.0)
16 scale = rospy.get_param(
"~scale", 1.02)
17 robot_description = rospy.get_param(
"/robot_description")
20 doc = parseString(robot_description)
21 links = doc.getElementsByTagName(
'link')
24 if link_name == link.getAttribute(
'name'):
25 visual_mesh = link.getElementsByTagName(
'visual').item(0).getElementsByTagName(
'mesh').item(0)
26 mesh_file = visual_mesh.getAttribute(
'filename')
29 raise Exception(
"Cannot find link: {0}".format(link_name))
30 pub = rospy.Publisher(
'~marker', Marker)
32 while not rospy.is_shutdown():
34 marker.header.frame_id = link_name
35 marker.header.stamp = rospy.Time.now()
36 marker.type = Marker.MESH_RESOURCE
37 marker.color.a = alpha
38 marker.color.r = rgb[0]
39 marker.color.g = rgb[1]
40 marker.color.b = rgb[2]
41 marker.scale.x = scale
42 marker.scale.y = scale
43 marker.scale.z = scale
44 marker.mesh_resource = mesh_file
45 marker.frame_locked =
True