Re: Aggressive tracking in a newtonian simulation

Darren Grant <[email protected]> Thu, 02 Dec 2010 11:52:33 -0800
Newsgroups gmane.games.devel.sweng
Message-ID <[email protected]>
At 09:51 PM 12/1/2010, Will Vale wrote:
>Hi Darren,
>
>On Tue, 30 Nov 2010 22:48:55 +1300, Darren Grant
><[email protected]> wrote:
>>>I am a programmer tasked with developing a newtonian simulation of
>>>high performance spacecraft.
>
>For I-War 2, we had what sounds like a similar setup of rigid bodies and
>requirements. We used a very simple follower for each (local space)
>angular velocity component, basically the same as the linear velocity
>component. I just looked up the code and it was something like:
>
>for each component i:
>   dv[i] = target[i] * max_speed[i] - current[i]
>   torque[i] = clamp_to_max_torque( dv[i] * moment[i] / dt )
>
>(moment is the diagonal of the MoI matrix - all our stuff was in this form)
>
>Pretty horrible stuff - especially dividing by dt - but it worked OK in
>practice. We didn't allow ridiculous speeds or torques. Our integrator was
>straight Euler, and while I thought it had some bespoke stuff in to stop
>it hunting or blowing up, I looked and couldn't find it. I'm sure I
>remember playing with this at some point, but maybe we ended up
>constraining the inputs such that it would remain stable.

This sounds a lot like what I rolled for Sots Prime. This time around 
we're working with Bullet on advice from a coworker. It is much more 
robust. For example, one tricky bit of business was conveying near 
inertia-less motion in a dynamic simulation. Kinematic sounds like 
the right answer, but then you're stuck implementing all of the 
remaining dynamic responses by hand. With Bullet I can evidently use 
extreme forces to fake the effect without the huge instabilities that 
were a problem before.


>For the NPC ships, our AI coder (Brett Laming) drove the same simulation
>by setting max angular/linear speeds. He went into more kinematic depth to
>figure out what inputs to use so that a ship would arrive at a particular
>place at a particular time (acceleration, coasting, braking). I suspect
>these days both of us might consider a less pure approach whereby the AI
>can get at the simulation at a lower level than the pilot interface so we
>wouldn't have to second-guess it so much.

It's deceptive. Simple steering behaviors are nice neat packages, but 
it is a whole other story combining these into a smart and 
interesting control system. I still really want to stitch paths 
together from simple goals using an expert planner, but producing 
achievable paths is always going to be a problem.  Abundance of force 
helps, and I hope that a kinematic API will be useful for testing 
concrete options.

I wonder how ATC engineers stay sane. ;)


>Heh. While looking for this, I found the marvellously-named
>iiSim::DetachAndFlingChild. As a parent, I have to say I disapprove!

That is pretty horrifying. Remember, premature optimization is evil. 
Spending a lot of CPU cycles on enumerating children is a good thing. :)


Cheers,
Darren

_______________________________________________
Sweng-Gamedev mailing list
[email protected]
http://lists.midnightryder.com/listinfo.cgi/sweng-gamedev-midnightryder.com