🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Controlling body motion under realistic physics

Started by
2 comments, last by lawnjelly 5 years, 8 months ago

I am stuck on a bit of a body motion problem and I was wondering if anyone would be able to offer a fresh perspective on it.

I have a body in motion, governed by a realistic physics engine. It is a rocket, during ascent (launch) into orbit. Rocket has main engine thrusters on its end, 4 of them (just like Apollo Saturn V) and I am able to gimbal (pivot) these engines to change the thrust geometry. One of these modes is a "roll" configuration, where 2 engines pivot slightly forward, and 2 engines slightly backward, thus producing torque and an axial (longitudinal) roll on the rocket body.

Everything works well, as expected. The problem I have is, I need an algorithm that will let me produce an exact amount of degrees in roll. So for example, I'd like to roll the rocket by 60 degrees. At first, this seemed trivial:

  • Initiate roll by gimbaling engines
  • The rocket starts rolling
  • At half way point, 30 degrees, reverse gimbal positions so that the roll can be counter-acted
  • The rocket slows down the roll
  • The rocket stops at exactly 60 degrees (since equal but opposite torque was applied at exactly half way point)

Under ideal conditions, this would work. I tried the algorithm above, and the rocket stops the roll, as expected, but way off the 60 degree mark, more like around 47 degrees. Then I realized that I had several other factors to contend with:

  • Rocket is losing mass - the fuel is being expended as the launch progresses. This means that the moment of inertia is changing with time.
  • There is small but not negligible damping created by the atmosphere, and that is changing as well, as the atmosphere is getting thinner.

So, the results I got were correct, since the rocket lost a bit of mass while it was turning, and less torque was required to stop the roll. Since I applied the same amount of torque, the rocket stopped rolling earlier than at 60 degree mark.

I am not sure how to tackle this. Somehow, I need to calculate that "point" in the roll, in degrees, where to switch the thrust geometry, to wind up exactly at my desired roll amount. In 0-60 degree roll example above, that mark would be somewhere higher than 30 degrees.

Any thoughts on this?

 

Advertisement
8 hours ago, Mitch99 said:

Any thoughts on this?

Real rockets uses a proportional navigation method to achieve it. Its just configure engines trust proportionaly to deviation of referenced orientation, so as result it able to reach/keep required orientation with given precission tolerance regardless of external conditions (of cource while a stearing torque is enought to overdue a external forces torques) .

#define if(a) if((a) && rand()%100)

This is reminding me of one of those questions in school math class that I've long forgotten how to do lol. These days I normally do it with feedback mechanism (e.g. apply torque relative to how far from target angle etc).

Here they describe an analogous problem I think:

https://www.owlfolio.org/uncat/acceleration-stop-const-distance/

I'm presuming that same idea would work on angles. However it will not map exactly to your physics simulation as the math is continuous, and physics simulations are step based, so you will probably need some adjustment. Also I imagine things get a lot more hairy if you want to take into account things like fuel weight changing etc.

You could also calculate it pretty precisely in advance if you know the physics tick rate etc (if not using fixed tick rate forget it!) and the precise calculations used in your physics. Just start from the destination angle, with angular velocity zero, then move 'backwards in time' towards the start angle, by increasing angular velocity until you get to the start position at the correct angular velocity. You might have to do this several times, or pass backwards forwards backwards etc through the loop a few times to get an accurate constant torque (in a similar manner to how inverse kinematics is sometimes calculated, if that is what you need) or just do it once and vary the torque as calculated.

However, the more complex the simulation, the more likely that feedback will provide the easiest solution. It will also be able to deal with changing unpredictable conditions. You would probably need feedback anyway on top of the other techniques. Perhaps a rough guesstimate in combination with feedback would be a good solution.

I think my terminology is right, I'm not a mathemagician or physician. ;) 

This topic is closed to new replies.

Advertisement