untoldwind / KontrolSystem2

Autopilot scripting system for KSP2
Other
54 stars 15 forks source link

vessel.situation.to_string() reporting wrong vessel #89

Closed SodaPopinski closed 6 months ago

SodaPopinski commented 1 year ago

The active vessel is the booster, but vessel.situation.to_string() is reporting the status of the upper stage, which in my case has splashed.

untoldwind commented 1 year ago

I am not sure I fully understand this: In a script vessel is the vessel that has been active when the script was started, i.e. it will not switch to another vessel. I you want a reference to the currently active vessel at any given time you should use this function: https://kontrolsystem2.readthedocs.io/en/latest/reference/ksp/vessel.html#active-vessel

Of course it is also possible that vessel.situation reports a wrong value, though I am taking that directly from the underlying VesselComponent of the game

SodaPopinski commented 1 year ago

So to clarify, the script maintains control of the booster (which had the root part), while the upper stage tumbles away uncontrolled. The script continues to control the booster through boost back, and attempting to land at KSC. Part way through the process, I noted vessel.situation is giving me "Splashed" even though the active booster is still flying. I guessed it's the upper stage that splashed, but I don't think so anymore.

I just repeated the launch, and I don't think it's reporting the upper stage, as it switches to Splash before the upper stage would have hit the water, and it's no longer a vessel. After "landing" the booster, I checked if there were any vessels or debris of the upper stage in the water, and there were none.

Here's a video I posted a few days ago. You can see the vessel status change in the console from Flying to Splashed at 2:14 seconds, even though the active booster is still flying.

Could it have been the fairing in the water causing it to give a Splashed status?

untoldwind commented 1 year ago

This might be indeed a bug in the game. If I understand the code correctly, a vessel is marked as splashed if any of its parts is splashed, which itself is triggered by a collision.

I will add some additional bindings to the vessel part, so it would be possible to analyse if it is indeed the fairing.

untoldwind commented 1 year ago

In 0.4.1.3 I added a splashed flag to the part: https://kontrolsystem2.readthedocs.io/en/latest/reference/ksp/vessel.html#id86

So with something like:

for(part in vessel.parts) {
  if(part.spashed) {
    ...
  }
}

It should be possible to figure out with part triggered the transition to the "Splashed" situtation

github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 60 days with no activity.

github-actions[bot] commented 6 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.