From: Robert R. <tif...@ho...> - 2006-04-06 20:16:35
|
Help! ok, I tried to boil down the pyode tutorial 3 to a very simple 38 line program just to test it. There are only two bodies - a plane and a box. The print function at the bottom is the only output. In theory, the box should fall and stop. Interestingly, the callback seems to be called at the correct time (when z is just less than 5) but the box falls too far (say -20) and then bounces too high (back to near 46). It's like the plane is made of very soft rubber. Tutorial 3 does not display this behavior - the blocks fall and stop. I have been playing with this code far too long - adjusting various parameters (bounce, etc) with no luck. I must be missing something obvious... Any help would be greatly appreciated. Thanks! Here is the code: import ode def near_callback(args, geom1, geom2): contacts = ode.collide(geom1, geom2) world, contactgroup = args for c in contacts: c.setBounce(0.2) c.setMu(5000) j = ode.ContactJoint(world, contactgroup, c) j.attach(geom1.getBody(), geom2.getBody()) contactgroup = ode.JointGroup() world = ode.World() world.setGravity( (0, 0, -9.81) ) world.setERP(0.8) world.setCFM(1E-5) space = ode.Space() floor = ode.GeomPlane(space, (0,0,1), 0) body = ode.Body(world) M = ode.Mass() M.setBox(10000, 10, 10, 10) body.setMass(M) geom = ode.GeomBox(space, (10, 10, 10)) geom.setBody(body) body.setPosition((50, 50, 50)) fps = 80.0 dt = 1.0/fps while True: pos = body.getPosition() print 'z = ', pos space.collide((world, contactgroup), near_callback) world.step(dt) contactgroup.empty( |