Ask Your Question
0

See previous published Markers in Rviz

asked 2016-12-01 15:52:14 -0500

RogerPi gravatar image

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-12-01 18:32:15 -0500

William gravatar image

I believe you're overwriting them every time because you're using the same marker id. If you increment the marker id each time, then you'll be adding a new marker each time rather than modifying the existing marker each time. You can control how long each will stay by using the lifetime field or by explicitly publishing a Marker message with the same marker id and the action delete.

If you look at the marker message, the actions ADD and MODIFY have been merged. Really it should be something like SET, where that actually means "set contents for this marker id".

edit flag offensive delete link more

Comments

Thanks! It worked fine!!!

RogerPi gravatar imageRogerPi ( 2016-12-02 04:27:59 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-12-01 15:52:14 -0500

Seen: 462 times

Last updated: Dec 01 '16