Profile image

cos(PitchAngle) sometimes causes PID to crash

106k hpgbproductions  2.3 years ago

Bug: Using cos(PitchAngle) as the current or target value, and spawning vertically up/down, causes PID to always return NaN. This causes the PID to lock up.

How to replicate it:

Use the following FT in InputController, variables, or DebugExpression:
PID(cos(PitchAngle), 0, 1, 0, 0)

Spawn into a level (e.g., Lunar Arc) or a location that is vertical. This does not need to be at the beginning of a level, it could be a location selected later. It could be possible to trigger it accidentally.

Further investigation:

PID(cos(90), 0, 1, 0, 0) isn't exactly zero. For me it's some value in the order of E-08, and it doesn't become NaN.

What still works:

  • using cos(PitchAngle) as error correction coefficients
  • using cos(PitchAngle) in other memory functions like smooth()
  • Log in to leave a comment
  • Profile image

    PID(cos(angle)*clamp01(Time>1), 0, 1, 0, 0) doesn't work

    9 months ago
  • Profile image

    better use PID(cos(Time>1 ? angle : 0), 0, 1, 0, 0)
    Its mean: if time after load more than 1 second, use angle (PitchAngle), else cos(0)

    9 months ago
  • Profile image

    use clamp. I'm tested, its work. I dont know why, mb in start cos(angle) go to infinity and break pid

    9 months ago
  • Profile image

    what does PID mean?

    1.6 years ago