making LINE_LIST lines different colors?
hi,
very quick summary -- how can you make each line when using LINE_LIST a different color? --
more specific: i'm using Rviz to create a bounding box around found clusters within a pointcloud. i have created the points and by using LINE_LIST, joined each pair together, giving me a bounding box around each cluster.
ideally i would like each bounding box to be a different color but i am unable to get this working. in my code below, i tried using 'j' to change the colors but only the last clusters color is chosen and that color is applied to all bounding box.
i also noticed there is a 'marker.colors' option but i was unable to get that working. there is very little documentation on it and i was not able to find any examples.
any ideas? thanks in advance for any suggestions :)
Eigen::Vector4f min_point;
Eigen::Vector4f max_point;
geometry_msgs::Point32 min_pt;
geometry_msgs::Point32 max_pt;
visualization_msgs::Marker lines;
lines.header.frame_id = "base_link";
lines.header.stamp = ros::Time::now();
lines.type = visualization_msgs::Marker::LINE_LIST;
lines.action = visualization_msgs::Marker::ADD;
lines.scale.x = 0.01;
lines.scale.y = 0.01;
lines.color.a = 1.0;
lines.ns = "my lines";
lines.id = 1;
int j = 1;
for (std::vector<pcl::PointIndices>::const_iterator it = cluster_indices.begin();
it != cluster_indices.end(); ++it)
{
pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_cluster (new pcl::PointCloud<pcl::PointXYZI>);
for (std::vector<int>::const_iterator pit = it->indices.begin(); pit != it->indices.end(); pit++)
cloud_cluster->points.push_back (inCld->points[*pit]);
cloud_cluster->width = cloud_cluster->points.size();
cloud_cluster->height = 1;
cloud_cluster->is_dense = true;
pcl::getMinMax3D (*cloud_cluster, min_point, max_point);
//minimum side face points
geometry_msgs::Point pt1;
pt1.x = max_point.x(); pt1.y = min_point.y(); pt1.z = max_point.z();
geometry_msgs::Point pt2;
pt2.x = min_point.x(); pt2.y = min_point.y(); pt2.z = max_point.z();
geometry_msgs::Point pt3;
pt3.x = max_point.x(); pt3.y = min_point.y(); pt3.z = min_point.z();
lines.points.push_back(pt1); lines.points.push_back(pt2);
lines.points.push_back(pt1); lines.points.push_back(pt3);
lines.color.r = 1.0f / j;
lines.color.g = 1.0f / j;
lines.color.b = 1.0f / j;
pub_Bbox.publish (lines);
j++;
}
}