From: Ethan Glasser-C. <gl...@cs...> - 2006-11-02 01:07:18
Attachments:
signature.asc
ode12.py
|
Hi, In a project I'm working on, there are objects which are "static", which means they affect objects without objects affecting them back. So an object can be joined using a joints to a "static" object, and the static object will pull the other object along without changing velocity. I've been having a hard time figuring out how to simulate those objects. Enclosed is my current approach. Body2 is joined, via body1, to a static object which isn't actually in the simulation -- let's call it "body0". Body0 moves in the negative y direction at 50 units per second, so body1's position is forced to match body0 every tick. After about 40 ticks, this causes my simulation to freak out and move objects to (nan, nan, nan). Is there a better approach to simulate this kind of thing? If not, how can I work around this behavior? I've tried playing with CFM and ERP parameters, both global and of the joints, but haven't found anything useful. Ethan |
From: Hart's A. <bha...@ya...> - 2006-11-02 01:45:50
|
Hi Ethan, not sure if this will do what you want, but when i want to make an object follow a point i use a magnet function, it won't be perfect, it will slip a little, try adjusting the value of magnet target = vec3( x,y,z ) magnet = 100 v1 = vec3( body.getPosition() ) v2 = target-v1 body.addForce( v2.normalize()*magnet ) -brett --- Ethan Glasser-Camp <gl...@cs...> wrote: > Hi, > > In a project I'm working on, there are objects which are "static", > which means they affect objects without objects affecting them back. > So an object can be joined using a joints to a "static" object, and > the static object will pull the other object along without changing > velocity. > > I've been having a hard time figuring out how to simulate those > objects. Enclosed is my current approach. Body2 is joined, via body1, > to a static object which isn't actually in the simulation -- let's > call it "body0". Body0 moves in the negative y direction at 50 units > per second, so body1's position is forced to match body0 every tick. > After about 40 ticks, this causes my simulation to freak out and move > objects to (nan, nan, nan). > > Is there a better approach to simulate this kind of thing? If not, how > can I work around this behavior? I've tried playing with CFM and ERP > parameters, both global and of the joints, but haven't found anything > useful. > > Ethan > > import ode > import math > > world = ode.World() > world.setCFM(1e-8) > > # Create two bodies > body1 = ode.Body(world) > body1.setPosition((0,0,0)) > j0 = ode.HingeJoint(world) > j0.attach(ode.environment, body1) > j0.setAxis((0, 0, 1)) > j0.setAnchor((0, 0, 0)) > > body2 = ode.Body(world) > body2.setPosition((200, 0, 0)) > M = ode.Mass() > M.setSphere(2500, 0.05) > body2.setMass(M) > > j1 = ode.SliderJoint(world) > j1.attach(body1, body2) > j1.setAxis((200, 0, 0)) > j1.setParam(ode.ParamLoStop, 0) > j1.setParam(ode.ParamHiStop, 4) > > # Simulation loop... > > fps = 50 > dt = 1.0/fps > loops = 0 > > while loops < 50: > loops += 1 > print body1.getPosition(), body2.getPosition(), j1.getPosition(), j1.getPositionRate() > > def down(pos): > return pos[0], pos[1]-1, pos[2] > move = down > > body1.setPosition(move(body1.getPosition())) > j0.setAnchor(move(j0.getAnchor())) > #body2.setLinearVel((1, 0, 0)) > > # Next simulation step > world.step(dt) > > print j0.getAnchor(), body1.getPosition(), body2.getPosition(), j1.getAxis() > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642> _______________________________________________ > Pyode-user mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyode-user > ____________________________________________________________________________________ Get your email and see which of your friends are online - Right on the New Yahoo.com (http://www.yahoo.com/preview) |
From: Ethan Glasser-C. <gl...@cs...> - 2006-11-02 04:17:08
Attachments:
signature.asc
|
Hart's Antler wrote: > Hi Ethan, >=20 > not sure if this will do what you want, but when i want to make an obje= ct follow a point i use a > magnet function, it won't be perfect, it will slip a little, try adjust= ing the value of magnet >=20 > target =3D vec3( x,y,z ) > magnet =3D 100 > v1 =3D vec3( body.getPosition() ) > v2 =3D target-v1 > body.addForce( v2.normalize()*magnet ) This is a useful stopgap, thanks. I see that the ODE manual says: "How can an immovable body be created? In other words, how can you create a body that doesn't move, but that interacts with other bodies? The answer is to create a geom only, without the corresponding rigid body object. The geom is associated with a rigid body ID of zero. Then in the contact callback when you detect a collision between two geoms with a nonzero body ID and a zero body ID, you can simply pass those two IDs to the dJointAttach function as normal. This will create a contact between the rigid body and the static environment. Don't try to get the same effect by setting a very high mass/inertia on the "motionless" body and then resetting it's position/orientation on each time step. This can cause unexpected simulation errors." I guess what I'm doing is much like that, resetting its position every time step, and I'm not surprised that it causes errors. But what I'd like, ideally, to do, is, well, make an immovable body that moves. :) This is what I called "static" in my original email. The above recipe works fine until you add joints; once that happens, the static object's velocity can be altered, which isn't what I want. Maybe the best solution is to make a new kind of joint. I'll look into this possibility next. Ethan |