publishing marker points python
I have some problems publishing markers in a python node to visualize them on rViz. I have a node that calculates some static points and I want to visualize them (like a path). I also have a robot moving and I want to drop some marks when it reaches some points. I don't want to make an infinite cycle to visualize them, otherwise the rest of the code will not go on. Here is a method that I wrote to visualize the points in the path and it worked sometimes, now I don't know why does never appear anything on rViz:
def print_points(self, points, frame):
rate = rospy.Rate(5)
triplePoints = []
#transform from x,y points to x,y,z points
for (x,y) in points:
p = Point()
p.x = x
p.y = y
p.z = 0
triplePoints.append(p)
iterations = 0
while not rospy.is_shutdown() and iterations <= 10:
pub = rospy.Publisher(frame, Marker, queue_size = 100)
marker = Marker()
marker.header.frame_id = "/map"
marker.type = marker.POINTS
marker.action = marker.ADD
marker.pose.orientation.w = 1
marker.points = triplePoints;
t = rospy.Duration()
marker.lifetime = t
marker.scale.x = 0.4
marker.scale.y = 0.4
marker.scale.z = 0.4
marker.color.a = 1.0
marker.color.r = 1.0
pub.publish(marker)
iterations += 1
rate.sleep()
As you can see I tried to use the lifetime and 0 should mean infinite time. I also published the points more times because I've seen that sometimes rviz needed 2-3 times to receive the points. Now it doesn't work anymore.