Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

Right, but it's rather hard to tell notepad to execute the program or issue commands that are then executed. I have to switch back to KSP for that.

No I get what you are saying razark. I totally do. I think its a cool idea, and it would be nice to get it in. Just a bit farther down the road probably, as I think a focus on bug fixes and core functionality comes first.

It is a nice idea though.

Link to comment
Share on other sites

I've asked all around, but it's hard to get an answer from anywhere. Could someone possibly explain why I can only print the vectors velocity, prograde and retrograde? If I try to print their magnitude, I get "Suffix 'mag' not found on object," and the same thing happens when trying to print the xyz values of it individually.

All I can do is print the vector, nothing else, but if I make a vector myself, it's fine.

Link to comment
Share on other sites

I've asked all around, but it's hard to get an answer from anywhere. Could someone possibly explain why I can only print the vectors velocity, prograde and retrograde? If I try to print their magnitude, I get "Suffix 'mag' not found on object," and the same thing happens when trying to print the xyz values of it individually.

All I can do is print the vector, nothing else, but if I make a vector myself, it's fine.

Want to show us some code? I want to understand exactly what you are asking for.

Link to comment
Share on other sites

I've asked all around, but it's hard to get an answer from anywhere. Could someone possibly explain why I can only print the vectors velocity, prograde and retrograde? If I try to print their magnitude, I get "Suffix 'mag' not found on object," and the same thing happens when trying to print the xyz values of it individually.

All I can do is print the vector, nothing else, but if I make a vector myself, it's fine.

Hi Panichio, you need to define the type of VELOCITY, try SHIP:VELOCITY:ORBIT:MAG.

Link to comment
Share on other sites

OK here's an interesting issue I found. I normally control my inclination in the following way.

set y to 0. // Initial pitch

lock x to up + R(0,y,180). // master steering

lock steering to x. // lazy shorcut

and I change Y with a function during the ascend to get a smooth profile.

however if i were to do:

set y to 0. // Initial pitch

set x to 0. // Initial yaw

lock x to up + R(x,y,180). // master steering

lock steering to x. // lazy shorcut

the program just crashes horribly. for some reason it can't handle two variables with the steering command.

edit: lol never mind I'm an idiot... xD

Edited by odricar
Link to comment
Share on other sites

Hi Panichio, you need to define the type of VELOCITY, try SHIP:VELOCITY:ORBIT:MAG.

Wow, I feel stupid now. I had no idea you had to specify. On GitHub, velocity seems to just be orbital velocity. I didn't know it was all types of velocity in vector form.

After three pages of discussion in a different thread on the forum, it's only three posts down from my question here that I get an answer. Wow. :P

Link to comment
Share on other sites

hmm.. I've not installed kOS anywhere as of yet. I want to, its just a matter of relearning YAL... Yet Another Language. :]

Is anyone aware of a specific site that we can use to post scripts/programs for KOS? If not, gimme a couple days and I'll have one built. I'll work on it tomorrow while the kids are in school, and I'm at home wishing I could do more Kethane runs. ;)

Link to comment
Share on other sites

I'm confused about the current version of kOS. there is a thread for version .9 and this thread for version .1

Are there now two different kinds of kOS, or did you erendrake take over developement for kOS?

It seems like this is thread is the the newer of the two threads, but it is an older version of kOS?? .1 vs .9

thanks.

Link to comment
Share on other sites

...it is an older version of kOS?? .1 vs .9

It's dot ten, not dot one. Software version numbers are not decimals.

As for the two versions, the original developer of kOS has been gone for three months with no indication of ever returning. A new developer has stepped up to take over development.

Link to comment
Share on other sites

Wow, I feel stupid now. I had no idea you had to specify. On GitHub, velocity seems to just be orbital velocity. I didn't know it was all types of velocity in vector form.

After three pages of discussion in a different thread on the forum, it's only three posts down from my question here that I get an answer. Wow. :P

It is. "Velocity" *is* Orbit:Velocity. But "PROGRADE" is not. Prograde is a Euler Rotation and not a vector. That means it contains information about the direction a ray is pointing but not information about how long that ray is (which is why it's not a vector and why MAG won't work on it.) The tuple of 3 numbers in a Euler Rotation (which kOS calls a "Direction") instead of being x,y,z coordinates are actually rotation angles in degrees. The exact type of rotation is badly documented and it takes a lot of trial and error to work it out (which is why they're a pain to work with. You don't know the order in which the rotations occur (which changes everything) and you don't know whether they are intrinsic or extrinsic rotations (which also changes everything and affects the issue of gimbal lock).)

Link to comment
Share on other sites

Could you possibly add a keyboard shortcut to open and close the KOS terminal window? I would like to be able to send KOS commands as keyboard macros, but the KOS window traps all keypresses while it is open, so I need to manually click the close button before the keyboard can control anything else. Ideally, I'd like separate keybinds for opening and closing the window, but I'd settle for a toggle. Thanks!

Link to comment
Share on other sites

Could you possibly add a keyboard shortcut to open and close the KOS terminal window? I would like to be able to send KOS commands as keyboard macros, but the KOS window traps all keypresses while it is open, so I need to manually click the close button before the keyboard can control anything else. Ideally, I'd like separate keybinds for opening and closing the window, but I'd settle for a toggle. Thanks!

Could you settle for the action group bindings we have now?

Link to comment
Share on other sites

You create a new program, or edit an existing one, with


edit programName.

Once done, in that editor screen just press F5 to save it.

But that saves the program only to the storage of the kOS unit you're currently using (i.e. it's tied to your current ship and will be removed if the ship crashes or you rewind back to launch or to an earlier save).

copy MYPROGRAM to archive.

while in contact with the archive saves the program to a centralized location (your mission control center, if you like) and actually saves it to your real computer's harddrive. Then it's available to every other kOS module in your ships ("copy MYPROGRAM from archive."); and yes, you can edit the program with a normal text editor and have the changes immediately visible on the archive drive.

You can even switch to archive (assuming you have contact) and run programs from there --- so if you're debugging launch profiles or similar, you can do so with your favourite text editor and immediately run the result in KSP.

(Pro tip: you can save yourself a bit of typing if you know that the name archive and the number 0 corresponds, so "copy MYPROGRAM to 0." works just as well, unless erendrake changed that between 0.9 and 0.10.)

Link to comment
Share on other sites

Could you possibly add a keyboard shortcut to open and close the KOS terminal window? I would like to be able to send KOS commands as keyboard macros, but the KOS window traps all keypresses while it is open, so I need to manually click the close button before the keyboard can control anything else. Ideally, I'd like separate keybinds for opening and closing the window, but I'd settle for a toggle. Thanks!
Could you settle for the action group bindings we have now?

I think Luis's point is that once the Terminal window is open, you can't close it with a hotkey since all keys are trapped by the terminal. Though you could probably get around it due to the DEL bug :)

Link to comment
Share on other sites

Is there a list with C code on one side and kOS code on the other side? For the advanced programmers to see how for(), while() and other things are handled in kOS language.

Is it possible to use pointers?

Link to comment
Share on other sites

Is there a list with C code on one side and kOS code on the other side? For the advanced programmers to see how for(), while() and other things are handled in kOS language.

Is it possible to use pointers?

Kind of hard to do a proper comparison as the kOS language is very different than just about anything, but if you are an advanced programmer you should be able to pick it up easily enough. Check the wiki for the commands list. There really isn't a lot of structure.

Pointers? Lol no, kOS isn't anywhere near that advanced.

If I was to make any comparison at all, I would compare it to the old school Basic more than anything.

Link to comment
Share on other sites

Sure, here's an example of two "when" statements I would like running at the same time: (language not exact)

-When TWR > 1.5 Then reduce thrust

-When ALT > 5000 Then turn right

Right now with KOS, it's tough to have both of those "When" statements running at the same time. From what I've seen, you can only have one "when" statement" be executed before it'll even consider the second "when" statement. Similarly for "If" statements.

When you say "when TWR > 1.5 then reduce thrust", what you are actually saying is akin to "wait until TWR > 1.5", which blocks program execution, and since kOS isn't multi-threaded, you can't spawn that off in a separate thread.

Can you both try the following 2 programs?


// do multiple whens run one after the other or at the same time?

set x to 0.
when (x == 1) then { print "a 1". print "a 2". print "a 3". }.
when (x == 1) then { print "b 1". print "b 2". print "b 3". }.
when (x == 1) then { print "c 1". print "c 2". print "c 3". }.

set x to 1.
wait 1.

 // does a earlier defined when block later defined whens until it's run?

set x to 0.
when (x == 4) then { print "x is FOUR". }.
when (x == 2) then { print "x is 2". }.
when (x == 3) then { print "x = ***". }.
when (x == 1) then { print "x is one". }.

set x to 1. wait 0.2.
set x to 2. wait 0.2.
set x to 3. wait 0.2.
set x to 4. wait 0.2.

Trying them with 0.10 I get


a 1
b 1
c 1
a 2
b 2
c 2
a 3
b 3
c 3

x is one
x is 2
x = ***
x is FOUR

respectively ...

Personally, I think of when as creating a new thread and starting it when the condition becomes true and kOS as multithreaded. (Note: erendrake and Steven Mading differ (they say it's not multithreaded) and think I'm trolling.) (Benchmarking also says that with 0.10 there's no timimg difference beyond measurement errors between one main thread and one main thread + 10 when threads all running at 100% busy, so I think of the kOS module as having many parallel processors.) (Note: erendrake and Steven Mading differ (they say it's not multithreaded and most certainly not parallel) and think I'm trolling.)

Try:

clearscreen.
set g0 to 9.82. // the correct g factor, not 9,81,
// even though that's surface gravity on Kerbin.
set t to 1. // 100%
set pitch to 90. // straight up.
stage.
lock twr to maxthrust / (mass * g0).
lock throttle to t.
lock steering to up + R (0,0,180) + R(0,pitch - 90,0).

when (twr > 1.5) then {
set t to 0.7.
print "TWR > 1.5, reducing throttle" at (0,4).
}.
when (altitude > 5000) then {
set pitch to 45.
print "Pitching right (course 90)" at (0,6).
}.

// wait until altitude > 15000. // give us some data instead
until (altitude > 15000) {
print "TWR: " + round(twr,2) + " " at (0,2).
}.

As to "if": it's executed like set and print and wait. When the program flow reaches it. You need conditional branching, and if supplies that feature.

Link to comment
Share on other sites

Did you consider the number of kOS varieties and how to handle that? Are you intending to just maintain a more interoperable kOS variant of Erendrake's fork or are you independently developing your own things/commands/ideas?

Edit: sorry, this was meant to go in Agathorn's thread, but it illustrates the problem nicely.

Link to comment
Share on other sites

(Benchmarking also says that with 0.10 there's no timimg difference beyond measurement errors between one main thread and one main thread + 10 when threads all running at 100% busy, so I think of the kOS module as having many parallel processors.)

In a real world computer, the computer has to be manufactured with a fixed number of CPUs and software running on it can't arbitrarily manufacture more of them on the fly. It also can't execute any arbitrary expression in fixed time. You cannot execute an expression consisting of 10 math operators and one consisting of 2 math operators in the same fixed time as each other. These differences make trying to use terminology humans developed for real world computers break when you try to apply them to kOS. The differences are large enough to warrant using new terms for them.

And to get this on topic about the kOS mod, I suspect this is part of why kOS bogs down KSP and makes it stutter. kOS is pretending that its simulated computer executes things in constant time that on the underlying computer take vastly differing amounts of time. When the next batch of 5 operations that it wants to finish in the next timeslice actually take longer than the timeslice KSP expects a mod to finish its callback hook in, KSP has to pause simulation waiting for the mod to finish. So thus the simulation's clock will claim kOS is constant time when in reality it's not. If the algorithm was changed to not always execute the same number of fixed instructions per callback and instead watch how long they're taking, and stop when it's running out of time for this particular slice (thus executing a varying number of instructions per slice), that might help.

Edited by Steven Mading
Link to comment
Share on other sites

when I'm trying to set a node if I do add node (time+30,0,0,400). it tells me that time does not return a number value. if I do add node (0,0,0,400). it makes a node 3 hours in the past... did the behavior of this change or am I doing something wrong?

ty in advance.

Link to comment
Share on other sites

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