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:
  1. 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.
  2. 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.
  3. 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

To see what has stolen a couple of hours of my time, comment out line 74 and see what happens.

=(
I'm not too familiar with PyODE, but I know some physics. Am I reading it right that the two balls at the top are "immovable"? If so, why are they moving?
Well, they're supposed to be. Best way to find out how much they're moving is to print out their coordinates, Maybe I'll add that to the next version.

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.
Yes, a piston-like joint would probably be closer to the original experiment. I don't see why your current setup with the double pendulum wouldn't work, though, as long as the bar's swing was small enough that it's almost linear.

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've changed the support of the "base" object. The pendulums still do not synchronize. =|

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.

I think one problem is that your bar is too strong to allow energy to transfer between the pendulums. I tried decreasing the bar's mass by a factor of 1000 and eliminating the middle two pendulums, then let it run with just the outer two pendulums. They did synchronize after a few minutes, but in opposite directions. I think that might also be a stable configuration.

 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)]
Hi, I haven't checked it out yet, but I should soon. I decided to check Minecraft out and playing it has been pretty much all that I have done in my free time after that. =(