HI Doug, 

our students tried the correct interface (using setBrightness(n)) but
got a similar error.

The problem seems to be as below:

> AttributeError: BulbDevice instance has no attribute '__getitem__'

We're using a TkPioneer which is a subclass of TkRobot, subclassing
SimRobot.  SimRobot has a method addDevice, which we use:

>    sim.addRobot(60000, TkPioneer("RedPioneer",
>                                   4.99, 1.32, 6.28,
>                                   ((.225, .225, -.225, -.225),
>                                    (.175, -.175, -.175, .175)),
>                                   "red"))
>     # add some sensors:
>     sim.robots[0].addDevice(PioneerFrontSonars())
>     sim.robots[0].addDevice(BulbDevice(0.226, 0))

This works ok!  We get a little robot with a light on his head!

Adding the device used the method addDevice in class SimRobot:

> def addDevice(self, dev):
>         self.devices.append(dev)
>         if dev.type not in self.builtinDevices:
>             self.builtinDevices.append(dev.type)
>         if dev.type == "bulb":
>             self.simulator.lights.append( dev )
>             dev.robot = self
>             self.bulb = dev
<snip>  etc...

But when we try to do this:
    
> print "bulb is",    sim.robots[0].bulb[0]

we get the error :

    print "bulb is",    sim.robots[0].bulb[0]
AttributeError: BulbDevice instance has no attribute '__getitem__'


Now, the Device class has a __getitem__ method but looking in pysim.py
shows that class BulbDevice is a child of class Light.  And class Light
ISN'T a child of class Device.

I'm confused!  Where do I go from here?

regards

Matt  


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

Reply via email to