Reputation: 1
I am not a big user but find BOX2D for creating the basis for realistic led light effects. Iteration time is not a big issue because I am not trying to achieve scene realism. For some time I have had a programme running to generate a fountain effect. It runs under Python2.7.12, Ubuntu but I don't know the version of Box2D.
Now I want to run the same on a RaspberryPi ideally under Python3 but presently under Python2.7.12.
The code fails at the point where "restitution" is defined:
body = world.CreateStaticBody(
position=(0, 10),
allowSleep=False,
restitution=0.7,
shapeFixture=Box2D.b2FixtureDef(density=20.0),
userData=time.time(),
shapes=[
Box2D.b2PolygonShape(box=(14, 0.1, (0,-7), 0)),
Box2D.b2PolygonShape(box=(14, 0.1, (0,7), 0)),
Box2D.b2PolygonShape(box=(0.1, 7, (0,0), 0)),
Box2D.b2PolygonShape(box=(0.1, 7, (14,0), 0)),
# Box2D.b2CircleShape(pos=(7,0),radius=0.5),
]
)
The error is blah, blah ...
File "/home/pi/.local/lib/python2.7/site-packages/Box2D/Box2D.py", line 152, in _init_kwargs
raise AttributeError('Invalid keyword argument "%s" for %s' % (key, cls))
AttributeError: Invalid keyword argument "restitution" for <class 'Box2D.Box2D.b2BodyDef'>
Of course the code might also be failing later but when I comment out the offending statement it seems to run through to completion ok.
My question is how do I go about diagnosing the problem?
PS. The original installation on Ubuntu works fine but there when I enter into the Python shell "body.restitution" I get the return:
AttributeError: 'b2Body' object has no attribute 'restitution'
So where is the field being stored in this (working) case.
Upvotes: 0
Views: 227
Reputation: 1
Michael Mahn helped me solve the problem.
The code sample I posted was incorrect in attributing restitution to a body. I think I picked up that example from another example posted on-line and it has worked now for some years, why it has not caused an error before I don't know. Perhaps a latter update has now caused the error to be flagged.
Upvotes: 0