Ask Your Question
2

Delete all rviz markers

asked 2015-03-18 16:04:19 -0500

jess gravatar image

Hi,

On the tutorial ( http://wiki.ros.org/rviz/Tutorials/Ma... ) and docs for the visualisation markers, there's supposed to be an option for action "DELETEALL" which would remove all markers. I've tried this and it has not deleted any markers. Is this function actually in effect? Is there anything else I need to specify apart from marker.action?

Thanks, Jess

edit retag flag offensive close merge delete

Comments

According to http://wiki.ros.org/rviz/Tutorials/Ma... that was added in Indigo. Are you using Indigo?

William gravatar image William  ( 2015-03-18 16:27:43 -0500 )edit

Yes, definitely on indigo

jess gravatar image jess  ( 2015-03-18 17:25:06 -0500 )edit

I think I have an idea of what the problem might be, can you open a ticket on rviz: https://github.com/ros-visualization/...

William gravatar image William  ( 2015-03-18 19:24:58 -0500 )edit

Just did. Thanks for looking into this.

jess gravatar image jess  ( 2015-03-18 19:59:45 -0500 )edit

Does this work now? Can someone give a brief code example?

atp gravatar image atp  ( 2015-10-19 11:03:12 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-03-18 22:25:24 -0500

jess gravatar image

I ended up using rviz_visual_tools::RvizVisualTools and calling deleteAllMarkers() - did the trick for me.

edit flag offensive delete link more
0

answered 2021-03-26 00:38:03 -0500

surajj4837 gravatar image

updated 2021-03-27 20:51:41 -0500

jayess gravatar image

I m using ROS Noetic in Ubuntu 20.04. Please see following code which creates 2 lines in each message and publishes over ROS network. When one message is received the previous message's lines are deleted. Includes are <ros ros.h=""> and <visualization_msgs marker.h="">. (I m not able to add screen recording here to show how it is seen in RViz.)

int main( int argc, char** argv ) 
{
  ros::init(argc, argv, "points_and_lines");
  ros::NodeHandle n;
  ros::Publisher marker_pub = n.advertise<visualization_msgs::Marker>("visualization_marker", 10);
  ros::Rate r(1);

  int count = 0;

  visualization_msgs::Marker markerD;

  // Set the frame ID and timestamp.  See the TF tutorials for information on these.
  markerD.header.frame_id = "map";    
  markerD.action = visualization_msgs::Marker::DELETEALL;    
  geometry_msgs::Point p;

  while (ros::ok())
  {    
    visualization_msgs::Marker line_list;
    line_list.header.frame_id = "map";
    line_list.ns = "points_and_lines";
    line_list.action = visualization_msgs::Marker::ADD;
    line_list.pose.orientation.w = 1.0;
    line_list.type = visualization_msgs::Marker::LINE_LIST;
    line_list.scale.x = 0.1;
    line_list.header.stamp = ros::Time::now();
    // Line list is red
    line_list.color.r = 1.0;
    line_list.color.a = 1.0;

    marker_pub.publish(markerD);

    line_list.id = count;

    //Create end points of 1st line
    p.x = count;
    p.y = 0;
    p.z = 0;
    line_list.points.push_back(p);
    p.z += 1.0;
    line_list.points.push_back(p);

    //Create end points of 2nd line
    p.x = count;
    p.y = 2;
    p.z = 2;
    line_list.points.push_back(p);
    p.z += 1.0;
    line_list.points.push_back(p);

    count++;

    marker_pub.publish(line_list);

    r.sleep();
  }   
}
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2015-03-18 16:04:19 -0500

Seen: 5,280 times

Last updated: Mar 27