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();
}
}
According to http://wiki.ros.org/rviz/Tutorials/Ma... that was added in Indigo. Are you using Indigo?
Yes, definitely on indigo
I think I have an idea of what the problem might be, can you open a ticket on rviz: https://github.com/ros-visualization/...
Just did. Thanks for looking into this.
Does this work now? Can someone give a brief code example?