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

Revision history [back]

click to hide/show revision 1
initial version

It is defined here: Raw Message Definition, more precisely in these lines:

#Only used if the type specified has some use for them (eg. POINTS, LINE_STRIP, ...)
geometry_msgs/Point[] points
#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
#NOTE: alpha is not yet used
std_msgs/ColorRGBA[] colors

You are pushing back into points but you are missing to push back into colors (also member of the visualization_msgs/Marker message), defined in this line:

 std_msgs/ColorRGBA[] colors

This part you already have:

   segment.points.push_back(segment_a);
   segment.points.push_back(segment_b);

This part you are still missing:

  // push back one color per segment
  segment.colors.push_back(segment_a.color); // pass in any std_msgs::ColorRGBA object
  segment.colors.push_back(segment_b.color);

It is defined here: Raw Message Definition, more precisely in these lines:

#Only used if the type specified has some use for them (eg. POINTS, LINE_STRIP, ...)
geometry_msgs/Point[] points
#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
#NOTE: alpha is not yet used
std_msgs/ColorRGBA[] colors

You are pushing back into points but you are missing to push back into colors (also member of the visualization_msgs/Marker message), defined in this line:

 std_msgs/ColorRGBA[] colors

This part you already have:

   segment.points.push_back(segment_a);
   segment.points.push_back(segment_b);

This part you are still missing:

  // push back one color per segment
  segment.colors.push_back(segment_a.color); // pass in any std_msgs::ColorRGBA object
  segment.colors.push_back(segment_b.color);

The number of colors you push back has to match the number of points (you are calling them segments) that you push back.