[ODE] Trebuchet demo

Brent Burton brentb at io.com
Tue Apr 27 10:23:50 MST 2004


Hi all,

To learn the ODE API and joint types, I wrote a little demo program that
simulates a trebuchet(*), and launches a projectile at a distant target.  
The treb model uses hinges and sliders to model the constrained arm
motion.

In reality, a projectile is attached to the treb arm by a cord, with a
metal ring at the end opposite the projectile.  The ring slips over a
short pin that is attached to the end of the arm. As the arm swings, the
projectile swings further out, and eventually the ring slips off the pin,
launching the object.  Counter weight mass, arm length, arm mass, axle
position, pin angle, cord length and projectile mass all affect how
efficient the machine is.

In ODE, the counter weight is on a vertical slider, attached to the arm
with a hinge.  The arm's axle is on a horizontal slider. The ring-pin
connection is yet another slider whose position is checked at each sim
step to see if the ring position is longer than the pin length (and
therefore released).

One other demo aspect is how the viewpoint is changed relative to
a moving object.  Press 'p' to toggle projectile following (turn it
on to follow the projectile on its descent).

The source and a binary are available at 
  http://www.io.com/~brentb/trebode.zip
The binary is precompiled for Windows (cygwin), but you don't have
to have Cygwin installed -- it'll still run from its directory.

One problem I've run into is a crash when the number of boxes in the
target wall is increased (more than the 10 now).  I've read about the
Win32 stack size issue, but as far as I can tell, the treb program is
compiled like the ODE test_crash.exe, and test_crash runs fine (155
boxes).  As a test, I also built everything with MSVC 6, and used
  editbin /STACK:16000000 treb.exe
to set the stack size to a whopping 16MB which didn't fix it.
Anyway, I haven't found this issue yet.

cheers,
-Brent


(*)The particular design is a "floating arm trebuchet" originally designed
by Ron Toms; more info at www.trebuchet.com.



More information about the ODE mailing list