Ask Your Question
-2

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

asked Mar 05 '11

Ali Abdul Khaliq gravatar image Ali Abdul Khaliq
1 1

updated Jul 03 '11

mwise_wg gravatar image mwise_wg flag of United States
3299 8 39 75
http://www.meloneewise.co...

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;
             c.b=1;
      draw.points.push_back(p);
      draw.colors.push_back(c);
}
marker_pub.publish(draw);

thanks for the help.

delete close flag offensive retag edit

Comments

Please update your question to say what you see on the screen and what you expect to see when you render. tfoote (Mar 05 '11)edit

1 Answer

Sort by ยป oldest newest most voted
2

answered Mar 07 '11

hersh gravatar image hersh
646 4 9 14

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.

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: Mar 05 '11

Seen: 132 times

Last updated: Jul 03 '11