Jump to content

[KSP 1.12.x] kOS v1.4.0.0: kOS Scriptable Autopilot System


Dunbaratu

Recommended Posts

28 minutes ago, scimas said:

Is this a bug or intended behaviour? The resource values for a stage (STAGE:RESOURCES) are all zero unless the next stage has a decoupler. I'm running into a problem because of this.

The context is this: I'm placing a satellite in orbit. The stages are as follows (0 - upper engine, 1 - stack decoupler, 2 - fairings, 3 - lower engine). When I perform a 'STAGE' command on launch pad, the resources in the current stage are detected as zero :confused:. And yes, I am waiting a full second before I check for the resource values. My script is basically staging once (current stage 3) and then staging again (current stage 2) because of this.

Could someone confirm this either as bug or intended (and if its intended, I would appreciate if you tell me the reason too)? Thanks!

last time i cheeked stage i got -1 
was this bug fixed?
i dont know if it got fixed as i dont use it in my scripts

Link to comment
Share on other sites

58 minutes ago, scimas said:

Is this a bug or intended behaviour? The resource values for a stage (STAGE:RESOURCES) are all zero unless the next stage has a decoupler. I'm running into a problem because of this.

The context is this: I'm placing a satellite in orbit. The stages are as follows (0 - upper engine, 1 - stack decoupler, 2 - fairings, 3 - lower engine). When I perform a 'STAGE' command on launch pad, the resources in the current stage are detected as zero :confused:. And yes, I am waiting a full second before I check for the resource values. My script is basically staging once (current stage 3) and then staging again (current stage 2) because of this.

Could someone confirm this either as bug or intended (and if its intended, I would appreciate if you tell me the reason too)? Thanks!

KSP itself has a habit of showing 0 stage resources under certain conditions. If kOS agrees with what KSP displays (toggle the "stage view" in the resources tab), then this isn't a bug in kOS. It is frustrating, though. I had to switch from using STAGE:RESOURCES to something more complicated to calculate current stage delta-v.

Link to comment
Share on other sites

1 hour ago, ElWanderer said:

KSP itself has a habit of showing 0 stage resources under certain conditions. If kOS agrees with what KSP displays (toggle the "stage view" in the resources tab), then this isn't a bug in kOS. It is frustrating, though. I had to switch from using STAGE:RESOURCES to something more complicated to calculate current stage delta-v.

Yeah, I checked, KSP does shows zero resources in the stage.. that's super weird. Guess I have to figure out other variables to write staging logic.

kOS devs, please take 'fixing' this as a feature request if you can!

Link to comment
Share on other sites

10 minutes ago, scimas said:

Yeah, I checked, KSP does shows zero resources in the stage.. that's super weird. Guess I have to figure out other variables to write staging logic.

kOS devs, please take 'fixing' this as a feature request if you can!

I think it was deliberately changed to be consistent with what KSP displays, in an effort to solve various problems, so it's unlikely to get changed back to be inconsistent again (unless KSP itself changes!) There is at least one issue requesting a change to the current behaviour on the kOS github: https://github.com/KSP-KOS/KOS/issues/1908

Link to comment
Share on other sites

@scimas I have zero resources in stage in some of my designs but KSP shows zero in those cases as well (curiously, Alternate Resource Panel sometimes does not).

I currently use engine status to check whether I need to stage:

function startnextstage {
  local allengactive to 
  {
    list engines in el.
    for e in el
      if e:flameout return False.
    return True.
  }.
  until ship:availablethrust > 0 and allengactive() {
    lock steering to srfprograde.
    wait 1.
    stage.
  }
}

 

Link to comment
Share on other sites

On 02/11/2017 at 2:45 AM, Pand5461 said:

@scimas I have zero resources in stage in some of my designs but KSP shows zero in those cases as well (curiously, Alternate Resource Panel sometimes does not).

I currently use engine status to check whether I need to stage:


function startnextstage {
  local allengactive to 
  {
    list engines in el.
    for e in el
      if e:flameout return False.
    return True.
  }.
  until ship:availablethrust > 0 and allengactive() {
    lock steering to srfprograde.
    wait 1.
    stage.
  }
}

 

Thanks for the 'flameout' idea, I'm using something very similar to this code now!

Though I didn't understand what you meant by Alternate Resource Panel, is that a mod or another structure in kOS?

Link to comment
Share on other sites

I remember hearing somewhere that I can write script in other languages, that I can then use on kOS, but I can't find any website that explains how to do this. Is this actually doable, and if so how?

@scimas

ARP is a mod. It makes your resource panels look fancy, and organized.

Link to comment
Share on other sites

1 hour ago, ebigunso said:

I remember hearing somewhere that I can write script in other languages, that I can then use on kOS, but I can't find any website that explains how to do this. Is this actually doable, and if so how?

@scimas

(Unrelated quote. I can't get rid of the reference above though)

That sounds more like kRPC than kOS.

Link to comment
Share on other sites

@ebigunso @Pand5461 got it.

On 02/11/2017 at 2:45 AM, Pand5461 said:

curiously, Alternate Resource Panel sometimes does not

Is it more consistent in showing correct values? And from ARP page "API for information reading and alarm acknowledgement." I think it isn't implemented in kOS though, is it? At least the Addon section of the wiki doesn't list it.

Link to comment
Share on other sites

Sounds like changing the boot file in terminal (or in a script) doesn't actually do anything.

//1:/something.ks
print "THIS WON'T RUN".


//hello.ks
print core:bootfilename.
set core:bootfilename to "1:/something.ks".
//core:bootfilename changes but it has no effect.
reboot.

What am I doing wrong?

Edited by Alpha_Mike_741
Link to comment
Share on other sites

4 hours ago, Alpha_Mike_741 said:

Sounds like changing the boot file in terminal (or in a script) doesn't actually do anything.


//1:/something.ks
print "THIS WON'T RUN".


//hello.ks
print core:bootfilename.
set core:bootfilename to "1:/something.ks".
//core:bootfilename changes but it has no effect.
reboot.

What am I doing wrong?

i need to look at my scripts to be sure
but AFAIR you cant use 1:/
and the boot script has to be in /boot/
 

Link to comment
Share on other sites

2 hours ago, danielboro said:

i need to look at my scripts to be sure
but AFAIR you cant use 1:/
and the boot script has to be in /boot/
 

That's not true.  It has to be in /boot/ in order to be seen in the list of choices in the VAB.  It doesn't have to be in /boot/ if you manually select the boot file with commands like in the example.

I don't know what's wrong here, but I've never seen this problem before.  It's hard to tell what's wrong here because I can't diagnose a problem that never happens to anyone else.  What's going on, I don't know.

6 hours ago, Alpha_Mike_741 said:

Sounds like changing the boot file in terminal (or in a script) doesn't actually do anything.


//1:/something.ks
print "THIS WON'T RUN".


//hello.ks
print core:bootfilename.
set core:bootfilename to "1:/something.ks".
//core:bootfilename changes but it has no effect.
reboot.

What am I doing wrong?

I don't know.  This works when I do it.  Do you have a log file?

Link to comment
Share on other sites

Hey.

Trying to get something to happen when my apoapsis reaches 300000m. All i want to do is wait for that apoapsis then set throttle to zero but whatever language i use it never shuts the throttle off.

For this particular command i am using a WAIT UNTIL command. I have tried all of the below but it never does what i want when the apoapsis reaches the desired altitude.

WAIT UNTIL APOAPSIS = 300000.

WAIT UNTIL SHIP:APOAPSIS = 300000.

WAIT UNTIL ORBIT:APOAPSIS =300000.

WAIT UNTIL SHIP:ORBIT:APOAPSIS = 300000.

as well as other permeatations.

Is the issue the language i am using or the following line, which is LOCK THROTTLE TO 0.? This lines seems painfully straight forward so can't think it is that. Or, as i earlier locked the throttle to 1, do i need to unlock the throttle first? I figured a new lock throttle command would just override the previous one.

Link to comment
Share on other sites

Apoapsis is a floating point number. Chances are it will never equal 300000.

Also, the games proceeds at a certain number of ticks/updates per second. Your apoapsis could easily be under 300000m one update, then over 300000m a split second later.


Better to use a greater than check. WAIT UNTIL APOAPSIS > 300000.

Edited by ElWanderer
Link to comment
Share on other sites

2 hours ago, ElWanderer said:

Apoapsis is a floating point number. Chances are it will never equal 300000.

Also, the games proceeds at a certain number of ticks/updates per second. Your apoapsis could easily be under 300000m one update, then over 300000m a split second later.


Better to use a greater than check. WAIT UNTIL APOAPSIS > 300000.

I'd like to further suggest using >= as I personally use it to remind myself later on that I'm actually expecting this statement to evaluate at that specific value, whereas in places I'm just using > I expect the statement to evaluate for a number that can be anything larger. It does actually help when chasing down logic bugs

Link to comment
Share on other sites

7 hours ago, Steven Mading said:

I don't know.  This works when I do it.  Do you have a log file?

 

14 hours ago, Alpha_Mike_741 said:

What am I doing wrong?

personal expirance
set core:bootfilename to "/boot/"+bootf+".ks".  works
set core:bootfilename to "1:/boot/"+bootf+".ks". dos not work

Link to comment
Share on other sites

2 hours ago, danielboro said:

 

personal expirance
set core:bootfilename to "/boot/"+bootf+".ks".  works
set core:bootfilename to "1:/boot/"+bootf+".ks". dos not work

Ah that's not quite what you said before.  Before you said it was being in the boot folder that was the issue, not the explicit mention of the volume number.  It could be that it changes depending on your "start on volume" setting.  That gives me something else to look for.

Link to comment
Share on other sites

13 hours ago, Steven Mading said:

Ah that's not quite what you said before.  Before you said it was being in the boot folder that was the issue, not the explicit mention of the volume number.  It could be that it changes depending on your "start on volume" setting.  That gives me something else to look for.

my original post was not worded correctly
the second sentence was a problem i had (certainty)and i tried to point that you cant use the volume number in the path
the therd line was an impression i got from the wiki and my way of doing things

Link to comment
Share on other sites

Hey

I am using the example of the executable node script from the kOS guide to run my own nodes but it keeps failing and i can figure out why. The line that causes the failure is:

wait until abs(NP:pitch - facing:pitch) < 0.15 and abs(NP:yaw - facing:yaw) < 0.15.

The error i get is

Get suffix 'PITCH' not found on object V( then gives the vectors). An attempt was made to get a suffix called 'PITCH' from an object of type 'VECTOR' when that object does not have that suffix usable in that way.

I copied the script from the guide on the page 'Execute Node Script'. i have not tinkered with it so not sure what i'm doing wrong. Any ideas?

Daniel

Link to comment
Share on other sites

5 hours ago, windystig said:

Hey

I am using the example of the executable node script from the kOS guide to run my own nodes but it keeps failing and i can figure out why. The line that causes the failure is:

wait until abs(NP:pitch - facing:pitch) < 0.15 and abs(NP:yaw - facing:yaw) < 0.15.

The error i get is

Get suffix 'PITCH' not found on object V( then gives the vectors). An attempt was made to get a suffix called 'PITCH' from an object of type 'VECTOR' when that object does not have that suffix usable in that way.

I copied the script from the guide on the page 'Execute Node Script'. i have not tinkered with it so not sure what i'm doing wrong. Any ideas?

Daniel

After reading your post I just made this issue:

https://github.com/KSP-KOS/KOS/issues/2173

 

Link to comment
Share on other sites

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...