Dave Zoltok wrote:
Hi!

I'm working on an experiment that requires robots to change the colour of the light bulb they contain. Is there a way to assign a robot a color using the 0-255 RGB values in the color map? Or alternately, to look up the closest match to the values that are produced by the robot controller?

Dave,

If you are referring to the Python simulator, then:

It looks like the color of the bulb is set to be the color of the robot; in file pyrobot/plugins/simulators/pysim.py line 2556. You could make that be a different color if you wanted. These are Tk color names.

The colors are listed in pysim.py via a dictionary with "name" -> RGB tuple:

colorMap = {
    "aliceblue": (240, 248, 255),
    "antiquewhite": (250, 235, 215),
    "antiquewhite1": (255, 239, 219),
    "antiquewhite2": (238, 223, 204),
    "antiquewhite3": (205, 192, 176),
 ...
}

You could find the closest to those for arbitrary RGB values.

Programmatically, you can change the color of a robot, like this (at the Pyro IDE prompt):

>>>  robot.simulation[0].eval("self.robots[0].color")
red
>>>  robot.simulation[0].eval("self.robots[0].color = 'blue'")
ok
>>>  robot.simulation[0].eval("self.redraw()")
ok

Hope that helps,

-Doug


Dave
_______________________________________________
Pyro-users mailing list
[email protected]
http://emergent.brynmawr.edu/mailman/listinfo/pyro-users


_______________________________________________
Pyro-users mailing list
[email protected]
http://emergent.brynmawr.edu/mailman/listinfo/pyro-users

Reply via email to