Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

...What I meant was...

Your first post opened with a complaint, and never qualified it. You can't expect the developers (which include erendrake) to always assume you mean well when you don't phrase things politely.

In other news, the new pilotsteering commands are great. I used them to write scripts that take user input (primarily in the form of the translation keys, because even though they aren't locked out of actually affecting the craft, they don't do a lot), and have created a fly-by-wire VTOL control system. Thanks for making that possible without having to resort to action group bindings.

Link to comment
Share on other sites

Your first post opened with a complaint, and never qualified it. You can't expect the developers (which include erendrake) to always assume you mean well when you don't phrase things politely.

I usually do expect people to assume others mean well. Personally "annoying" and "frustrating" dont strike me as inherently aggressive. A complaint would be "this is a crap language and a poorly made mod" but I cant say that since its completely false.

Regardless, I dont really think "annoying" and "frustrating" warrant the response I got (especially from one of the devs!).

TL;DR Sorry for the mix-up. Thanks for the great mod. But seriously chill.

Link to comment
Share on other sites

I usually do expect people to assume others mean well. Personally "annoying" and "frustrating" dont strike me as inherently aggressive. A complaint would be "this is a crap language and a poorly made mod" but I cant say that since its completely false.

Regardless, I dont really think "annoying" and "frustrating" warrant the response I got (especially from one of the devs!).

TL;DR Sorry for the mix-up. Thanks for the great mod. But seriously chill.

I was actually asking what you meant by there being no support because it was unclear to me. No need to get defensive.

As for kerboscript dsl we use in kOS it is an imperfect language just like any other. Using a diffferent language wouldnt solve many of the strange quirks that the KSP API gives us to deal with as addon developers and you need to code around as a scripter. We would always depend mostly on our own documentation for heavy lifting of these unique quirks.

You really should look at the official docs rather than the wika. There are links to the docs in quite a few places and we have put a lot of work into them.

Lastly, if you would like another language supported in script. Please send us a pull request with the implementation and we would be happy to review it.

Link to comment
Share on other sites

issue with detaching a kOS-enabled probe core from a ship, doesn't matter if it's a ship with local command or another probe core:

(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 49)

Stack dump:



(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 49)

At interpreter
<<--EOF
^


(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 49)

System.NullReferenceException: Object reference not set to an instance of an object

at kOS.Binding.FlightControlManager.Update () [0x00000] in <filename unknown>:0

at kOS.Binding.BindingManager.PreUpdate () [0x00000] in <filename unknown>:0

at kOS.Execution.CPU.PreUpdateBindings () [0x00000] in <filename unknown>:0

at kOS.Execution.CPU.Update (Double deltaTime) [0x00000] in <filename unknown>:0

(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 49)

Code Fragment

File Line:Col IP opcode operand

---- ----:--- ---- ---------------------

0:0 0000 EOF <<--INSTRUCTION POINTER--

that spams the log, and the console window too. (full log) Here is my test setup, all I have to do is drop the core from the ship:

6lp3M8Tl.png

If I exit to the space center and reload back to the probe, everything is fine. Additionally, there was no program loaded or running when this happens

Link to comment
Share on other sites

I can't find any definitive list of features regarding RT2 support here on the thread or in the docs. What exactly does enabling RT2 in the settings window entail these days? I can use the part module interface to tell if I am connected or not, or in the process of transmitting data, but I can't see a way to know what the signal delay time is

Link to comment
Share on other sites

I need some help from IR+KOS guru

For a silly project of mine (see picture) I wrote a code that is supposed to stabilize the lander can, but for some reason I cannot set the rotation speed of Rotatrons higher than 5+something using KOS

N04zDEf.jpg

set stab1 to SHIP:PARTSTAGGED("Stab")[0]:GETMODULE("MUMECHTOGGLE").set stab2 to SHIP:PARTSTAGGED("Stab")[1]:GETMODULE("MUMECHTOGGLE").


clearscreen.
print stab1:allfields.
print stab1:allevents.
print stab1:allactions.


//calculate radial speed give surface speed
lock wheelR to alt:radar.
// coarse speed of 1.0 meand 20 degrees in sec or at least it seems so from part.cfg
lock angularvelocityCoeff to 180 / (Constant():PI * wheelR) / 20 .


lock upvector to up:vector.
lock facingvector to SHIP:FACING:vector.


until false
{
set error to vxcl(upvector,facingvector).
set errorangle to vdot(ship:facing:upvector,error).

set v1 to VECDRAWARGS(V(0,0,0), error, RGB(0,1,0), "error", min(abs(error:mag*10),10), True).
set v2 to VECDRAWARGS(V(0,0,0), upvector, RGB(1,0,0), "upvector", 10, True).
set v3 to VECDRAWARGS(V(0,0,0), facingvector, RGB(0,0,1), "facingvector", 10, True).
set v4 to VECDRAWARGS(V(0,0,0), ship:facing:upvector, RGB(1,1,1), "starvector", 10, True).


stab1:SETFIELD("coarse speed", max(1, ship:surfacespeed*angularvelocityCoeff)).
stab2:SETFIELD("coarse speed", max(1, ship:surfacespeed*angularvelocityCoeff)).


print "Surface speed, " + round(ship:surfacespeed,4) at(0,28).
print "Angular vel coeff, " + round(angularvelocityCoeff,4) at(0,27).
print "Coarse speed, " + round(stab1:getfield("coarse speed"),4) at(0,29).
print "Fine speed, " + round(stab1:getfield("fine speed"),4) at(30,29).


if (abs(errorangle) > 0.05)
{
if errorangle > 0
{


print "Positive, " + errorangle at(0,30).
stab1:doaction("move +",True).
stab1:doaction("move -",False).
stab2:doaction("move +",True).
stab2:doaction("move -",False).
}
else
{
print "Negative, " + errorangle at(0,30).
stab1:doaction("move +",False).
stab1:doaction("move -",True).
stab2:doaction("move +",False).
stab2:doaction("move -",True).
}

}
else
{
if ship:surfacespeed < 0.1 //stop rotating when ship is steady.
{
stab1:doaction("move +",False).
stab1:doaction("move -",False).
stab2:doaction("move +",False).
stab2:doaction("move -",False).
}
//else keep rotating the same direction
}



wait 0.005.


set v1 to 0.
set v2 to 0.
set v3 to 0.
set v4 to 0.


if ag1
{
toggle ag1.
break.
}
}

Link to comment
Share on other sites

After posting a video of my work in progress flyback and landing program on Reddit I received several requests to make some video tutorials. This is my first video in what will hopefully become a series. I tried to start with an introduction to the mod and then jump right in to an intermediate level launch script to give new users an idea of what can be done with kOS. This video covers launching rockets and in the next video I hope to cover landing them again. Please let me know if anyone finds it useful!

Link to comment
Share on other sites

erendrake: In case you miss it, I've released a preliminary version of my RPM <--> kOS interface here. Feel free to tell me how horrible it is :P

I plan to support some more advanced features, but for now it's just a console and a selector really.

Link to comment
Share on other sites

Will KoS remain enabled if I switch to another craft?

The CPU is part of the physical part that's on the ship. Therefore it has to exist within the loading limit of KSP (2.5m of the camera in default stock without mods that change it). It doesn't have to be the current ship, but it has to be near enough to the current ship to remain fully "loaded".

If you leave the scene and move more than 2.5km away from the CPU, it will unload and stop running the script, but keep it nearby and you can switch between two vessels and have both keep running scripts.

Link to comment
Share on other sites

I'm using BHDArmory for a 500km load distance. I just wanted to make sure kOs will still function when I switch away from the craft before I take the time to learn a little bit.

My only dilemma now is, well... I was hoping the current version would by chance work for .25. Doesn't seem to be the case. There is no functionality. So I won't even bother asking how to trouble shoot, but I will ask if there's a kOs version I can get for .25?

Edit: Nevermind. I see the github in the OP. There's alot going on there though, which one do I want for .25?

Edit: Nevermind again, lol. I found one that works. But it seems the kOs script fails to control the craft when not being viewed. Im trying to watch my rockets fly to orbit with kOs only controlling staging. I start the script, but when I switch to my spectator craft the script runs, but fails to stage. Any work around?

Edited by Motokid600
Link to comment
Share on other sites

I can see that there are new orbital patches, and how many. I can see the kind of transfer (transition, escape, ...). But ETA:WHATEVER only seems to work with the current patch.

How would I place a node on the periapsis of the next patch?

Possibly related: how do I work with any node that is not NEXTNODE, but some time later?

Edited by Laie
Link to comment
Share on other sites

I'm using BHDArmory for a 500km load distance. I just wanted to make sure kOs will still function when I switch away from the craft before I take the time to learn a little bit.

My only dilemma now is, well... I was hoping the current version would by chance work for .25. Doesn't seem to be the case. There is no functionality. So I won't even bother asking how to trouble shoot, but I will ask if there's a kOs version I can get for .25?

Edit: Nevermind. I see the github in the OP. There's alot going on there though, which one do I want for .25?

Edit: Nevermind again, lol. I found one that works. But it seems the kOs script fails to control the craft when not being viewed. Im trying to watch my rockets fly to orbit with kOs only controlling staging. I start the script, but when I switch to my spectator craft the script runs, but fails to stage. Any work around?

This is a very important question: Is the craft on which kOS is 'failing' near the craft you are viewing, or is it far away from it? In stock KSP the magic range is about 2.5km (it varies slightly but it's about that much). Some mods can change this range. But regardless of what the range actually is, if the ship is past that range then KSP unloads all its parts and collapses the ship to just a dot in space, ready to reload the dot later.

So anyway, if the ship is in that state - where it's just a dot and doesn't fully exist, then there's just not much kOS can do about it. The base game prevents kOS from working in that state.

On the other hand, if the ship is closer than that and the script still isn't working, then there might be a bug.

Link to comment
Share on other sites

It's a camera right next to the launch pad. I set everything up on the rocket, enable MJ guidance then run my staging program which gives me 12 seconds to switch to my camera. The script runs, but when it tries to stage all you hear is the click. It then runs through everything and ends. Works fine if I'm viewing the rocket... Is there something I have to specify in my script?


print "12". wait 1.
print "11". wait 1.
print "10". wait 1.
print "9". wait 1.
print "8". wait 1.
print "7". wait 1.
print "6". wait 1.

stage.
print "Ignition Start.".

print "5". wait 1.
print "4". wait 1.
print "3". wait 1.
print "2". wait 1.
print "1". wait 1.

stage.

print "Liftoff!".
wait until stage:liquidfuel < 5.

stage.
print "Stage 1 separated.".
wait 1.7.
stage.
print "Stage 2 Ignition.".

wait 2.5.
stage.
print "Interstage Seperation.".
//end program
// Staging program

And im running kOs v15.3 if that's of any significance.

Edited by Motokid600
Link to comment
Share on other sites

I start the script, but when I switch to my spectator craft the script runs, but fails to stage. Any work around?
This is a very important question: Is the craft on which kOS is 'failing' near the craft you are viewing, or is it far away from it?

It might be something with KSP itself rather than kOS. I recently left a MechJeb-controlled craft to watch a piece debris; when I switched back, I found MJ had not staged in my absence, but it had initiated the turn. So it's not as if the vessel was totally uncontrolled, only the staging didn't work. As soon as I was watching the main vessel again, MJ quickly went through all outstanding stages (well, them both).

@Motokid: could you put your staging condition into a loop that will be repeated again and again? Maybe also print a line whenever it's triggered.


...
wait until stage:liquidfuel < 5.
until ship:mass < xyz {
stage.
print "staging " + round(missiontime).
wait 1.
}
print "Stage 1 separated.".
wait 1.7.

Wait until the vessel should have staged, the switch views and open the console. That way you could tell whether kOS is issuing "stage" commands that fail to work, or if kOS does nothing at all.

Edited by Laie
Link to comment
Share on other sites

@Laie - See my post above. As you can see as it counts down from 12 I have a stage start the engines at 5 seconds. The script runs. It prints out what I specify, but when the staging command comes it fails and all you get is that click. Again this is without having the craft selected. I run the script then switch to my camera vessel. As for loops.. ive read into them, but it seems a bit too complicated for what I need kOs to do at the moment. I just need a few staging sequences and MJ will do the rest. Unless an alternate script can be used to make this work.

Edit: I see the change you made there. Ill add that into my script the only thing is kOs doesn't get to that point It fails at the very first staging command. And what is it exactly when you say wait for the vessel to stage? Wait for the ignition stage then switch vessels? I tried. The next staging command to release the launch clamps fails.

Edited by Motokid600
Link to comment
Share on other sites

but when the staging command comes it fails and all you get is that click.

Your script has lots of places where it issues a staging command. Could you be more specific about exactly which of them is the one that's just going "click"? (at which point during that script are you switching the camera to your second vessel?

-----

[EDIT - never mind. I see the problem. It's a bug and I'll report it. I don't normally do a lot of the actual flight control stuff, so I probably won't be the one to fix it, but you are absolutely correct that it doesn't correctly deal with the case where active vessel differs from the vessel the CPU is currently running on.]

I just made an issue for it here: https://github.com/KSP-KOS/KOS/issues/548

If you absolutely need to do this, you could try to fiddle with the PartModules feature and find the "decouple" event on the decoupler parts and activate them one by one, but that would probably be a bit ugly. It's probably better to wait for the official fix if you need this in the generic case.

Edited by Steven Mading
Link to comment
Share on other sites

@Steven Mading - The very first stating command and then all of them fail as they come up wity just a click. I tried switching vessels right after I run the program in that 12 seconds I have set before liftoff. And I also tried letting kOs stage the ignition while viewing the vessel then switching to my camera. No go. The reason why there is so much staging commands is because its a SaturnV staging sequence. Ignition-Liftoff-Stage sep-ignition-interstage sep. my timing commands are specific so that the second stage engine fires just before the ulage motors deplete.

Edited by Motokid600
Link to comment
Share on other sites

@Motokid: see where my code says "until ship:mass < xyz {"? You need to replace xyz with a number that makes sense in your case: smaller than the vessel's mass before staging, but less than the weight after. Not knowing your ship, I just put xyz in that place.

@Steven Madding: could you please also drop me a hint how I look into future patches and nodes? If it can't be done that's alright, at least I know that I can stop trying.

Link to comment
Share on other sites

@Kaie - But what would that do? The issue occurs long before that point at the first staging command when I switch vessels.

First off, this is no about making your script work. This is about determining how exactly it fails.

I don't know about ulage motors in KSP (and anyway, do you need them on the ground?), so I presume that this is role-playing stuff and your vessel will not lose any weight until after the first "stage" command. If that is so, wrap your first staging in the following loop:


set oldmass to ship:mass.
until ship:mass < oldmass {stage. print "foo". wait 1.}

This will repeatedly stage, until the mass of the vessel finally decreases. If you hear a click every second, this is an indication that the script is working, but not the staging. If you switch vessels and see a screenful of "foo", that's confirmation that the script itself is running.

It won't make kOS work for you, at least not today. But it's an important distinction whether kOS itself ceases working when you go away, or if it's the staging that's broken.

Link to comment
Share on other sites

Thanks Laie ill see what I can do to figure it out. In the meantime though..

If you hear a click every second, this is an indication that the script is working, but not the staging.

That's exactly whats happening. Even when I switch to the other vessel ( which btw doesn't have a kOs part on it if that could be something. ). I hear the staging click when kOs is set to stage, but the staging itself fails. Whether or not that's exactly what your looking for to diagnose the problem im not sure.

Link to comment
Share on other sites

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