Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

12 hours ago, Sebra said:

This works good.


print terminal:input:getchar().

works bad.

Okay I installed the right options in Windows to get my keyboard to toggle between Russian and US mode with alt+shift.  I think I am now able to see the problem in front of my own eyes.

Can you confirm: is this the same exact problem you are seeing:

In Notepad, I type the (US layout) "q" key, then shift modes to Russian with alt+shift, and type "q" again and get the Russian letter й instead.  So, this is the expected behaviour.

Then I try the same thing in the kOS terminal.

I type "q" and get 'q' as expected in US mode.  Then I shift it to Russian mode with alt+shift, and type "q" expecting to get "й", but instead get "9".

If this is the same thing that's happening to you, then at least I know I've been able to reproduce the same problem, which is necessary before I can start fixing it.

I can't read Russian, but I can at least see that "9" doesn't look like "й".

I promise I want to fix this.  Getting kOS to work in other languages was one of my main goals when making it able to use unicode fonts, and I'm frustrated to find out it didn't work like I expected.

I'll get started on this on July 5th.  (Tomorrow is a holiday here and I'm busy).

So, as an example, "й" is unicode 0439hex, while "9" is unicode 0039hex.  They have the same low byte (39hex).  This seems to suggest very strongly that somewhere along the way the high byte (04hex) is being zeroed out.  I thought I'd found every spot where that could happen and changed it, but I probably missed a spot somewhere.

 

Edited by Steven Mading
Link to comment
Share on other sites

8 hours ago, Steven Mading said:

Okay I installed the right options in Windows to get my keyboard to toggle between Russian and US mode with alt+shift.  I think I am now able to see the problem in front of my own eyes.

I think US and Russian keyboards differs only by button labels so I can see "й" on the same button with "q". This means you have almost perfect test model. Picture can help you as additional reference.

8 hours ago, Steven Mading said:

So, as an example, "й" is unicode 0439hex, while "9" is unicode 0039hex.  They have the same low byte (39hex).  This seems to suggest very strongly that somewhere along the way the high byte (04hex) is being zeroed out.  I thought I'd found every spot where that could happen and changed it, but I probably missed a spot somewhere.

I found exactly the same. 0400 difference in unicode.

There is also problem, described above in my last edited post: Russian letters can be typed and stores using internal editor. Then I can run file and see Russian letters from this file. But as soon as game saved and loaded back, only question marks "?" are on the places of Russian letters.

Link to comment
Share on other sites

1 hour ago, Sebra said:

I think US and Russian keyboards differs only by button labels so I can see "й" on the same button with "q". This means you have almost perfect test model. Picture can help you as additional reference.

I found exactly the same. 0400 difference in unicode.

There is also problem, described above in my last edited post: Russian letters can be typed and stores using internal editor. Then I can run file and see Russian letters from this file. But as soon as game saved and loaded back, only question marks "?" are on the places of Russian letters.

I made this into a Github issue, here: https://github.com/KSP-KOS/KOS/issues/2061

You can look there to track further progress as I look into this problem in the next few days.

 

Link to comment
Share on other sites

14 hours ago, Sebra said:

I think US and Russian keyboards differs only by button labels so I can see "й" on the same button with "q". This means you have almost perfect test model. Picture can help you as additional reference.

I found exactly the same. 0400 difference in unicode.

There is also problem, described above in my last edited post: Russian letters can be typed and stores using internal editor. Then I can run file and see Russian letters from this file. But as soon as game saved and loaded back, only question marks "?" are on the places of Russian letters.

I don't know yet where the cause of the problem is, but here's a possible workaround for you to try until then:

If you use the telnet feature, and your telnet terminal program is capable of using "UTF-8 Translation", then the Russian keyboard will work via telnet.  I tested it just now as part of trying to narrow down the problem.  (Knowing that the telnet terminal works fine eliminates large sections of the source code from being the cause.  Whether the input comes from telnet or from the in-game terminal window, after a certain point it follows the same path through the source code either way.  So the problem has to be happening before then, when the two techniques still differ.)

 

 

Edited by Steven Mading
Link to comment
Share on other sites

Now I solved the saved file problem too.  It took a while to find the problem.  There was one spot buried deep within the code that writes to the persistent.sfs file that was using ASCII instead of UTF-8 mode when converting from a String to a byte array.

Now I have a Pull Request for it on Github, but I have no idea when the next release will be that includes it.

 

Link to comment
Share on other sites

So the terminal told me that SCALE and TERMVELOCITY are deprecated (which the documentation didn't mention, by the way.)

What other options do I have to determine dynamic pressure, and is there any way left at all to calculate terminal velocity? I'll need that to save fuel on my SSTO, and (I think) I can't make kOS interface with MJ.

 

Oh, and speaking of errors in the documentation, the forum thread link in the "Downloads and Links" section is missing a dash.

Edited by Angstinator
Link to comment
Share on other sites

i have a scrip to copy and set new boot scripts
the new script is copyed to /boot

set core:bootfilename to "1:/boot/"+bootf+".ks".

works as in can see in the save

bootFile = 1:/boot/bootgetlander.ks

i have room it the CPU
as doing cd("boot"). and run bootgetlander runs the boot script
but on reboot the boot script wont run

wat happened in 1.3/1.1.1 to change this?
found the problem
i dont know if 1:/boot/ was allowd bifur (but this script is one i used bifur so i think it did)
but it wont work in this version
core:bootfilename must be /boot/

Edited by danielboro
Link to comment
Share on other sites

3 hours ago, MattPlaysSimulations said:

anyone here know how to contact the developers of this mod? would be useful to include in my modpack im working on.

This forum is fine, I belive. @Steven Mading is one of active developers, but you might have better luck on github kOS repository where other devs are more active too.

Link to comment
Share on other sites

17 hours ago, MattPlaysSimulations said:

anyone here know how to contact the developers of this mod? would be useful to include in my modpack im working on.

We tend to be more active on reddit in /r/kos.

That's because here on the KSP forums we get only one thread for all of kOS, and that gets frustrating to deal with because separate conversations get interleaved together.  On the subreddit it's easier to keep separate conversations separate.

What was the question you wanted to ask?

 

Link to comment
Share on other sites

On 11.7.2017 at 10:16 PM, Angstinator said:

So the terminal told me that SCALE and TERMVELOCITY are deprecated (which the documentation didn't mention, by the way.)

What other options do I have to determine dynamic pressure, and is there any way left at all to calculate terminal velocity? I'll need that to save fuel on my SSTO, and (I think) I can't make kOS interface with MJ.

 

Oh, and speaking of errors in the documentation, the forum thread link in the "Downloads and Links" section is missing a dash.

@Steven Mading You said you were open for questions?

Link to comment
Share on other sites

7 hours ago, luizopiloto said:

Is Inter-Vessel communication working on the the current ver. of kOS?
I tried to use it, but "connection:sendmessage" is always returning false.

It's not known to be broken.  What is the comm system selected for kOS config, and what's in use in the game?

 

Link to comment
Share on other sites

1 hour ago, Angstinator said:

@Steven Mading You said you were open for questions?

Terminal velocity is not a simple number anymore ever since the atmosphere model changed.  Now it properly has a different terminal velocity depending on your vessel's shape and orientation (which can change from one second to the next).  The only way to find it now would be to determine it experimentally for a given design and orientation.  (i.e. when falling, calculate where it would have been had there been no atmosphere, then compare that to where it actually ended up, and the difference is due to air drag).

We did remove terminal velocity from the documentation back when this change happened ages ago, and did make note of it in the changelog at the time, but missed a few places it got mentioned in the docs, it seems.

 

Link to comment
Share on other sites

1 hour ago, Steven Mading said:

Terminal velocity is not a simple number anymore ever since the atmosphere model changed.  Now it properly has a different terminal velocity depending on your vessel's shape and orientation (which can change from one second to the next).  The only way to find it now would be to determine it experimentally for a given design and orientation.  (i.e. when falling, calculate where it would have been had there been no atmosphere, then compare that to where it actually ended up, and the difference is due to air drag).

We did remove terminal velocity from the documentation back when this change happened ages ago, and did make note of it in the changelog at the time, but missed a few places it got mentioned in the docs, it seems.

 

Okay, terminal velocity I get now.

Why did SCALE have to go, though?

Link to comment
Share on other sites

So, I'm making this automatic launch vehicle and programming it with kOS. But I am having trouble with the code - a thing that definitely should work, for some reason does not. I asked a few people on IRC and they couldn't help either. What am I doing wrong?

// Falcon 9 second stage script
// Launches the rocket

LOCK STEERING TO HEADING(90, 90).
WAIT 1.
LOCK THROTTLE TO 1.
STAGE.
WAIT 1.
STAGE.

WHEN STAGE:LIQUIDFUEL < 2600 THEN {
    LOCK THROTTLE TO 0.  // this line is not working
    WAIT 2.
    SHIP:PARTSDUBBED("s1-CPU")[0]:GETMODULE("kOSProcessor"):ACTIVATE.
    STAGE.
    WAIT 3.
    LOCK THROTTLE TO 1.
}

SET launchProfile TO LIST(
    LIST(500, 90),
    LIST(5000, 70),
    LIST(15000, 45),
    LIST(30000, 30),
    LIST(40000, 15),
    LIST(60000, 0)
).

SET prev TO LIST(0, 90).
FOR pair IN launchProfile {
    SET a TO (pair[1] - prev[1]) / (pair[0] - prev[0]).
    SET b TO prev[1] - a * prev[0].
    UNTIL ALTITUDE >= pair[0] {
        SET targetPitch TO a * ALTITUDE + b.
        LOCK STEERING TO HEADING(90, targetPitch).
        IF APOAPSIS >= 75000 { BREAK. }
    }
    SET prev TO pair.
}

// circularize

The line I commented as not working is, obviously, supposed to stop the engines from burning during staging. But the throttle just stays at 1. The line does get reached, I checked that with a HUD message. Also, it is not a matter of using SET or LOCK, both don't work. The rest of the code performs as intended too. Could anyone help me out?

Edited by APlayer
Link to comment
Share on other sites

1 hour ago, APlayer said:

So, I'm making this automatic launch vehicle and programming it with kOS. But I am having trouble with the code - a thing that definitely should work, for some reason does not. I asked a few people on IRC and they couldn't help either. What am I doing wrong?


// Falcon 9 second stage script
// Launches the rocket

LOCK STEERING TO HEADING(90, 90).
WAIT 1.
LOCK THROTTLE TO 1.
STAGE.
WAIT 1.
STAGE.

WHEN STAGE:LIQUIDFUEL < 2600 THEN {
    LOCK THROTTLE TO 0.  // this line is not working
    WAIT 2.
    SHIP:PARTSDUBBED("s1-CPU")[0]:GETMODULE("kOSProcessor"):ACTIVATE.
    STAGE.
    WAIT 3.
    LOCK THROTTLE TO 1.
}

SET launchProfile TO LIST(
    LIST(500, 90),
    LIST(5000, 70),
    LIST(15000, 45),
    LIST(30000, 30),
    LIST(40000, 15),
    LIST(60000, 0)
).

SET prev TO LIST(0, 90).
FOR pair IN launchProfile {
    SET a TO (pair[1] - prev[1]) / (pair[0] - prev[0]).
    SET b TO prev[1] - a * prev[0].
    UNTIL ALTITUDE >= pair[0] {
        SET targetPitch TO a * ALTITUDE + b.
        LOCK STEERING TO HEADING(90, targetPitch).
        IF APOAPSIS >= 75000 { BREAK. }
    }
    SET prev TO pair.
}

// circularize

The line I commented as not working is, obviously, supposed to stop the engines from burning during staging. But the throttle just stays at 1. The line does get reached, I checked that with a HUD message. Also, it is not a matter of using SET or LOCK, both don't work. The rest of the code performs as intended too. Could anyone help me out?

Well, that looks right to me.  You could always try:

SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0.

I have a similar setup as yours and mine seems to work.

Link to comment
Share on other sites

46 minutes ago, Probus said:

Well, that looks right to me.  You could always try:

SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0.

I have a similar setup as yours and mine seems to work.

This didn't work either, but, taking a closer look, it seems that the throttle actually gets set to 0 for a second, but immediately resets back to 1.

 

With the help of oren on IRC, who reminded me that WHEN blocks finish running in one physics tick, I managed to fix it by moving things around:

// Falcon 9 second stage script
// Launches the rocket

LOCK THROTTLE TO 1.
LOCK STEERING TO HEADING(90, 90).
WAIT 1.
STAGE.
WAIT 1.
STAGE.

SET launchProfile TO LIST(
    LIST(500, 90),
    LIST(5000, 65),
    LIST(10000, 45),
    LIST(25000, 30),
    LIST(40000, 20),
    LIST(50000, 10),
    LIST(60000, 0)
).

SET prev TO LIST(0, 90).
FOR pair IN launchProfile {
    SET a TO (pair[1] - prev[1]) / (pair[0] - prev[0]).
    SET b TO prev[1] - a * prev[0].
    UNTIL ALTITUDE >= pair[0] {
        SET targetPitch TO a * ALTITUDE + b.
        LOCK STEERING TO HEADING(90, targetPitch).
        IF APOAPSIS >= 75000 { BREAK. }
        
        IF STAGE:NUMBER = 3 AND STAGE:LIQUIDFUEL < 2600 {
            LOCK THROTTLE TO 0.
            WAIT 2.
            SHIP:PARTSDUBBED("s1-CPU")[0]:GETMODULE("kOSProcessor"):ACTIVATE.
            STAGE.
            WAIT 3.
            LOCK THROTTLE TO 1.
        }
    }
    SET prev TO pair.
}

// circularize

 

Link to comment
Share on other sites

2 hours ago, APlayer said:

This didn't work either, but, taking a closer look, it seems that the throttle actually gets set to 0 for a second, but immediately resets back to 1.

 

With the help of oren on IRC, who reminded me that WHEN blocks finish running in one physics tick, I managed to fix it by moving things around:

 

Ah, that makes more sense.

Link to comment
Share on other sites

15 hours ago, APlayer said:

So, I'm making this automatic launch vehicle and programming it with kOS. But I am having trouble with the code - a thing that definitely should work, for some reason does not. I asked a few people on IRC and they couldn't help either. What am I doing wrong?

 

I think the problem is that your program reaches bottom and ends before the WHEN.THEN has time to fire off.  Once the program ends it clears out any WHEN,THEN triggers it had set up (can you imagine the nightmare of debugging if it didn't, and they could still take over and trigger after the program is over and you're in the middle of running something else instead?  That's why we clear them out as soon as the program is over.)

  To make them trigger you'd have to keep the program from finishing until they go off.

 

Edited by Steven Mading
Link to comment
Share on other sites

UNTIL ALTITUDE >= pair[0] {
        SET targetPitch TO a * ALTITUDE + b.
        LOCK STEERING TO HEADING(90, targetPitch).
        IF APOAPSIS >= 75000 { BREAK. }
    }

@Steven Mading
it looks like it keeps running until AP>=75000 (or at list to 60000 as in the last pair in the list)

but if WHEN blocks finish running in one physics tick  then it ignores all wait`s in it
IIRC thers a recommendation to not put a wait in a WHEN but if it ignores all wait it should be written instead of the recommendation

Edited by danielboro
Link to comment
Share on other sites

On 14/07/2017 at 5:53 AM, Steven Mading said:

We tend to be more active on reddit in /r/kos.

That's because here on the KSP forums we get only one thread for all of kOS, and that gets frustrating to deal with because separate conversations get interleaved together.  On the subreddit it's easier to keep separate conversations separate.

What was the question you wanted to ask?

 

I would like to include this mod in my modpack that i am currently making.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...