Jump to content

bdkaplin

New Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by bdkaplin

  1. Given two quaternions representing two orientations, there is a representation of the difference as a single rotation angle about a single axis. So, the most common implementation is to attempt such an "eigenaxis" rotation. From rest to rest, this is always possible, but if you are already rotating it's not always easy. Adding a constraint (such as I want to rotate but keep one side facing the nadir/"down" direction) is beyond the scope of what KSP is going for, I think. It can be done, but is more difficult to do smoothly in a closed-loop simulation that only depends on the current vehicle state. The tricker part here is how you represent either the current vehicle quaternion or the target direction. Saying "I want to point in the prograde direction" is not proscribing an orientation, because it leaves the roll angle about the pointing axis undetermined. So, there are an infinite number of quaternions representing this direction. Picking which one to plug into the Unity helper function is a non-trivial task and may or may not matter. Sometimes, you go "whatever, I don't care" and make a random selection, or hold some other value constant. And sometimes, that breaks the behavior in odd ways. I was suggesting that was one possible cause. For an aircraft, Euler angles provide a natural way of representing pitch/roll/yaw from a reference case. Some quaternion implementations start with this and then convert to quaternions for the "under the hood" calcs (example in Unity). But, this destroys one of the benefits of a native quaternion representation, which is avoiding singularities that are present in Euler angle descriptions. This statement is entirely true, but I doubt that is what the KSP2 simulation is doing, or at least not in detail. More likely, it is a simple feedback law saturated by available torque. I don't even know for sure if there is an allocation strategy (for example if I have multiple SAS modules) or if the parts are just additive to some vehicle maximum torque. The latter is simpler and faster, but less real world. The former introduces a new spot for error, because most allocation methods have singularities. I'm guessing it is somewhat of the former, with the torques added as part properties, because of the attitude instability of long, slender vehicles. In terms of "maybe it makes more sense", one possibility is to estimate this by computing maximum torques and time in both directions, but doing so and including saturation of the torque elements is computationally expensive. So, you would have to have decent estimating procedures. Otherwise, it is generally an optimal control problem (which I love, but is probably beyond the scope of real-time simulation).
  2. I noticed a bug where the auto-pointing/vehicle attitude control gets disturbed and sometimes decides to take the "long way" around to the desired pointing direction (for example, is 30 deg off of prograde and decides to continue rotation 330 deg rather than unwinding the 30 deg offset). This happens significantly more often when the offset is caused during time warp (either physics or just the desired pointing direction rotating) and results in significant control activity following reversion to 1x speed. On occasion, the behavior is unstable - the vehicle overshoots the correction, then decides to continue rotating rather than unwinding, etc. A few times, this has resulted in Kraken-like behavior. Proposed Fix: It depends on the exact root cause, for example if it's just a performance issue in the physics calcs. However, one possible cause could be attributed to how the game handles the ASAS simulation. If a torque command is generated in response to the attitude being stored as quaternions (my recommendation), then a possible error source could be in a handful of places: a) generating the target quaternion among the set of possible values, b) representation of the vehicle current attitude relative to inertial frame, c) chattering at the hypersphere equator (depending on convention this is the real part equal to zero, q0 or q4 = 0), or d) the control law itself. For a) a fix could be as simple as normalizing the real part to the same sign as the vehicle (since the shadow set -q is the same physical orientation as q). For b) it depends if the chosen "inertial" frame is super important, but one fix could be to incline the relative frame a few degree to lessen the chance you are exactly 180 deg off of it. Alternatively, utilizing the shadow set again could work (always real part positive vehicle representation) but this increases chattering stability issues if you don't handle that separately. For c) again inclining the reference could work but otherwise you would want to introduce some hysteresis into the calculations. For d) there are several alternative control laws available designed to solve this issue, see for example Wie's Space Vehicle Dynamics and Control. A simple modification if using linear feedback is to multiply the quaternion term by the sign of its real part (so that it drives to the closest version of the target). If you can replicate this and track it down, I'm happy to help. I teach attitude control and build and fly ADCS on rockets, missiles, and spacecraft.
×
×
  • Create New...