From Matthew2.Studley at uwe.ac.uk Wed Mar 25 08:18:13 2009 From: Matthew2.Studley at uwe.ac.uk (matt studley) Date: Wed Mar 25 08:19:43 2009 Subject: [Pyro-users] bulb error pyrobot 5.0 Message-ID: <1237983493.6530.61.camel@studley> Hi all does anybody have any advice on this? One of our students is attempting to set the brightness on a bulb on a robot. Pyrobot version 5.0 on Debian returns the following error: Using PYROBOT on posix with CPU 0 in '/usr/pyrobot'... Loading.Attempting to import 'Braitenberg2Lights1RobotBlueGreen'... Loaded '/home/netlab/dagrubb/pyrobot/plugins/worlds/Pyrobot/Braitenberg2Lights1RobotBlueGreen.pyc'! Traceback (most recent call last): File "/home/netlab/dagrubb/pyrobot/plugins/simulators/PyrobotSimulator", line 83, in gui = INIT(worldFile) File "/home/netlab/dagrubb/pyrobot/plugins/simulators/PyrobotSimulator", line 26, in INIT retval = userspace.INIT() File "/home/netlab/dagrubb/pyrobot/plugins/worlds/Pyrobot/Braitenberg2Lights1RobotBlueGreen.py", line 31, in INIT sim.robots[0].bulb[0].brightness = 40 #.setBrightness(40) AttributeError: BulbDevice instance has no attribute '__getitem__' any advice would be very helpful! regards Matt -- - - - - - - - - - - - - - - - - - - - - - - Dr Matthew Studley Senior Lecturer Bristol Robotics Laboratory Room 3Q75 University of the West of England Coldharbour Lane Bristol BS16 1QY +44 117 328 2671 This email was independently scanned for viruses by McAfee anti-virus software and none were found From dblank at cs.brynmawr.edu Wed Mar 25 08:36:03 2009 From: dblank at cs.brynmawr.edu (Douglas S. Blank) Date: Wed Mar 25 08:35:35 2009 Subject: [Pyro-users] bulb error pyrobot 5.0 In-Reply-To: <1237983493.6530.61.camel@studley> References: <1237983493.6530.61.camel@studley> Message-ID: <57712.71.59.120.170.1237984563.squirrel@cs.brynmawr.edu> Looks like the interface is actually: robot.bulb[0].setBrightness(40) (I'm looking at the fireflies world in that directory). Let us know if that doesn't work. -Doug > Hi all > > does anybody have any advice on this? One of our students is attempting > to set the brightness on a bulb on a robot. Pyrobot version 5.0 on > Debian returns the following error: > > Using PYROBOT on posix with CPU 0 in '/usr/pyrobot'... > Loading.Attempting to import 'Braitenberg2Lights1RobotBlueGreen'... > Loaded > '/home/netlab/dagrubb/pyrobot/plugins/worlds/Pyrobot/Braitenberg2Lights1RobotBlueGreen.pyc'! > Traceback (most recent call last): > File > "/home/netlab/dagrubb/pyrobot/plugins/simulators/PyrobotSimulator", line > 83, in > gui = INIT(worldFile) > File > "/home/netlab/dagrubb/pyrobot/plugins/simulators/PyrobotSimulator", line > 26, in INIT > retval = userspace.INIT() > File > "/home/netlab/dagrubb/pyrobot/plugins/worlds/Pyrobot/Braitenberg2Lights1RobotBlueGreen.py", > line 31, in INIT > sim.robots[0].bulb[0].brightness = 40 #.setBrightness(40) > AttributeError: BulbDevice instance has no attribute '__getitem__' > > > any advice would be very helpful! > > regards > > Matt > > -- > - - - - - - - - - - - - - - - - - - - - - - > Dr Matthew Studley > Senior Lecturer > Bristol Robotics Laboratory > > Room 3Q75 > University of the West of England > Coldharbour Lane > Bristol BS16 1QY > > +44 117 328 2671 > > > > This email was independently scanned for viruses by McAfee anti-virus > software and none were found > _______________________________________________ > Pyro-users mailing list > Pyro-users@pyrorobotics.org > http://emergent.brynmawr.edu/mailman/listinfo/pyro-users > From matthew2.studley at uwe.ac.uk Wed Mar 25 16:12:43 2009 From: matthew2.studley at uwe.ac.uk (Matthew Studley) Date: Wed Mar 25 16:12:05 2009 Subject: [Pyro-users] Re: Pyro-users Digest, Vol 60, Issue 1 In-Reply-To: <200903251600.n2PG02CB010215@emergent.brynmawr.edu> References: <200903251600.n2PG02CB010215@emergent.brynmawr.edu> Message-ID: <1238011963.7022.62.camel@titanium.clocksoft.dom> 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 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 From dblank at cs.brynmawr.edu Thu Mar 26 14:27:20 2009 From: dblank at cs.brynmawr.edu (Douglas S. Blank) Date: Thu Mar 26 14:26:51 2009 Subject: [Pyro-users] Re: Pyro-users Digest, Vol 60, Issue 1 In-Reply-To: <1238011963.7022.62.camel@titanium.clocksoft.dom> References: <200903251600.n2PG02CB010215@emergent.brynmawr.edu> <1238011963.7022.62.camel@titanium.clocksoft.dom> Message-ID: <49CBC908.7030202@cs.brynmawr.edu> Matthew Studley wrote: > 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 > 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? Ok, I think that you might be talking about two different interfaces: 1) the server-side simulator 2) the client-side robot The client-side robot doesn't have an interface to the simulator (well, not directly... you have to use the robot.simulation[0] device). BUT, your code sample shows that you are combing sim with .bulb[0]. If you want to set the bulb brightness on the server side, then you would use something like: sim.robots[0].bulb.brightness [We should make the two sides of the interface parallel... sigh... next time!] Only one bulb per robot, it appears. -Doug > regards > > Matt > > > _______________________________________________ > Pyro-users mailing list > Pyro-users@pyrorobotics.org > http://emergent.brynmawr.edu/mailman/listinfo/pyro-users > -- Douglas S. Blank Director, Institute for Personal Robots in Education (IPRE) http://www.roboteducation.org Chair, and Associate Professor, Computer Science, Bryn Mawr College http://cs.brynmawr.edu/~dblank (610)526-6501