Jump to content

kOS Scriptable Autopilot System 0.9


KevinLaity

Recommended Posts

This is what I've been working on... Currently the hinge's range is -90 and 90 according to the cfg. Still a lot of work ahead but I wanted to show the potential in kOS for external mods.

This is the piece I've been waiting for, I'm going to throw out the half-baked implementation I've been working on to keep myself occupied until you came out with the real deal.

I'm definitely looking forward to this release of IR!

Link to comment
Share on other sites

To the creator of the mod:

Please ditch one of those documentaries:

(my suggestion is: https://github.com/Nivekk/KOS/blob/master/README.md)

And link the continued one in the discontinued one.

Like in the README.md: "look at kos.wikia.com for the manual" ...

And Please!!! Update and Complete it!!! F*****g pretty pretty PLEASE!!!

It (the mod) is really awesome, but I hate it to only be able to drew out like 1% cause I don't know the commands to do more.

And its a f* wiki ... so one step after another is fine, too.

It even hasn't has to have descriptions. The people can like figure that out themselves, and most of your names are pretty much self explaining.

Just add every command there that there is in the mod. The rest (adding examples, the usage and descriptions) can even do someone else.

Hell, if I have to, I will even do that (adding the describing rest) myself.

See, see what you have done! ... I am so desperate ... I am even would do something that looks like work ... And my doctor says I have a serious allergy (against work)

Wow. Have some tact.

Link to comment
Share on other sites

The mod author didn't write the wiki. It's user-made If it became the only source of documentation then we'd all be guessing all the time.

Not If the mod creator updates the wiki....

Wow. Have some tact.

I am only try to point out how desperate I am for a complete manual.

Edited by Bizz Keryear
Link to comment
Share on other sites

Wow. Have some tact.

I know right? "Screaming" isn't going to get it done faster. I've gotten by mostly with the info that's been in the videos, and the comments that have been made here in the forum. I don't know for sure but I'd bet that Kevin has a life outside of KSP, and doesn't have the time between that life and updating the mod to keep up to date/accurate documentation. Now, I speak for my self, but I would much rather him work on the mod and then write more detailed information about it. It's like the group working on RT2, JDP I think it was said he wants to make a comprehensive video tutorial, but obviously that's not possible being as that he's still (I assume) working on the mod, when real life allows anyway.

I am only try to point out how desperate I am for a complete manual.

Seeing as that the game isn't complete yet that's a little hard to do. There's a ton (or tonne depending on where you're from) of info right here in the forums 90 something pages in fact, though going too far back it's a little out of date.

Maybe try asking a question here and see if someone has an answer, as I'm sure someone will. :) Learning this as it's being created to me is part of the process and fun, and for that matter there are occasions when we can have input to how the mod works (as has been somewhat evident from the discussion of steering. :wink: ).

Edited by Sma
Link to comment
Share on other sites

I am only try to point out how desperate I am for a complete manual.

Please be aware that this can be counter productive. Someone putting in a lot of hours of hard work for free does probably not want to deal with people making demands and using strong language. I have seen this happening before with the Rubber Band tracks; the guy went from open to inquiries about the release to desperate to be left alone about this subject and now the mod seems abandoned.

Let us all appreciate the hard work. If you want anything changed, the best thing you can do is to actually do it yourself. Update the Wiki so others can benefit from your knowledge and they might do the same.

Edited by Camacha
Link to comment
Share on other sites

I am only try to point out how desperate I am for a complete manual.

Go scrounge the videos, the forum, the readme, the blog. Read the source. Gather all the information. Package it all up into a nice manual. Wait a week. Do it again.

That's the best way to get a manual. This is a project that's in constant development, and it's hard to pin down documentation for something like that. For example, have you read the KSP manual?

Edit:

Mr. Laity:

Thank you for all the hard work you've put in on this. It truly is an amazing bit of work.

Link to comment
Share on other sites

I have another question for the masses. Questions... rather. I tried asking this in the other thread ( and in this one before though I was not as educated(ish) in these terms as I am now. ) in science labs hoping for more direct help, but it seems with kOS a clear answer is hard to come by. I have NO programming knowledge what so ever... so please bare with my ignorance.

All I want to learn is how to create a launch to orbit script that complies with the design of the rocket im using it for. After watching Kevin's introductory video and studying this page I tried to create my own script and load it into kOS. Here it is... again. Now assuming I can get by the issue of loading the program I have these issues to tackle below..

( ive since updated to .61 )


clearscreen.
print "3". wait 1.
print "2". wait 1.
print "1". wait 1.

lock throttle to 1.
lock steering to up + R(0,0,180).
stage.
print "Lift Off!".

wait until altitude > 9600.
lock steering to up + R(0,0,180) + R(0,-25,0).
print "Pitching over..".

wait until surfacespeed > 500.
lock steering to up + R(0,0,180) + R(0,-50,0).

wait until surfacespeed > 750.
lock steering to up + R(0,0,180) + R(0,-75,0).

wait until surfacespeed > 1000.
lock steering to up + R(0,0,180) + R(0,-100,0).

wait until altitude > 40000.
stage.
print "Fairing Jettison.".

wait until stage:liquidfuel < 5.
stage.
print "Stage One seperation!".

wait until altitude > 59500
{
if apoapsis < 70000 { lock throttle to 0.1. }.
if apoapsis >70000 { lock throttle to 0. }.
}.
lock steering to prograde.
print "MECO 1. Waitng for cicularization burn..".

wait until eta:apoapsis < 3.
lock throttle to 1.
print "Burning..".

wait until periapsis > 70000.
lock throttle to 0.
print "MECO 2. Orbit Achieved.".

I thought it would work.. and it does. To an extent. The rocket launches up to the gravity turn, but the code stops functioning ( mostly ) at this line down.


wait until surfacespeed > 500.
lock steering to up + R(0,0,180) + R(0,-50,0).

Nothing works after this line with the exception of


lock steering to prograde.

19 lines down... So what going on here? KOS doesn't kill the program so I do not think anything is wrong with my terminology, but my chronology. Now I imagine its the problem with wait until surfacespeed. ( someone questioned as to why I was using surfacespeed. ..is there a better one to use? That's what it says on the navball until it changes to orbital velocity which I also tried, but no luck ) Altitude is no way to go about performing a gravity turn and Id rather go by the speed. I want the rocket to pitch over to 25 degrees at 250m/s, 50 at 500, 75 at 750 and 100 ( horizontal ) at 1000m/s.

Other then that why is it most of the script does not work, but bits and pieces do? Like I said it ignores everything after the first surfacespeed line exept lock steering to prograde. The rocket pitches over on the first gravity turn command and just burns until the tanks out of fuel.. it doesn't stage despite being coded to do so. ... I need someone to look at this code and tell me...w..t..f.. is going on? Its been a week now with this mod and I just cannot figure it out.

And.. again all this is after I get over the first hurdle. Running the program which does not work anymore as of .61. It gives me "file not found"... the mod is now installed into gamedata, but some have told me your scripts still go in Plugins/PluginData/Archive. "switch to archive." "run PolarisOne." "file not found"

... lol. Its a mouthful and I apologies, but.. I just want a launch to orbit.. that's it. Simple...right? Because this is quite the headache and im ready to throw in the towel with kOS. If I must I will take this to addon affairs for its own thread, but id rather not. My last attempt at trying to figure this out.

Edited by Motokid600
Link to comment
Share on other sites

Now I imagine its the problem with wait until surfacespeed. ( someone questioned as to why I was using surfacespeed. ..is there a better one to use? That's what it says on the navball until it changes to orbital velocity which I also tried, but no luck )

surfacespeed only returns the horizontal component of your speed. You'd be better off using verticalspeed or better still (verticalspeed^2 + surfacespeed^2)^0.5

Link to comment
Share on other sites

surfacespeed only returns the horizontal component of your speed. You'd be better off using vertical speed or better still (verticalspeed^2 + surfacespeed^2)^0.5

and is that the reason that my script fails to function? Because Lock to steering to prograde does.. 19 lines later... nothing else works. The fairing stage, the liquidfuel stage, the MECO stage ( as if it'd even get to that point )... nothing. And these values you said to use.

verticalspeed^2 + surfacespeed^2)^0.5

Would you care to elaborate? What do I plug in to make my ideal gravity turn?

Link to comment
Share on other sites

I have another question for the masses. Questions... rather. I tried asking this in the other thread ( and in this one before though I was not as educated(ish) in these terms as I am now. ) in science labs hoping for more direct help, but it seems with kOS a clear answer is hard to come by. I have NO programming knowledge what so ever... so please bare with my ignorance.

All I want to learn is how to create a launch to orbit script that complies with the design of the rocket im using it for. After watching Kevin's introductory video and studying this page I tried to create my own script and load it into kOS. Here it is... again. Now assuming I can get by the issue of loading the program I have these issues to tackle below..

( ive since updated to .61 )


clearscreen.
print "3". wait 1.
print "2". wait 1.
print "1". wait 1.

lock throttle to 1.
lock steering to up + R(0,0,180).
stage.
print "Lift Off!".

wait until altitude > 9600.
lock steering to up + R(0,0,180) + R(0,-25,0).
print "Pitching over..".

wait until surfacespeed > 500.
lock steering to up + R(0,0,180) + R(0,-50,0).
...

Nothing works after this line with the exception of


lock steering to prograde.

19 lines down... So what going on here? KOS doesn't kill the program so I do not think anything is wrong with my terminology, but my chronology. Now I imagine its the problem with wait until surfacespeed. ( someone questioned as to why I was using surfacespeed. ..is there a better one to use? That's what it says on the navball until it changes to orbital velocity which I also tried, but no luck ) Altitude is no way to go about performing a gravity turn and Id rather go by the speed. I want the rocket to pitch over to 25 degrees at 250m/s, 50 and 500, 75 at 750 and 100 ( horizontal ) at 1000m/s.

Other then that why is it most of the script does not work, but bits and pieces do? Like I said it ignores everything after the first surfacespeed line exept lock steering to prograde. The rocket pitches over on the first gravity turn command and just burns until the tanks out of fuel.. it doesn't stage. So.. I need someone to look at this code and tell me...w..t..f.. is going on? Its been a week now with this mod and I just cannot figure it out.

And.. again all this is after I get over the first hurdle. Running the program witch does not work anymore as of .61. It gives me "file not found"... the mod is now installed into gamedata, but some have told me your scripts still go in Plugins/PluginData/Archive. "switch to archive." "run PolarisOne." "file not found"

... lol. Its a mouthful and I apologies, but.. I just want to launch to orbit.. that's it. Simple...right? Because this is quite the headache and im ready to throw in the towel with kOS. If I must I will take this to addon affairs for its own thread, but id rather not. My last attempt at trying to figure this out.

Not sure why you're having a problem off the top of my head, but I do know people have had problems using negative numbers. One way I think to get around that is to do (0 - number here), though I was pretty certain I've used negative numbers in R() before.

I'll take a look at my older code but I think I basically just used

lock steering to up + R(0,45,180).

or something similar to do the gravity turn. Also going by altitude is generally the way you do gravity turns, right around 10,000. I do have another section that "manages" the speed, though the navball surface speed is different than the surfacespeed variable, again I'll look in my old code for this to see how I used it.

Now with 0.61 though, I'm using

lock steering to heading 90 by 45

to start the gravity turn.

Update: Check beat me to it lol, though I was just using verticalspeed + horizontalspeed apparently, I'll have to try what Check mentioned though. As for the angle, I was right about the code I used (though I set them with variables).

My old code:

  if altitude > 9500 {set pitch to -45. lock steering to up + R(yaw, pitch, roll). lock throttle to 0.75.}.

and new code:

  if altitude > 10000 { lock steering to heading 90 by 45. }. 

Edited by Sma
Link to comment
Share on other sites

well yes I do start my g-turn at 10,000 meters, but its the rate at which the rocket pitches over I need to regulate. And I have the direction down at which the rocket pitches over down. The progressing angle of pitch.. not so much.

Something I do to help when I have problems is use the print statements to see what the variables are doing. In this case you could compare the surfacespeed variable to what the navball says, just so you have a better idea of what is going on. It's possible (maybe) that the variable isn't reaching the speed which you set, though I wouldn't think that'd be the problem as it should reach those numbers eventually. How ever I would use until instead. For example, in the code below:


until altitude > 25000 {
if altitude < 10000 and altitude > 1000 {lock steering to heading 90 by 90.}.

// Check for low fuel and stage.
set currenttotal to <liquidfuel>.
if currenttotal < (totalfuel - (eachstagefuel * (spentstages + 1))) and spentstages < aspCount {
set spentstages to spentstages + 1. stage.
}.

set sspeed to verticalspeed + surfacespeed.
if altitude > 10000 {
lock steering to heading 90 by 45.
print "starting grav turn" at (0,9).
}.
// Check if speed is above or below 200m/s and adjust accordingly.
if sspeed > 190 and sspeed < 220 { lock throttle to 0.55.}.
if sspeed < 190 and throttle < 1 { lock throttle to 0.85. }.
if sspeed > 230 and altitude > 12000 { lock throttle to 1.}.
}.

With something similar you could control your pitch like


if altitude > 10000 and altitude < 10500 { lock steering to heading 90 by 75. }.
if altitude > 10500 and altitude < 11000 { lock steering to heading 90 by 65. }.
if altitude > 11000 and altitude < 11500 { lock steering to heading 90 by 55. }.
if altitude > 11500 and altitude < 12000 { lock steering to heading 90 by 45. }.

Or you could even do this to progressively change the pitch.


if altitude > 10000 and altitude < 15000 {
lock steering to heading 90 by pitch - 2.
}.

Pitch would have to be set outside of the "until" loop otherwise it would keep resetting it. Also you'll have to adjust the amount that gets subtracted so it pitches over at the rate you want.

You could set the pitch variable to 90 at the top of your program, and set the steering before staging for launch, using the pitch variable. This is all off the top of my head though so hopefully it'll do what I think it should lol.

Edited by Sma
Link to comment
Share on other sites

Yo,

I have stopped whining and had a look into the source code myself.

Since I haven't found the Q() and R() expression I am sure that have overseen something.

Can someone have a look here tell me if its complete or how many are missing?

Its still WIP though...

Here is the different steering commands, which list both Q() and R(): http://kos.wikia.com/wiki/Steering_Angles

I think I'll go ahead and sign up so I can try and contribute as well...apparently someone already has my username...hmmm.....lol

Do you mind if I do some editing to it Bizz? Nothing big just a little formatting here and there, and maybe adding some examples of commands, and removing "unneeded" bits like "bool_var" and "float_var". I'm not 100% familiar with the programming language used in the source, but I'm guessing bool_var means boolean variable, which is basically means yes/no, true/false or 1/0.

Edited by Sma
Link to comment
Share on other sites

I don't know if the terminator means what I think it does. If I remember Kevin right, he was going to add a way for people to set the terminator to something other than full stop. So TERMINATOR <;> would be a way to describe using a semicolon instead of the full stop.

Call is a command that is to be used specifically with other MODs. There is a way they can register with kOS and then the terminal can interact with them through the CALL command. See the videos posted by Sirkut earlier in the thread.

Link to comment
Share on other sites

I don't know if the terminator means what I think it does. If I remember Kevin right, he was going to add a way for people to set the terminator to something other than full stop. So TERMINATOR <;> would be a way to describe using a semicolon instead of the full stop.

Call is a command that is to be used specifically with other MODs. There is a way they can register with kOS and then the terminal can interact with them through the CALL command. See the videos posted by Sirkut earlier in the thread.

Yeah, some of that is just internal programming stuff and/or may not be 100% implemented yet. Still good to list it though :) just in case. Though the todo part most of the repeating stuff is something we won't be using in kOS, I think it's just setting up arrays of different programming objects, or whatever, like in the case of the OperatorList.

Link to comment
Share on other sites

Yo,

I have stopped whining and had a look into the source code myself.

Since I haven't found the Q() and R() expression I am sure that have overseen something.

Can someone have a look here tell me if its complete or how many are missing?

Its still WIP though...

Good job, there are a few of them in there I have not seen before.

Link to comment
Share on other sites

Yo,

I have stopped whining and had a look into the source code myself.

Since I haven't found the Q() and R() expression I am sure that have overseen something.

Can someone have a look here tell me if its complete or how many are missing?

Its still WIP though...

Awesome!

About the terminator, this a feature that I may never finish, simply because when I brought it up in the forums, it erupted into a heated debate involving people in multiple camps. Some wanted to have the option, some felt it would create inconsistency when sharing scripts, and some wanted to not only not have the option, but force everyone to switch to semicolons. Rather than ignite the powder keg I chose to put it on the back burner and keep things as they are.

Link to comment
Share on other sites

Awesome!

About the terminator, this a feature that I may never finish, simply because when I brought it up in the forums, it erupted into a heated debate involving people in multiple camps. Some wanted to have the option, some felt it would create inconsistency when sharing scripts, and some wanted to not only not have the option, but force everyone to switch to semicolons. Rather than ignite the powder keg I chose to put it on the back burner and keep things as they are.

Dunno how I missed that discussion, but as a self taught php programmer I vote for semicolon...lol sorry :P...

Could always go the basic route and not have line terminators, or....ye olde school route...


5 clearscreen
10 print "Orbit v2.9" at (0,0)
15 print "Status: Ready" at (0,2)
20 set boostersDropped to "false"
25 set spentstages to 0 // Used for determining how many booster stages have been dropped
30 set totalfuel to <liquidfuel>
35 set aspCount to 3 // Number of aspargus stages. Set to 1 if all boosters are to be dropped at the same time
40 set acirc to 0 // If set to true, circularization burn will be aborted
45 stage
50 wait 1
55 end

I kid....maybe :wink: Really though, I've become accustomed to using . and being as that the language is sort of english...errr kerbish based, I think using . works.

Edited by Sma
Link to comment
Share on other sites

Here is the different steering commands, which list both Q() and R(): http://kos.wikia.com/wiki/Steering_Angles

I think I'll go ahead and sign up so I can try and contribute as well...apparently someone already has my username...hmmm.....lol

Do you mind if I do some editing to it Bizz? Nothing big just a little formatting here and there, and maybe adding some examples of commands, and removing "unneeded" bits like "bool_var" and "float_var". I'm not 100% familiar with the programming language used in the source, but I'm guessing bool_var means boolean variable, which is basically means yes/no, true/false or 1/0.

Well at first I would say sure, but the bool_var thing really means a boolean variable (0/1) and if I interpret the code correctly it can be any boolean which is used in the game. no matter where they come from. And float_var means the same for floats .... anything bigger than 0 is interpreted as 1.

So please leave that in. And for the examples. I don't really like to have them on that page. I intended to be a short overview. I like to have examples and such on a different page...

(for me its like that: once I have learned the basics I only need a overview like that. And anything more detailed only in rare exceptional cases. But I am almost unable to memories those command completely)

Awesome!

To hear that from you make me blush.

About the terminator, this a feature that I may never finish, simply because when I brought it up in the forums, it erupted into a heated debate involving people in multiple camps. Some wanted to have the option, some felt it would create inconsistency when sharing scripts, and some wanted to not only not have the option, but force everyone to switch to semicolons. Rather than ignite the powder keg I chose to put it on the back burner and keep things as they are.

Ok, no wonder the Terminator works only halfway.

Edit: @KevinLaity feel free attended anything I might have forgotten. Just add it to the to the "Things I have to somehow implement in this page:" part

Edited by Bizz Keryear
Link to comment
Share on other sites

Well at first I would say sure, but the bool_var thing really means a boolean variable (0/1) and if I interpret the code correctly it can be any boolean which is used in the game. no matter where they come from. And float_var means the same for floats .... anything bigger than 0 is interpreted as 1.

So please leave that in. And for the examples. I don't really like to have them on that page. I intended to be a short overview. I like to have examples and such on a different page...

(for me its like that: once I have learned the basics I only need a overview like that. And anything more detailed only in rare exceptional cases. But I am almost unable to memories those command completely)

Ahh ok cool :) I understand. Maybe link it to a section that has a basic example, if one exists, other wise we can make another section with basic examples, like how to use warp, or locking throttle, etc. Unless of course it's already included on the kerboscript page.

Link to comment
Share on other sites

Thanks again to all who helped me on this one I do appreciate it. After more tweaking from what I learned here I was able to achieve a nice launch to orbit program that worked flawlessly.

Now.. maneuver nodes. Lol im ready to branch out. Is there a way to make a simple script that points the craft automatically to the node and burns at half the burn time? ( burn time 60sec. Start burn -30 end +30 ). This varies, but not much with large craft and id like a nice, static program to do so.

Link to comment
Share on other sites

Anybody interested in testing a version of kOS that you can access from a Telnet client? Currently it's based on v.6 because I'm waiting on Kevin to push v.61 changes to Github.

Features

- Each kOS unit has it's own Telnet server and specific port it listens to on (This is printed below the version number)

- Multiple clients can connect to the same kOS unit

- You can connect to different kOS units at the same time (as long as they are being rendered by KSP)

Link to comment
Share on other sites

Thanks again to all who helped me on this one I do appreciate it. After more tweaking from what I learned here I was able to achieve a nice launch to orbit program that worked flawlessly.

Now.. maneuver nodes. Lol im ready to branch out. Is there a way to make a simple script that points the craft automatically to the node and burns at half the burn time? ( burn time 60sec. Start burn -30 end +30 ). This varies, but not much with large craft and id like a nice, static program to do so.

I haven't tried this yet (It's "late" here and I was moving 12gb of video off of my phone to my computer, through kies air, then to the backup drive. Phone memory card is full and angry birds starwars 2 comes out soon), but Bizz dug up "node" and "eta:node" from the source code (oh and I also noticed it on the git hub readme). You could try printing those and see what happens. For eta:node I would imagine this could work:


set tNode to eta:node.
set atNode to 0. // once node is complete set to 1 to make sure it doesn't keep looping. Also could set it to 1 if mag:node is increasing.
until atNode = 1 {
if eta:node < tNode / 2 {
lock steering to node. //Not sure if this is how this works, assuming it's even implemented yet...it is on the git hub readme though
lock throttle to 1.
}.
if mag:node < 10 { lock throttle to 0. set atNode to 1. }. //mag:node is the amount of deltaV needed to complete the maneuver.
}

That's just a "simple" way that MIGHT work, again as I haven't tested it my self I can't say for sure. To get more complicated you could have it crunch some numbers on how much fuel you have left, mass of your vessel and the amount of thrust you have (to find out how much deltaV you have) and compare that to mag:node to see if you have enough fuel to complete the burn.

Also you could add a check to make sure that the deltaV doesn't increase. You could either put mag:node in a variable before you start the burn and just check that the current deltaV doesn't go over the original deltaV. Of course in that case you dV could be going down then start to go back up again, but at least the engines would cut off before you ended up with an orbit going somewhere you didn't want, or at least if it was it'd be to the point that it could be corrected easy enough. I guess you could also dynamically check it too, at the beginning of the until loop you would set it to a variable, wait a second or two to give it a chance to burn a little then run an if statement to compare actual dV to the variable. If actual dV is higher than the variable then you...err...the program knows something is wrong and cuts throttle.

Edited by Sma
Link to comment
Share on other sites

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