I'm very new to Blender. I'd like to setup a very simple rigid body physics system using the game engine. The system is simply a pole hinged in the middle of a block, which can move horizontally on a plane with friction, and walls to prevent it flying off the plane. It responds to a horizontal force that acts on the block, at every frame/timestep.
It's well known in engineering as the 2D cart/pole problem, aka inverted pendulum, and the rigid body equations are well known, but in Blender we don't need them! A simulation would start with the pole upright, and then apply random forces/impulses, (actuate it), horizontally on the block. When the pole falls below horizontal, its physically impossible for it to get back to vertical, and the simulation can end.
Setting this up procedurally would be a really nice/helpful introduction to rigid bodies and actuators in the BGE. I think in terms of the BGE/Physics the only scripting needed is to use a random, applyForce(...)
or applyImpulse(...)
, on the block at each frame/timestep.
I'm not really sure that the game engine is needed for this simulation, only physics, as there is no user interaction? The output is just the sequence of rendered images, for a small time step/frames per second, and the value of the actuator/force applied at each timestep/frame.
Perhaps a the easiest place to start is from the [domino's tutotrial][4]
The things I'm stick on are,
- How to hinge the rod to the block, I think I need a constraint, OR Maybe I should use a single armature bone ?
- To apply a random force or impulse at each keyframe, I think I need something like
bpy.ops.anim.keyframe_insert
?