ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

RVIZ not visualizing all markers

asked 2016-06-13 09:25:46 -0500

Thalaiva gravatar image

updated 2016-06-13 09:30:14 -0500

I am trying to create two markers and add them to a MarkerArray and then publish it. However, only the last marker shows up. Any help with this is much appreciated!

pub = rospy.Publisher('site_markers', MarkerArray, queue_size=10)
rospy.init_node('mission_manager')

markerArray = MarkerArray

marker1 = Marker()
marker1.header.stamp = rospy.Time.now()
marker1.header.frame_id = "/vicon"
marker1.type = marker1.CYLINDER
marker1.action = marker1.ADD
marker1.pose.position.x = -9
marker1.pose.position.y = 0
marker1.pose.position.z = 0
marker1.scale.x = 1.0
marker1.scale.y = 1.0
marker1.scale.z = 0.01
marker1.color.r = 1.0
marker1.color.g = 0
marker1.color.b = 0
marker1.color.a = 0.7
marker1.lifetime = rospy.Duration.from_sec(0)
marker1.frame_locked = 0
markerArray.markers.append(marker1)

marker2 = Marker()
marker2.header.stamp = rospy.Time.now()
marker2.header.frame_id = "/vicon"
marker2.type = marker2.CYLINDER
marker2.action = marker2.ADD
marker2.pose.position.x = -5
marker2.pose.position.y = 4
marker2.pose.position.z = 0
marker2.scale.x = 1.0
marker2.scale.y = 1.0
marker2.scale.z = 0.01
marker2.color.r = 1.0
marker2.color.g = 0
marker2.color.b = 0
marker2.color.a = 0.7
marker2.lifetime = rospy.Duration.from_sec(0)
marker2.frame_locked = 0
markerArray.markers.append(marker2)

while not rospy.is_shutdown():
    pub.publish(markerArray)

Also when I do rostopic echo on the topic, it shows both markers being published, so that confused me as well.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-06-13 09:36:24 -0500

gvdhoorn gravatar image

You're not setting the id field (see docs/api/visualization_msgs/Marker), so it will default to 0 and makes both your markers use the same id. RViz receives a message containing a marker with the same id, and interprets it as an 'update' to the same marker it saw before. Result: you see only a single marker.

edit flag offensive delete link more

Comments

This fixed it, thank you!

Thalaiva gravatar image Thalaiva  ( 2016-06-13 09:42:52 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-06-13 09:25:46 -0500

Seen: 1,165 times

Last updated: Jun 13 '16