Jump to content

kOS - can not set SASMODE / Staging routine does not work


Recommended Posts

Hey everybody,

I could use some help with my kOS script, because I can not find my error. I play 1.2.2 with RO (no remote tech and remote tech.cfg removed from RO) and kOS 1.1.5.1.

My script describes a gravity turn. Steering up until a certain speed, pitching down by 10 degrees and waiting until pitch is aligned with srfprograde pitch.

Then trouble begins: I unlock the steering to avoid the use of SAS with LOCK. I turn on SAS. I wait 0.01. And Im trying to SET SASMODE TO "SRFPROGRADE". But nothing changes. I´m unable to change the SASMODE.

Also I use a function to automatically stage each time the SHIP:MAXTHRUST is less than 0.2. But upon flameout it won`t stage. Could someone please check, if my following script is the problem? The part, where I think the trouble is located is marked by red letters.

 

Thanks very much!

 

SET FlexPitch TO 0.                                // for Periapsis function

LOCK THROTTLE TO 1.
SAS OFF.
RCS OFF.
LOCK STEERING TO UP.

STAGE.                                        // Main Engine ignition
WAIT 3.                                        // Main Engine run up time
STAGE.                                        // Booster ignition + launch clamps


WAIT UNTIL SHIP:VELOCITY:SURFACE:MAG > 40.                    // vertical speed for gravity turn

LOCK STEERING TO HEADING (90,80).                        // Gravity turn pitching down 10 degrees
WAIT UNTIL (90 - VANG(ship:up:vector, ship:srfprograde:vector)) < 80.    // wait until sfrprograde pitch is less then 80 degrees.    

UNLOCK STEERING.                                // to prevent use of SAS with LOCK
SAS ON.                                        // SAS stability assist mode
WAIT 0.01.                                     // thought this would help with the next line
SET SASMODE TO srfPROGRADE.                            // supposed to set sas to srfprograde but does not work


UNTIL APOAPSIS {    IF SHIP:MAXTHRUST < 0.2                   // if the thrust decreases the stage is burnt out
            {    STAGE.                        // decouples empty stage, activates retros, activates next engine
                SET SASMODE TO PROGRADE.            // switching from surface to orbital prograde
            }
            ELSE { WAIT 1. }.                    // to avoid kOS doing too many calculations

SAS off.                                    // because I will use LOCK from now on until circularized
LOCK STEERING TO HEADING(90, FlexPitch).                    // FlexPitch is 0 for now
UNTIL SHIP:PERIAPSIS > 140000 {                         // Function pitches up or down, depending on vert speed
    IF SHIP:PERIAPSIS > 132000 SET FlexPitch to 0.             // to keep vessel at around apoapsis altitude
        ELSE IF SHIP:VELOCITY:ORBIT:MAG < -50 SET FlexPitch TO 15. 
        ELSE IF SHIP:VELOCITY:ORBIT:MAG > -50 SET FlexPitch TO
        (SHIP:VELOCITY:ORBIT:MAG / (-4)). 
        }.
}                                        // no idea why this curly bracket has to be here, but it works only with it
LOCK THROTTLE TO 0.                                // throttle idle
UNLOCK STEERING.                                // unlocks the steering

Link to comment
Share on other sites

6 hours ago, Whateverest said:

And Im trying to SET SASMODE TO "SRFPROGRADE"

Try "PROGRADE" instead. Though it's up to you (as the player, not script writer) to ensure the navball is in surface mode.

Edit: remember the SASMODE is just replicating the user interface to the SAS options to the left of the navball. You can only pick values KSP knows about.

https://ksp-kos.github.io/KOS/commands/flight/systems.html?highlight=sasmode

Edited by ElWanderer
Link to comment
Share on other sites

6 hours ago, Whateverest said:

UNTIL APOAPSIS {    IF SHIP:MAXTHRUST < 0.2                   // if the thrust decreases the stage is burnt out
            {    STAGE.                        // decouples empty stage, activates retros, activates next engine
                SET SASMODE TO PROGRADE.            // switching from surface to orbital prograde
            }
            ELSE { WAIT 1. }.                    // to avoid kOS doing too many calculations

This section seems to be missing a closing curly bracket, so your "UNTIL APOAPSIS" (does that have a greater than comparison, or did it get eaten?) loop encompasses the rest of your script, down to your comment about having to add a curly bracket in. That probably means it won't work as expected.

Link to comment
Share on other sites

Thanks for your answers!

3 hours ago, ElWanderer said:

Try "PROGRADE" instead. Though it's up to you (as the player, not script writer) to ensure the navball is in surface mode.

Edit: remember the SASMODE is just replicating the user interface to the SAS options to the left of the navball. You can only pick values KSP knows about.

https://ksp-kos.github.io/KOS/commands/flight/systems.html?highlight=sasmode

I tried to change it to: SET SASMODE TO "PROGRADE".

kOS complains about the "unexpected quotation marks". When I change the script to SET SASMODE TO PROGRADE. and leave them away, then it is accepted. But when the script runs it does not change the sasmode... When I enter the command during flight with the quotation marks it works. Maybe the problem could be, that upon launch  -when checking the script- there is no prograde selection available when you turn on the sas. srfprograde becomes of course only available when the ship moves.

And just below the link you sent, there is a way to change the navball setting by using SET NAVMODE TO value.  So thanks for pointing me at that.

 

2 hours ago, ElWanderer said:

This section seems to be missing a closing curly bracket, so your "UNTIL APOAPSIS" (does that have a greater than comparison, or did it get eaten?) loop encompasses the rest of your script, down to your comment about having to add a curly bracket in. That probably means it won't work as expected.

I changed that. You´re right, I missed a value as a reference (hope this makes sense to you, I´m German). Here is the new passage, changes in red:

UNLOCK STEERING.
WAIT 0.01.                                
SAS ON.                                        
WAIT 1.                                     
SET SASMODE TO prograde.                            


UNTIL SHIP:ALTITUDE > (SHIP:APOAPSIS - 1000) {    IF SHIP:MAXTHRUST < 0.2         // An altitude close to Apoapsis          
            {    STAGE.                        
                SET SASMODE TO PROGRADE.            
            }
            ELSE { WAIT 1. }.
}                    
 

Link to comment
Share on other sites

And how about that: I wrote a little test script. Setting the navball to "orbit", then turn on the sas, then reset navball to "surface" and then you can set the sasmode to "Prograde" - and you get srfprograde. 

I don`t know why, but this workaround seems to do the job...

 

LOCK THROTTLE TO 1.           // ...
LOCK STEERING TO UP.          // ...
STAGE.                                      // Main engine start
WAIT 3.                                      // Main engine run up
STAGE.                                      // actual lift off.
WAIT 5.                                     // gain speed
SET NAVMODE TO "Orbit".
UNLOCK STEERING.
WAIT 0.5.                                  // so sas has time to recognize navball change
SAS on.
SET NAVMODE TO "Surface".
WAIT 1.                                       // so sas has time to recognize navball change
SET SASMODE TO "Prograde".

Link to comment
Share on other sites

1 hour ago, Whateverest said:

there is a way to change the navball setting by using SET NAVMODE TO value.

Ah, I didn't know that! :)

57 minutes ago, Whateverest said:

UNLOCK STEERING.
WAIT 0.5.                                  // so sas has time to recognize navball change
SAS on.
SET NAVMODE TO "Surface".
WAIT 1.                                       // so sas has time to recognize navball change
SET SASMODE TO "Prograde".

The waits here could probably be just one tick (WAIT 0).

Alternatively, you could use the kOS steering to follow prograde instead of SAS:

LOCK STEERING TO SRFPROGRADE.

or

LOCK STEERING TO LOOKDIRUP(SRFPROGRADE:VECTOR, FACING:TOPVECTOR).

The first of those will roll to keep the ship's "top" facing upwards; the second of those will prevent that. It depends on what you're launching as to which is better.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...