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) |