Ask Your Question
0

colors does not work on basic rviz markers like LINE_LIST and others

asked Apr 20 '11

Markus Bader gravatar image Markus Bader
196 2 10

updated Jun 17 '11

kwc gravatar image kwc
7078 23 67 117
http://kwc.org/

Hi

I like to publish marker (lines) with different colors for rviz on diamondback back. Therefore i like to use LINE_LIST markers, but the colors entry of the marker are ignored. Every line has the same color if I use the marker.color or does not show up at all if I use the markers.colors[] array? Same on POINTS, LINE_STRIP, ...

visualization_msgs::Marker marker;
marker.header.frame_id = frame_id_;
marker.header.stamp = ros::Time::now();
marker.ns = ns_name;
marker.id = 0;
marker.type = visualization_msgs::Marker::LINE_LIST;
marker.points.resize(n*2);
for (unsigned int i = 0; i < n; i++) {
    cv::Point3d p0 = mFilter[i]->location();
    cv::Point3d p1 = mFilter[i]->location(sec);

    marker.points[i*2].x = p0.x;
    marker.points[i*2].y = p0.y;
    marker.points[i*2].z = p0.z;
    marker.points[i*2+1].x = p1.x;
    marker.points[i*2+1].y = p1.y;
    marker.points[i*2+1].z = p1.z;
    /// Just a internal call to define the color 
    marker.colors[i] = markerColorBySet(mFilter[i]->idSet()); 
}
marker.scale.x = 10;
marker.scale.y = 10;
marker.scale.z = 10;
// using the following line works, using marker.colors[] array not
//marker.color = markerColorBySet(mFilter[0]->idSet());
marker.lifetime = ros::Duration(1.0);
rvizMarkerPub_.publish(marker);
delete close flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered Jun 17 '11

kwc gravatar image kwc
7078 23 67 117
http://kwc.org/

Are you sizing marker.colors correctly? I see a marker.points.resize but not a marker.colors.resize?

According to the docs for colors:

#Only used if the type specified has some use for them (eg. POINTS, LINE_STRIP, ...)
#number of colors must either be 0 or equal to the number of points
link delete flag offensive edit

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

Follow

subscribe to rss feed

Stats

Asked: Apr 20 '11

Seen: 112 times

Last updated: Jun 17 '11