From: <al...@ci...> - 2010-05-12 20:48:18
|
Since the patch file is too large, I have compressed it in order to reach the mailing list. > Hello, > > Here is the patch for accessing joint parameters as properties. > > Examples: > > j = ode.HingeJoint(world) > j.param.lo_stop = 0 > j.param.cfm = 1e-5 > j.param.vel = 0.1 > > For complex joints: > joint.param[1].fmax = 1 > joint.param[2].fmax = 2 > joint.param[3].fmax = 3 > > And for Plane2D: > joint.paramX.cfm = 1e-5 > joint.paramY.cfm = 1e-10 > joint.paramAngle.cfm = 1e-10 > > Or: > joint.param['X'].cfm = 1e-5 > joint.param['Y'].cfm = 1e-10 > joint.param['Angle'].cfm = 1e-5 > > > The patch also contains PUJoint, PRJoint, PistonJoint and Joint.enable/disable, > so it can be applied > against latest git revision. > > > I have tried to use 'Strip trailing spaces' in the editor, but now I have > another problem. > There are a lot of lines in the patch which do not change anything. > e.g. (instead of dots, there are spaces): > -.... > - BallJoint(world, jointgroup=None).... > + > + BallJoint(world, jointgroup=None) > > How should I get rid of these? Manually editing the patch? Git Gui does not help > me > (i.e. 'Stage/Unstage hunk from commit' does not work properly, and messes the > entire patch) > > Alex > >> al...@ci... wrote: >>> In ode.pyx there is a comment: >>> >>> ## This causes some kind of weird bug! Need to fix this. >>> >>> import weakref >>> >>> _geom_c2py_lut = weakref.WeakValueDictionary() >>> >>> In my programs, sometimes the lut is not able to find the geom ID, >>> and Space.collide_callback() fails with a KeyError. When this happens, >>> some boxes pass through the floor and fall down to -infinity. >>> Using a normal dictionary seems to solve the problem. >>> >>> Is this the weird bug? >> >> It sounds related but this isn't exactly the bug I was confused about >> when I wrote that comment. The bug is that if you create Geoms but don't >> save references to them, (like the "geoms" list in tutorial 3) then the >> geoms get garbage collected and they therefore don't have any collisions. >> >> Your bug sounds related, because it seems like geoms are getting garbage >> collected, but if that's true, then they should be getting destroyed >> with dGeomDestroy() and so not causing collisions. >> >>> Therefore, we have two possibilities to solve the conflict: >>> >>> A) Overriding __setattr__: >>> >>> Pros: - compatible with existing code >>> >>> Cons: - may be slow (overriding __getattr__ and __setattr__ slows down the >>> access to class items) >>> - you are not warned at all if you misspell the name of a property >>> (e.g. you use body.pos = (1,2,3) but the correct name is >>> 'body.position'; however, python will not complain at all) >>> >>> B) Custom data field: >>> Pros: - more lightweight >>> - works fine, with no conflicts >>> - if you misspell the name of a property, you will receive an error >>> >>> Cons: - breaks existing code which uses custom data >> >> I like B better. It would be really great if we could offer a setting >> that would enable backwards-compatible behavior, though :) >> >>> Which one should we choose? I prefer B) since it already works on my >>> computer. >>> >>> I have also implemented a mechanism for accessing joint parameters as >>> properties. >>> It works like this: >>> >>> j = ode.HingeJoint(world) >>> j.param.lo_stop = 0 >>> j.param.cfm = 1e-5 >>> j.param.vel = 0.1 >>> >>> For complex joints: >>> joint.param[1].fmax = 1 >>> joint.param[2].fmax = 2 >>> joint.param[3].fmax = 3 >>> >>> And for Plane2D: >>> joint.paramX.cfm = 1e-5 >>> joint.paramY.cfm = 1e-10 >>> joint.paramAngle.cfm = 1e-10 >>> >>> Or: >>> joint.param['X'].cfm = 1e-5 >>> joint.param['Y'].cfm = 1e-10 >>> joint.param['Angle'].cfm = 1e-5 >>> >>> And of course, the joint parameters are visible at TAB completion. >> >> Sounds like a good idea to me. >> >> Ethan >> > |