See previous published Markers in Rviz
New to ROS
I have a robot moving around a room. Receive data from the laser scan obtaining a cloud point in the camera's frame and I want to extract significant lines to finally obtain a "linear-model" of the map.
To publish the lines I use Markers and publish them to a topic.
I want to represent the map on Rviz while the robot is moving. This is the way I publish the markers on each iteration:
msg = Marker()
msg.header.stamp = rospy.Time.now()
msg.header.frame_id = frame
msg.ns = ns
msg.id = marker_id
msg.type = msg.LINE_LIST
msg.action = msg.ADD
msg.pose.position.x = 0.0
msg.pose.position.y = 0.0
msg.pose.position.z = 0.0
msg.pose.orientation.x = 0.0
msg.pose.orientation.y = 0.0
msg.pose.orientation.z = 0.0
msg.pose.orientation.w = 1.0
msg.scale.x = 0.01
msg.scale.y = 0.0
msg.scale.z = 0.0
msg.color.r = color[0]
msg.color.g = color[1]
msg.color.b = color[2]
msg.color.a = 1.0
for i in range(lines.shape[0]):
msg.points.append(Point(lines[i, 0], lines[i, 1], 0))
msg.points.append(Point(lines[i, 2], lines[i, 3], 0))
# Publish
pub.publish(msg)
Rviz only shows the last Markers received. I tried to save all lines and send it in every iteration but on every iteration the robot is in a diferent position so the data is in a diferent frame. I think that should be possible to make Rviz not clean the lasts Markers just to see it all time.
Thanks a lot