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.
Originally posted by Thalaiva on ROS Answers with karma: 15 on 2016-06-13
Post score: 1