KontrolSystem2 icon indicating copy to clipboard operation
KontrolSystem2 copied to clipboard

issue following node.burn_vector

Open PhilouDS opened this issue 1 year ago • 2 comments
trafficstars

When I execute a burn for a maneuver node, I have this in my script:

while (dv_min.value >= 0.01) {
    const ut = current_time()
    craft.autopilot.target_orientation = nextNode.burn_vector
    const dv = nextNode.expected_orbit.orbital_velocity(ut) - craft.orbit.orbital_velocity(ut)
    let max_acc = craft.available_thrust / craft.mass
    craft_throttle.throttle = min(dv.magnitude / max_acc, 1)

    if(dv0 * dv < 0) break
    if (current_time() > start_mnv + burn_duration + 20) break

    yield()
  }

Most of the time, it works well but I've noticed 2 strange situations where the craft.autopilot.target_orientation = nextNode.burn_vector doesn't seem to work very well.

1- around Minmus with a very elliptic orbit, I change my inclination's orbit at the apoapsis. The vessel doesn't stay aligned with the burn vector. 2- fly by of the Mun (picture below) when I start a maneuver at the periapsis of the mun to lower the periapsis around Kerbin.

image

Where should I investigate to understand those problems?

(I have plenty of electricity, I have gimbal and reaction wheel working perfectly... when I execute a long maneuver (for example from Kerbin to Minmus), I have no problem even if the maneuvers lasts more than 90 sec)

PhilouDS avatar May 08 '24 16:05 PhilouDS

Instead of manually overriding the target_orientation you could just set the SAS to maneuver mode directly:

vessel.autopilot.mode = AutopilotMode.Maneuver

It should be the same, but I am still not sure if overriding the target_orientation on every yield somehow messes up the internal state of PID-loops in the SAS.

Concerning "following the burn vector" in general: For short burn there is a problem of a "run-away" burn-vector, since

  • ... the burn-vector is a prediction that is updated asynchronously, and is therefore slightly outdated
  • ... the prediction changes when the vessel is not on the correct course
  • ... it takes time to turn the vessel To compensate it might be feasible to check if the vessel is correctly aligned and reduce the throttle if it is not so that the prediction can catch up.

Then again, controlling a course correction is actually a pretty complex problem: https://www.orbiterwiki.org/wiki/Powered_Explicit_Guidance

untoldwind avatar May 11 '24 11:05 untoldwind

Instead of manually overriding the target_orientation you could just set the SAS to maneuver mode directly:

vessel.autopilot.mode = AutopilotMode.Maneuver

It should be the same, but I am still not sure if overriding the target_orientation on every yield somehow messes up the internal state of PID-loops in the SAS.

I'll try this. Thanks.

PhilouDS avatar May 11 '24 12:05 PhilouDS

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

github-actions[bot] avatar Jul 26 '24 02:07 github-actions[bot]