Ask Your Question
0

How to show multiple LINE_STRIPs?

asked 2017-05-17 02:10:18 -0500

Ben Chern gravatar image

I want to show the boundaries of the road. The boundary has many points, I use LINE_STIP to do this. But as the road has two boundaries, although I give them different id, RViz still connect the end point of boundary1 to the start point of boundary2. Is there any method to make boundary1 and boundary2 not connect with each other?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2017-05-17 02:20:04 -0500

rbbg gravatar image

The easiest way to do so is by creating two separate LINE_STRIP markers, inserting them both in a MarkerArray and publishing that. There are a few sentences about the MarkerArray in the rviz/DisplayTypes/Marker page, but there doesn't seem to be a specific tutorial. Anyhow, it's identical to how you deal with Markers, but you have to publish a MarkerArray now and load the corresponding plugin in RVIZ.

edit flag offensive delete link more

Comments

In my previous code, I just use one marker and give it different id every time. It seems it doesn't work. I tried to create two markers, and each publishes a line_strip. Now they are not connected in RViz. Thanks for your suggestion.

Ben Chern gravatar image Ben Chern  ( 2017-05-17 03:21:07 -0500 )edit
0

answered 2021-05-13 09:14:10 -0500

jitske gravatar image

As mentioned here above, you can use a MarkerArray for this. Here is my example:

ros::Publisher viz_linearconstraints_pub_;
viz_linearconstraints_pub_ = nh.advertise<visualization_msgs::MarkerArray>("/linearconstraints_viz", 1);

visualization_msgs::MarkerArray linear_constraints;

for (int i = 0; i < linear_constraints_.halfspaces.size() - 4; i++){
    visualization_msgs::Marker line;
    line.type = visualization_msgs::Marker::LINE_STRIP;
    line.ns = "linear_constraints";

    line.id = i;
    line.action = visualization_msgs::Marker::ADD;
    line.scale.x = 1;
    line.color.g = 1.0;
    line.color.a = 1.0;

    geometry_msgs::Point p;
    p.x = -20*i;
    p.y = 10;
    p.z = 0;
    line.points.push_back(p);

    p.x = 20*i;
    p.y = -10;
    p.z = 0;
    line.points.push_back(p);

    line.header.frame_id = "map";
    linear_constraints.markers.push_back(line);
}
viz_linearconstraints_pub_.publish(linear_constraints);
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

1 follower

Stats

Asked: 2017-05-17 02:10:18 -0500

Seen: 447 times

Last updated: May 17 '17