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?