Learning PyODE
Due to my constant frustration in implementing simple physics in games, I decided that this coming Pyweek will be a good opportunity for me to get acquainted with PyODE. I'm not sure yet whether I'll do anything that will require physics simulation. But screw it. I'm learning something that's going to be useful for me later.ANYWAYS, there's some problems that I ran through already and I thought I'd share them with you:
- PyODE leaves the task of keeping track of instances of things to you. Anything that you let fall out of scope will be lost. That means if you connect object A to object B with a connector C, and you let connector C fall out of scope, you'll find that the connection between A and B has been completely lost.
- I've been trying to create a simulation (code below) of this experiment (link below) where metronomes are placed on top of a freely moving object, and it turned out that the situation I actually simulated is a different one. A group of out-of-phase pendulums attached to another pendulum is not the same as a group of out-of-phase pendulums attached to a freely moving object. It looks like I'll still have to learn a few more things in PyODE before I can simulate the experiment correctly.
- I need someone to correct my vocabulary in describing the experiment above, if anyone knows better and would be so kind to do so. =)
(log in to comment)
Comments
Also, I just realized that I might not need collision detection yet if I use a piston-like joint at the side of the base instead of two ball joints at the top.
I'll post results later.
I may not be understanding the setup, though, because these anchor points are definitely moving. I printed out the coordinates for the one on the right, and it gets almost 1 unit away from its starting point at (12,12), and settles around 0.5 units away.
I'm gonna read more on ODE, maybe I'm missing something important, or maybe the precision needed to correctly simulate this experiment is too much.
New code.
This initial condition seems to synchronize them in the same direction:
pendulum_balls = [(0, 8, 0), (9, 4, 0)]
pendulum_joints = [(5, 8, 0), (12, 8, 0)]
shundread on 2011/03/09 17:38:
To see what has stolen a couple of hours of my time, comment out line 74 and see what happens.=(