ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

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

asked 2011-04-19 20:23:24 -0600

Markus Bader gravatar image

updated 2011-06-17 10:29:15 -0600

kwc gravatar image

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);
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2011-06-17 10:31:32 -0600

kwc gravatar image

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
edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-04-19 20:23:24 -0600

Seen: 807 times

Last updated: Jun 17 '11