From: Chris S. <chr...@gm...> - 2007-06-13 03:03:09
|
Hi, I'm new to ODE/PyODE and I've been playing around with the tutorial scripts over the last week to get a feel for the library. However, there are still a few features I've had problems accessing. The attached script is based on the 2nd and 3rd PyODE tutorials, and makes use of PyGame to visualize the results in 2D, as well as Numpy to do some simple matrix multiplication to compute the rotation of polygons. Basically, the script drops a few spheres and boxes onto planes to the left, right, and bottom simulating walls and a floor. It attempts to simulate collision detection, both to stop objects from passing through each other and the planes. It also tries to detect objects in a certain area, identified by a bodiless geom box in the center of the screen. When a geom passes through that area, the collision detection code *should* turn the geom blue. If you run the script, you will notice several problems. First, while basic collision detection seems to work well enough to bounce objects off one another, there's still a lot of "mushiness", with objects routinely going partly or full way through one another. I've tried tweaking ERF/CFM but I haven't been able to improve things much. It seems at one setting the objects act mushy, and at another the simulation becomes completely unstable. I can't find a middle ground. Is there some way around this? Second, I'm unable to detect when objects enter my bodiless geom. I'm using collide2, which should return all geoms in contact with the target geom, but the results are chaotic. The callback signals a contact by changing the color of the contacting geom to blue. Some objects do change blue, but at positions that don't correspond to the target geom. Is there an error in my drawing code or am I incorrectly implementing collision detection? Third, I'm not sure I'm interpreting a geom's rotation data correctly. I allow geoms to rotate about the Z axis, and so I attempt to draw this rotation by using the rotation matrix returned by geom.getRotation(), but the results are a little confusing. The rectangle in the scene seems to correctly rotate somewhat, but there's enough error that I'm unsure whether my code's wrong or if it's simply "mushiness". Again, is this a problem with my drawing code, or with how I'm interpreting the rotation data? On a side note, I attempted to use plane2DJoint to restrict movement in the XY plane, according to http://opende.sourceforge.net/wiki/index.php/HOWTO_constrain_objects_to_2d but I was unable to get it to work. I achieved the same effect by reseting the Z position at each iteration, but I fear this may be inefficient. Is there any trick to using plane2DJoint in PyODE? I've been working on this for days now, but I'm reaching a plateau. If anyone could give me some tips or pointers, I'd be immensely grateful. Thanks, Chris |