Jump to content

kOS Scriptable Autopilot System 0.9


KevinLaity

Recommended Posts

Id consider Mechjeb, but im scared of the temptation. I only ever wanted kOS to perform a simple launch to orbit. That's it.. Mechjeb can do this just fine, but im scared ill tempt myself into using its other functions. Idk maybe one time ill be having a hard time with a maneuver and I say screw it Ill let mechjeb do it. Next thing I know im using it for EVERYTHING. And that's what I do not want. I thought launch to orbit would be so simple with kOS. But I build large rockets. Each one requires a different flight path and staging and its.. just not working for me. Im spending WAY to much time messing with scripts and in the VAB trying to fix problems that only exist with kOS flying my rockets.. its enough. I cannot do this anymore. I gotta stop this before it ruins the game for me. I like the programming.. when it works. But it never does.

Link to comment
Share on other sites

ow2SBS9.jpg

For some reason I can't get any throttle control from kOS, and I have two kOS modules under Utility in the VAB. I've tried deleting everything kOS related in GameData and Plugins and reinstalling.

Anyone else run into the same problem?

Link to comment
Share on other sites

Im spending WAY to much time messing with scripts and in the VAB trying to fix problems that only exist with kOS flying my rockets.

Well, you just found out what the difference is between a real pilot that can interpret and adapt, and a autopilot that can perform accurate manoeuvres but lacks flexibility. kOS was - as far as I know - never intended to provide an easy, clear cut solution for launching all rockets. Quite the contrary, I would say.

Link to comment
Share on other sites

[...]

For some reason I can't get any throttle control from kOS, and I have two kOS modules under Utility in the VAB. I've tried deleting everything kOS related in GameData and Plugins and reinstalling.

Anyone else run into the same problem?

Seems broken, as well as wheelthrottle. I already opened an issue on github

Link to comment
Share on other sites

Id consider Mechjeb, but im scared of the temptation. I only ever wanted kOS to perform a simple launch to orbit. That's it.. Mechjeb can do this just fine, but im scared ill tempt myself into using its other functions. Idk maybe one time ill be having a hard time with a maneuver and I say screw it Ill let mechjeb do it. Next thing I know im using it for EVERYTHING. And that's what I do not want. I thought launch to orbit would be so simple with kOS. But I build large rockets. Each one requires a different flight path and staging and its.. just not working for me. Im spending WAY to much time messing with scripts and in the VAB trying to fix problems that only exist with kOS flying my rockets.. its enough. I cannot do this anymore. I gotta stop this before it ruins the game for me. I like the programming.. when it works. But it never does.

You could just delete all the functions you think you might not need. It's completely possible. The only tabs you really need are the info tabs, and maybe the maneuver editor. Ascent Guidance is recommended for your case, too.

Link to comment
Share on other sites

Seems broken, as well as wheelthrottle. I already opened an issue on github

Yep, if you look back some of us have already come across this issue. As far as I understand it Kevin is on vacation over the weekend so no telling when we'll hear anything about it. I guess for now we have to go back to ver 0.7.

The more neat stuff gets added to it, the more complicated the programing gets, the more likely there will be strange bugs.

Link to comment
Share on other sites

... Now kOS is ignoring my gravity turn commands.. the damn thing just shoots straight up. I changed nothing... its been working for the past few days, but now it just **** the bed. Whew... well im done with kOS for time time being. Ever since I got it its been nothing, but problems and headaches. Im sorry this is a killer app.. really it is, but I will only use this for small rockets. Satellite launches and what not from now on. I mean for christ sake I can pilot my rockets WAY better with manual control. Everything works just as it should.

With the latest update some of the lock commands don't function at least not all the time. I did manage to have a few lock steering commands work sometimes, but couldn't get lock throttle to work. Once Kevin gets back from vacation I'm sure he'll get this fixed.

kOS simpy cannot do it. They spin like a top without SAS. They oscillate violently.

Have you tried disabling gimble? I know sometimes that can be a problem even when you fly manually. Also I think kOS's "stability control" is different than that with the stock SAS. I know with my smaller rockets to a certain extent they fly better with kOS than when using SAS (I turn my SAS off completely when using KOS). The biggest rocket I've tried is a center stage ROM tank with mainsail engine, and then 4 of the same as boosters, with 2 stages above that. I can't make rockets too much bigger before I run into the part count wall though.

Id consider Mechjeb, but im scared of the temptation. I only ever wanted kOS to perform a simple launch to orbit. That's it.. Mechjeb can do this just fine, but im scared ill tempt myself into using its other functions. Idk maybe one time ill be having a hard time with a maneuver and I say screw it Ill let mechjeb do it. Next thing I know im using it for EVERYTHING. And that's what I do not want. I thought launch to orbit would be so simple with kOS. But I build large rockets. Each one requires a different flight path and staging and its.. just not working for me. Im spending WAY to much time messing with scripts and in the VAB trying to fix problems that only exist with kOS flying my rockets.. its enough. I cannot do this anymore. I gotta stop this before it ruins the game for me. I like the programming.. when it works. But it never does.

I wouldn't count kOS out completely. Maybe just test it out a few times then go back to doing something else in KSP. Give it time to get the bugs worked out. Id be willing to bet that once we have better roll control that we can use with the heading command it might work better. In my imagination the problem you're having with your large rockets is that kOS is trying to roll the rocket while moving to wherever it is your pointing. I sometimes have that problem with smaller rockets to a lesser extent, but I'd imagine with large rockets the problem would be more exaggerated and require a large number of SAS units....or control surfaces. For the most part actually, when I have kOS running I don't usually use SAS as some of the lock steering commands don't work until sas is off, like lock steering to retrograde for example.

I've also avoided getting MJ because I know I'd get too lazy eventually. At least with kOS, even though it has the potential to work almost like MJ, the fact that I have to program to make it work makes the difference. Sure I could download other peoples complete scripts, but then if something messes up I won't have a clue as to what the problem is.

Also possibly unrelated, I've seen a lot of people use

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

why not use this instead:

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

I use the 2nd one sometimes, when im not using heading and don't really have any problems with it.

Edited by Sma
Link to comment
Share on other sites

1) I would really like to see an external window that you could use on a second monitor. Or even a web page display like the telemetry mod. it doesn't have to be type-able, but that would a plus. You have the termanle on the second monitor and you press "~" now your keyboard is set to the termanle. You type your commands then press "~" aging and your keyboard is back to KSP control's. The "~" key could be what ever you like it to be.

2) A command to set the power used by RCS thrusters/Control surfaces/Wheel turn from 100% to 0%. Able to adjust the % of total thrust RCS use, speed your Control surfaces move or haw far they move, The angle your wheels rotate. Sometimes you have a lot of control surface for high altatude flights but at low altatude it is to much so you get the bouncing effect. Or you are building a space station and while docking you wont the RCS to just nudge you here or there.

This is the best mod out there for ship control!!! Thank you very much.

3) GoTo command Old dos coding if my memory serves me right.

(Goto reset.

reset:

set x to 0

set y to 0)

Link to comment
Share on other sites

Well, the PRINT AT () and Floor() functions have come in super handy...

Altitude (x) and surface speed (o) launch profile:

DgeSlD9.png

Altitude (x) and surface speed (o) reentry profile:

puQBQAr.png

Terrain elevation (x) profile:

KJ7kMvY.png

Link to comment
Share on other sites

Here is a little script that extrapolates a planes vertical speed and tries to converge the altitude to some target altitude.

Testing it on a B9 I8-L Bradbury it was able to keep it stable within 2.5 meters of the target (11500m). On heavier designs like the B9 D-175 Strugatsky it struggled to keep within a couple 100m as there is just too much momentum and not enough pitch authority at that altitude.

Random question: What exactly is the semantic of locking variables ? When exactly are they updated ?


set targetAlt to 11500.
set targetHeading to 90.


set vMinPitch to -10.
set vMaxPitch to 15.

set vPitchDownSpeed to 0.05.
set vPitchUpSpeed to 0.05.

set predictionTime to 120.

set newPitch to 10.
set vhPrev to 0.
set vhDev1Prev to 0.
set vhDev1 to 0.
set vhDev2 to 0.

set dampening to 0.95.
CLEARSCREEN.
until 0 {

set vh to VERTICALSPEED.
set vhDev1 to (VERTICALSPEED - vhPrev) * (1-dampening) + dampening * vhDev1.
set vhDev2 to (vhDev1 - vhDev1Prev) * (1-dampening) + dampening * vhDev2.

declare vPitchAdjustment.

//set predictedAltitude to ALTITUDE + (vh + ((vhDev1 + vhDev2 * predictionTime / 2 ) * predictionTime / 2)) * predictionTime.
set predictedAltitude to ALTITUDE + (vh + (vhDev1 * predictionTime / 2)) * predictionTime.
set altitudeGap to targetAlt - predictedAltitude.

set pitchSpeedModifier to altitudeGap / 500.

if altitudeGap > 0.5 {

set vPitchAdjustment to vPitchUpSpeed * pitchSpeedModifier.
}.
if altitudeGap < 0.5 {

set vPitchAdjustment to vPitchDownSpeed * pitchSpeedModifier.
}.




set newPitch to newPitch + vPitchAdjustment.
if newPitch < vMinPitch {
set newPitch to vMinPitch.
}.
if newPitch > vMaxPitch {
set newPitch to vMaxPitch.
}.


lock steering to heading targetHeading by newPitch.


print " Surface Speed: " + SURFACESPEED at (0,1).
print " Vertical Speed: " + vh at (0,2).
print " delta Vertical Speed: " + vhDev1 at (0,3).
print "delta^2 Vertical Speed: " + vhDev2 at (0,4).
print " Prediction Window: " + predictionTime at (0,5).
print " Altitude: " + ALTITUDE at (0,6).
print " Predicted Altitude: " + predictedAltitude at (0,7).
print " Pitch Change: " + vPitchAdjustment at (0,8).
print " Pitch Target: " + newPitch at (0,9).
print " Heading Target: " + targetHeading at (0,10).

set vhDev1Prev to vhDev1.
set vhPrev to vh.
}.

CDE6784A8CBDC6233CCE798D4E83E06E01082DE6

BTW: Some random things I wish for ;)

min/max functions or maybe even a clamping function.

arrays (associative or vanilla) so that its easier to store flight data, sensor readings ect. While its possible to produce a graph with print .. at it would be nice to also have that data readily available for further computations.

Link to comment
Share on other sites

Here is a little script that extrapolates a planes vertical speed and tries to converge the altitude to some target altitude.

Testing it on a B9 I8-L Bradbury it was able to keep it stable within 2.5 meters of the target (11500m). On heavier designs like the B9 D-175 Strugatsky it struggled to keep within a couple 100m as there is just too much momentum and not enough pitch authority at that altitude.

Random question: What exactly is the semantic of locking variables ? When exactly are they updated ?

I didn't use lock variables for a while now, cause they where broken within loops.

Maybe Kevin has worked on that, but since 0.82 (? dunno hadn't tested 0.8 -loops broken- and 0.81 -was too slow or 0.82 was released too fast- so far) Lock throttle and wheelthrottle is broken.

Link to comment
Share on other sites

Can I suggest a feature? I can't write C#, but I would like a command for entering text to my programs.

Something like 'INPUT TO X' like in BASIC- recieves input and sets variable X to it.

EDIT: I had another idea:

We currently lack any file reading commands, so I might suggest:

'READ "FILE" TO X' Reads the content of the file FILE into variable X

'READLINE X FROM "FILE" TO Z' Reads line number X in file FILE into variable Z

Edited by ShadowKatStudios
Had an idea
Link to comment
Share on other sites

Here is a little script that extrapolates a planes vertical speed and tries to converge the altitude to some target altitude.

BTW: Some random things I wish for ;)

arrays (associative or vanilla) so that its easier to store flight data, sensor readings ect. While its possible to produce a graph with print .. at it would be nice to also have that data readily available for further computations.

Check out the log function:


if stage:liquidfuel < 1 and logged < 1 {
log altitude+"|"+apoapsis+"|"+periapsis+"|"+throttle+"|"+pitch+"|"+altStartPitch+"|"+initPitch to kosc1log.
set logged to 1.
}

I've been using that temporarily in my attempt at the kOS reddit challenge. I've mostly been looking at the raw numbers(comparing periapsis altitude and the parameters used to get there) but you can open the log file (saved in archive) as a csv file in open office/libre office calc, or Excel, of the equivalent on other os's,I use a | (pipe) as the separator, then however your given spreadsheet program generates graphs.

Also there is a plugin/mod for kOS (Sensor Reporter for kOS) that makes it possible to poll the stock sensors and get their data, which can then also be logged using the log command. You may want to check it out.

Can I suggest a feature? I can't write C#, but I would like a command for entering text to my programs.

Something like 'INPUT TO X' like in BASIC- recieves input and sets variable X to it.

I don't know if you've seen this, and while it's not exactly the same as an input statement, you can declare a parameter before your program is run:


declare parameter gravturnAltitude.

and then in the terminal


run launch(10000).

I use this in my "universal" launch program (still working on it to get the AP and PE closer together, also needs some work for cases when you don't use fuel lines). In my cause I have two declared parameters aspCount (number of asparagus stage pair boosters) and the desired orbital altitude.

Edited by Sma
Link to comment
Share on other sites

Check out the log function:


if stage:liquidfuel < 1 and logged < 1 {
log altitude+"|"+apoapsis+"|"+periapsis+"|"+throttle+"|"+pitch+"|"+altStartPitch+"|"+initPitch to kosc1log.
set logged to 1.
}

I've been using that temporarily in my attempt at the kOS reddit challenge. I've mostly been looking at the raw numbers(comparing periapsis altitude and the parameters used to get there) but you can open the log file (saved in archive) as a csv file in open office/libre office calc, or Excel, of the equivalent on other os's,I use a | (pipe) as the separator, then however your given spreadsheet program generates graphs.

Also there is a plugin/mod for kOS (Sensor Reporter for kOS) that makes it possible to poll the stock sensors and get their data, which can then also be logged using the log command. You may want to check it out.

I don't know if you've seen this, and while it's not exactly the same as an input statement, you can declare a parameter before your program is run:


declare parameter gravturnAltitude.

and then in the terminal


run launch(10000).

I use this in my "universal" launch program (still working on it to get the AP and PE closer together, also needs some work for cases when you don't use fuel lines). In my cause I have two declared parameters aspCount (number of asparagus stage pair boosters) and the desired orbital altitude.

While it's good, it's not what I need for a space terminal.

Link to comment
Share on other sites

you can declare a parameter before your program is run:


declare parameter gravturnAltitude.

and then in the terminal


run launch(10000).

I am not really getting this. Could you elaborate on what this is and how to use it?

Link to comment
Share on other sites

I am not really getting this. Could you elaborate on what this is and how to use it?

It's sort of like having an input command. I use it for two things in my program, to set the number of asparagus stages, and the final altitude I want to be at. That way they're not hard coded into my program, which can be reused for other rockets. So far I've only tested it with two so far though.

A crude example for setting the altitude of you're apoapsis and periapsis, if you wanted them to be different for some reason, in a file called launch you would have:


declare parameter apoapsisAltitude.
declare parameter periapsisAltitude.
stage.
lock steering to heading 90 by 90.
until apoapsis > apoapsisAltitude {
lock throttle to 1.
if altitude > 10000 {lock steering to heading 90 by 45.)
}
lock throttle to 0.
lock steering to heading 90 by -10.
wait until eta:apoapsis < 20.
until periapsis > periapsisAltitude {lock throttle to 1.}
lock throttle to 0.

Then to get an orbit roughly 120,000m by 100,000m:


run launch(120000,100000).

I THINK you could also use it to get around the lack of functions, sort of. For example your first program could run a second program, and with parameters pass variables from the first program to the 2nd program. Although I don't think it can pass variables back but I could be wrong about that.

Link to comment
Share on other sites

So the parameters are declared in the order they are in the script? That was what was confusing me, as there does not seem to be solid or absolute link between the two.

Ahh I see, yeah I believe thats the way it works.

Link to comment
Share on other sites

Although I don't think it can pass variables back but I could be wrong about that.

If all variables have global scope, you don't need to worry about passing anything back. You just have to be very careful with variable names.

Link to comment
Share on other sites

If all variables have global scope, you don't need to worry about passing anything back. You just have to be very careful with variable names.

Ahh ok, yeah I was thinking I heard something like that but wasn't 100% sure.

Link to comment
Share on other sites

Can I suggest a feature? I can't write C#, but I would like a command for entering text to my programs.

Something like 'INPUT TO X' like in BASIC- recieves input and sets variable X to it.

EDIT: I had another idea:

We currently lack any file reading commands, so I might suggest:

'READ "FILE" TO X' Reads the content of the file FILE into variable X

'READLINE X FROM "FILE" TO Z' Reads line number X in file FILE into variable Z

Nice, we also discussed about that, but I think all of us would prefer to have the existing features working as intended before having new features.

Having then (new features) are nice, but all for naught if the rest isn't working.

[...]

I've been using that temporarily in my attempt at the kOS reddit challenge.

Wait.. What? There are reddit challenges for kOS?
Link to comment
Share on other sites

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