untoldwind / KontrolSystem2

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

Can't control grid fins #101

Closed SodaPopinski closed 6 months ago

SodaPopinski commented 6 months ago

Neither the Steering Manager nor the Autopilot seems to affect the grid fins. As a test, I've put grid fins right next to regular control surfaces, and visibly see the other control surfaces moving, while the grid fins don't.

If I shut off the script, manual inputs will move the grid fins.

untoldwind commented 6 months ago

This is somewhat funny. The control surfaces have an IgnoreSASInputs flag, which seems to be true for grid fins and false for the regular ones. In this case the KontrolSystem is treated like the SAS, i.e. pitch,yaw,roll is ignored.

I patched the SteeringManager to now set both pitch (this is treated as SAS input) and inputPitch (this is treated as human/pilot input), which seems to solve the issue.

Though maybe I should allow scripts to have better control over this. I suppose there is a reason why grid fins are treated differently.

untoldwind commented 6 months ago

Should be now working in 0.5.1

Checked with the following test script:

use { Vessel } from ksp::vessel
use { CONSOLE } from ksp::console
use { GlobalDirection, Direction, Vec3, vec3, euler } from ksp::math
use { sleep, current_time, wait_until } from ksp::game

pub fn main_flight(vessel: Vessel) -> Result<Unit, string> = {
    CONSOLE.clear()

    const manager = vessel.set_steering(vec3(0.0, 0.0, 0.0))

    for(j in 0..100) {
        for(i in -10..10) {
            manager.pitch_yaw_roll = vec3(i/10.0, 0, 0)
            sleep(0.1)
        }
        for(i in -10..10) {
            manager.pitch_yaw_roll = vec3(0, i/10.0, 0)
            sleep(0.1)
        }
        for(i in -10..10) {
            manager.pitch_yaw_roll = vec3(0, 0, i/10.0)
            sleep(0.1)
        }
    }

    manager.release()
}
SodaPopinski commented 6 months ago

Definitely fixed it. Thanks!