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

std_msgs/ColorRGBA[].displaying different color for each point

asked 2011-03-05 10:03:46 -0500

closed gravatar image

updated 2014-01-28 17:09:17 -0500

ngrennan gravatar image

Hello sir,

I am trying to display different color for each point. I am able to display points with single color using:

             draw.color.b = 1.0;
             draw.color.a = 1.0;

but in am unable to display points with different colors. my lines of code is:

for(int i =0;i<=5;i++)


geometry_msgs::Point p;

     std_msgs::ColorRGBA c;
      p.x =i;
      p.y = 1;
      p.z = 1;
             c.r = 1;
             c.g = 1;

thanks for the help.

edit retag flag offensive close merge delete


Please update your question to say what you see on the screen and what you expect to see when you render.
tfoote gravatar image tfoote  ( 2011-03-05 13:02:42 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2011-03-07 04:54:22 -0500

hersh gravatar image

In the code you posted, the color is the same (white) for all the points: r=g=b=1. Maybe you meant to have something like: c.r = 0; c.g = 0; c.b = float(i)/5; Which would give you a spread from black to blue.

edit flag offensive delete link more

Question Tools


Asked: 2011-03-05 10:03:46 -0500

Seen: 1,685 times

Last updated: Jul 03 '11