Jump to content

kOS Scriptable Autopilot System 0.9


KevinLaity

Recommended Posts

Hey love the plugin! I've been automating everything haha! I'm not sure if this is the place but I've found a small bug that you might be interested in. As you know volume 0 can be accessed when in close proximity to Kerbin. As such, i often launch my ships then work on a landing script from LKO. Apparently however if you have an eliptical orbit (my new launching script needs some work :wink:) then you can start writing a script to volume 0 at the low point of the orbit, however if you drift out of range of volume 0 while writing said script then when you save and exit your script will have been lost since the file can't be saved to volume 0. Unfortunately you don't get an error or anything so you assume your script was saved until you try to use it and find it missing from volume 0.

Also, on the readme it says "prograde" "up" and "retrograde" return vectors, however vector commands don't work on them (i.e. prograde:x). Although it looks like "directions" are a way to bypass this.

Once again, awesome job on this mod. I really like how I can automate tasks without feeling like I'm cheating. I can't wait to see what comes in the future.

Also I'm running 0.7 so if any of these are fixed in .82 ignore my post. For some reason .82 doesn't allow me to lock steering or thrust as I've seen a number of people report.

Link to comment
Share on other sites

hey, could you make a part for probes or a radial part? that would be amazing!!!

I'd like to see this as well.

Something of similar form factor to an AR202 style mechjeb, where it can be easily attached to an existing vessel or used on an ultralight probe assembly without having to make structural changes.

I was playing with it last night and managed to automate my kethane scanner such that the sensor automatically turns off as the battery runs down, and turns back on as the battery recharges. KOS is apparently able to fire action groups while a vessel is warping, making it quite the solution for my 1000x kethane scanner.

I'll probably add other power management tasks to it tonight, and possibly even a 'phototropism' mode where it attempts to orient the vessel for maximum attainable sun exposure.

Link to comment
Share on other sites

I was playing with it last night and managed to automate my kethane scanner such that the sensor automatically turns off as the battery runs down, and turns back on as the battery recharges. KOS is apparently able to fire action groups while a vessel is warping, making it quite the solution for my 1000x kethane scanner.

Heh... I like that idea. Would be nice to bring the drill in automatically when the tanks are full.

Link to comment
Share on other sites

For a radial part, I add the kOS module to the Kerbal Engineer tape drive.

There's some stuff Bizz added to the wiki about how you can go about making any other part in the game into a KOS computer by using another mod that lets you alter the configs of parts.

I'm not using it because I'd rather design craft that work "out of the box" and can be shared, but it does look like a good solution if you don't have that as one of your goals.

Link to comment
Share on other sites

Heh... I like that idea. Would be nice to bring the drill in automatically when the tanks are full.

I was thinking even further- making it so that on hitting an action group key it automatically cycles through each kethane converter output in order until all tanks are full.

Along those lines though, can the action groups be set or reset instead of just toggled. Now it may be that I had my action group set to use the toggle action on the parts I was controlling, but I had to do some fudging around with using ints as bools to make it properly track states. Plus it is rather easy to mess it up- the program can only be started with the vessel in a known condition or it ends up having inverted outputs and depriving the ship of power.

Also is the file storage device accessible outside KSP, so that I can make backups of programs that work well when experimenting.

Link to comment
Share on other sites

I'd like to see this as well.

Something of similar form factor to an AR202 style mechjeb, where it can be easily attached to an existing vessel or used on an ultralight probe assembly without having to make structural changes.

I was playing with it last night and managed to automate my kethane scanner such that the sensor automatically turns off as the battery runs down, and turns back on as the battery recharges. KOS is apparently able to fire action groups while a vessel is warping, making it quite the solution for my 1000x kethane scanner.

I'll probably add other power management tasks to it tonight, and possibly even a 'phototropism' mode where it attempts to orient the vessel for maximum attainable sun exposure.

In the wiki http://kos.wikia.com/wiki/Mods I described a way to make all stock drone cores a kOS computer.

That would work for radial parts like flight engineer, too

Is there an older version available anywhere until there's an update? .82 doesn't seem to work (i.e. "lock throttle to 1.")

Well, since the problems the current version has I have uploaded every version I had to google drive. Link in the wiki http://kos.wikia.com/wiki/Issues

Edited by Bizz Keryear
Link to comment
Share on other sites

I have tried for thirty minutes to find an answer somewhere, but I'm completely stuck.

I find I'm unable to lock throttle. I'm able to set steering, stage, set and print variables, but I can't lock the throttle. I've copied the first few lines from the tutorial video, but no dice.

Shouldn't a simple

lock throttle to 1.

send my rocket flying when I run the program? I've tried setting a variable to 1 and locking the throttle to that, I've tried throttling up and locking my throttle to zero.

I'm really confused.

Edit: I'm running the most recent versions of KSP and kOS on a Mac.

Edit: The issue was running version .82. If you're having the same problem, you can download earlier versions here.

Edited by hapaxLegomina
Link to comment
Share on other sites

I've read a few pages, but didn't see anything applicable. Can you point to a specific post you think would be helpful?

Seeing as that some how you've missed the multiple posts saying lock throttle to 1 isn't working....In the 0.82 update this got broken and isn't working. Look at the post by Bizz right above your post saying you've searched for 30minutes. :P

Link to comment
Share on other sites

Code that I have been using for several versions now flat out refuses to launch craft into orbit. Using eta:periapsis in a when statement is now being rejected by kos as an unrecognized term. here is the screenshot of the error thats being reported.

2F5D171E85782A6FB914453CEC1CB6B62C11FC2D

here is the launch code that I'm currently using thats been used unaltered since atleast 0.60.


clearscreen.
sas off. // Ensures SAS is OFF.

//**User Set variables.

set tOrbit to 200000. // Sets Default Target Orbit.
set tHeading to 90. // Sets your launch heading. Usage:0-360. 0=North.
set rpAlt to 1000. // Sets the altitude at which to preform an initial roll.
set rProgram to -90. // Sets the roll target. Engages at rpAlt. Usage:0-360. 180=VAB default.

set throttleLimit to 1. // Engages throttle limits below turn1.
set tTWR to 1.25. // Sets the max TWR while throttle limited.

set Count to 0. // Sets the number of asparagus stages.
set aspFuel to 0. // Sets the amount of fuel in one aparagus stage.


//**Internal variables.

set yaw to 90 + tHeading. // Internal var to match heading to NavBall
set pitch to 90. // Sets your inital pitch via heading. Usage:0-360 90=Up.
set roll to 180. // Sets your inital roll. Usage:0-360. 180=VAB Default.
set x to 0. // Internal var for angle calculation.
set y to 0. // Internal var for angle calculation.
set z to 0. // Internal var for angle calculation.
set tThr to 1. // Sets throttle at lift off.
lock steering to up + R(0,0,roll) + V(x,y,z). // Locks steering to calculated vector plus roll.
lock throttle to tThr. // Locks throttle to var tThr.
set orbit to 0. // Sets the main loop close condition.
set hAtmo to 69500. // Sets the altitude of atmosohere of Kerbin. Unit:Meters.
set turn1 to 9999. // Sets the altitude of the first down range turn. Unit:Meters
set turn2 to 14999. // " " Unit:Meters
set turn3 to 19999. // " " Unit:Meters
set turn4 to 24999. // " " Unit:Meters
set turn5 to 49999. // " " Unit:Meters

//**Values based on UI.

set xAlt to tOrbit - 100. // Primary M.E.C.O. Condition. Usage:xAlt=tOrbit-Meters.
set xOrbit to tOrbit + 5000. // Secondary M.E.C.O. Condition. Usage:xOrbit=tOrbit+Meters.
set cAlt to tOrbit - (tOrbit*.05). // Internal var for near MECO throttle limit. Usage:cAlt=tOrbit-5%.
set hAlt to tOrbit - 5. // Internal var for apoaps hold. Usage:hAlt=tOrbit-Meters.


//**Begin Countdown.

clearscreen.
print "Orbit altitude set to " + tOrbit + "m".
print "3". wait 1.
print "2". wait 1.
print "1". toggle ag1. wait 1.
clearscreen.
print "Lift Off! Target Heading set to " + tHeading + "Deg". stage.

set StartFuel to <liquidfuel>. // Internal var for initial Total Liquid Fuel.


//**G-turn Section.

when altitude > rpAlt then set roll to rProgram.
when altitude > turn1 then set pitch to 65.
when altitude > turn2 then set pitch to 50.
when altitude > turn3 then set pitch to 30.
when altitude > turn4 then set pitch to 15.
when apoapsis > turn5 then set pitch to 0.


//**Orbit Injection control. Alter at your own risk.

when apoapsis > tOrbit then
{
set tThr to 0.
set Gk to 3.5316000*10^12.
set Radius to 600000 + apoapsis.
set iRadius to 600000 + ((apoapsis+periapsis)/2).
set tVel to (Gk/Radius)^0.5.
set iVel to (Gk/iRadius)^0.5.
set reqdV to (iVel-tVel).
set acceleration to (maxthrust/mass).
set burnTime to (reqdV/acceleration).
set tTime to (burnTime/2).

until altitude > hAtmo
{
if apoapsis < hAlt { set tThr to .1. }.
if apoapsis > tOrbit { set tThr to 0. }.
}.
when altitude > 70000 then stage.
when altitude > 70200 then set warp to 3.
when eta:apoapsis < 120 + tTime then set warp to 2.
when eta:apoapsis < 60 + tTime then
{
set warp to 0. wait 1. lock steering to prograde.
}.
when eta:apoapsis < tTime then set tThr to 1.
}.

when periapsis > cAlt then set tThr to .1.
when periapsis > xAlt OR apoapsis > xOrbit then
{
set tThr to 0.
clearscreen.
print "You Are Now In Orbit".
set orbit to 1.
}.


//**Main Control loop. Alter at your own risk.

until orbit = 1
{
set x to cos(yaw) * cos(pitch).
set y to sin(yaw) * cos(pitch).
set z to sin(pitch).
set StageSolid to stage:solidfuel.
set StageLiquid to stage:liquidfuel.
set Lfuel to <liquidfuel>.
set TWR to maxthrust / (mass*9.81).
set cTWR to TWR * tThr.
set dTWR to cTWR - tTWR.
print "Heading " + heading at (0,3).
print "Max Surface TWR " + TWR at (0,5).
print "Current TWR " + cTWR at (0,7).
print "ETA:Apoapsis " + eta:apoapsis at (0,9).

if throttleLimit = 1
{
if cTWR > tTWR { set tThr to tThr - (dTWR*.1). }.
if cTWR < (tTWR - (tTWR*.1)) { set tThr to tThr + .05. }.
if tThr > 1 { set tThr to 1. }.
if tThr < 0 { set tThr to 0. }.
when altitude > turn2 then
{ set throttleLimit to 0. set tThr to 1. }.
}.

if Lfuel < StartFuel - aspFuel AND Count > 0
{ stage. set StartFuel to Lfuel. set Count to Count - 1. }.

if StageSolid > 0 AND StageSolid < 5
{ stage. }.

if StageLiquid = 0 AND StageSolid = 0
{ if Lfuel > 0 { stage. wait 1. }. }.
}.


//**End program orbital condition print out. Extend solar pannels on AG1.

lock throttle to 0.
wait 1.
print " ".
print "Apoapsis is " + apoapsis + "m".
print " ".
print "Periapsis is " + periapsis + "m".
print " ".
print "Orbital Eccentricity is " +
(((apoapsis + 600000)-(periapsis + 600000))/((apoapsis + 600000)+(periapsis + 600000))).
print " ".

wait until orbit = 1.
wait 5.
run plrelease.

Link to comment
Share on other sites

Meh ... I wish the people would read all sources.

See github. eta: is broken as well (in programs at least)

I'm aware that it is posted there I'm posting it here as well in hope that it is seen and fixed.

Link to comment
Share on other sites

Ever since .8, steering doesn't work. Mechjeb steering works fine, so it's not the rocket, and I'm using the same program I used in .7, so it's not that either.

can't confirm that. Made a program to test the eta: problem in 0.82 and used manual throttle (cause I had known that that was broken)

and it had 3 lock steering commands.

  • lock steering to up + R(0,0,180).
  • lock steering to heading 90 by 90.
  • lock steering to heading 90 by 45.

That worked like a charm... So not broken for me. Maybe only with mechjeb?

edit:

-=[ Does Your System Have Bugs? ]=-  4/97

.--. .--.
_ ` \ / ` _
`\.===. \.^./ .===./`
\/`"`\/
, | | ,
/ `\|`-.-'|/` \
/ | \ | \ .--. .--.
.-' ,-'`| ; |`'-, '-. _ ` \ / ` _
| | \| | `\.===. \.^./ .===./`
| | ;| | \/`"`\/
| \ // | , | | ,
| `._//' | / `\|`-.-'|/` \
jgs .' `. / | \ | \
_,' `,_ .-' ,-'`| ; |`'-, '-.
` ` | | \| |
| | ;| |
.--. .--. | \ // |
_ ` \ / ` _ | `._//' |
`\.===. \.^./ .===./` .' `.
\/`"`\/ _,' `,_
, | | , ` `
/ `\|`-.-'|/` \
/ | \ | \
.-' ,-'`| ; |`'-, '-.
| | \| |
| | ;| | .--. .--.
| \ // | _ ` \ / ` _
| `._//' | `\.===. \.^./ .===./`
.' `. \/`"`\/
_,' `,_ , | | ,
` ` / `\|`-.-'|/` \
/ | \ | \
.-' ,-'`| ; |`'-, '-.
| | \| |
| | ;| |
| \ // |
| `._//' |
.' `.
_,' `,_
` `

Edited by Bizz Keryear
Link to comment
Share on other sites

I believe the "LOCK TO" code breaks a bit further with every new version. In 7.0, every LOCK TO that isn't locked to altitude seems to stop working as soon as any loop or wait is started. And it sounds as if the problem got worse with the 0.8x series.

Link to comment
Share on other sites

I believe the "LOCK TO" code breaks a bit further with every new version. In 7.0, every LOCK TO that isn't locked to altitude seems to stop working as soon as any loop or wait is started. And it sounds as if the problem got worse with the 0.8x series.

Also locked variables also get only updated outside from loops when called.

When not they stay at the last value.

Edit: There is something really wired going on.

While a in a program that I wrote eta:apoapsis works perfectly fine.

It doesn't work in space computer anymore... in 0.7 it has!

A moment I thought it has to do something with single and multiple lines, but that's also not true.

stage.
wait 10.
print "after wait.".
if eta:apoapsis > 10 {print "if 1 line ok". }.
when eta:apoapsis > 10 then {print "when 1 line ok". }.
wait 10.
if eta:apoapsis > 10 {
print "if multi line ok".
}.
when eta:apoapsis > 10 then {
print "when multi line ok".
}.
wait 50.

All lines were executed.

Edited by Bizz Keryear
Link to comment
Share on other sites

-=[ Does Your System Have Bugs? ]=-  4/97

.--. .--.
_ ` \ / ` _
`\.===. \.^./ .===./`
\/`"`\/
, | | ,
/ `\|`-.-'|/` \
/ | \ | \ .--. .--.
.-' ,-'`| ; |`'-, '-. _ ` \ / ` _
| | \| | `\.===. \.^./ .===./`
| | ;| | \/`"`\/
| \ // | , | | ,
| `._//' | / `\|`-.-'|/` \
jgs .' `. / | \ | \
_,' `,_ .-' ,-'`| ; |`'-, '-.
` ` | | \| |
| | ;| |
.--. .--. | \ // |
_ ` \ / ` _ | `._//' |
`\.===. \.^./ .===./` .' `.
\/`"`\/ _,' `,_
, | | , ` `
/ `\|`-.-'|/` \
/ | \ | \
.-' ,-'`| ; |`'-, '-.
| | \| |
| | ;| | .--. .--.
| \ // | _ ` \ / ` _
| `._//' | `\.===. \.^./ .===./`
.' `. \/`"`\/
_,' `,_ , | | ,
` ` / `\|`-.-'|/` \
/ | \ | \
.-' ,-'`| ; |`'-, '-.
| | \| |
| | ;| |
| \ // |
| `._//' |
.' `.
_,' `,_
` `

Nice! :)

For me, in 0.82 pretty much all locks were broken, although it seemed like lock steering would work sometimes, but not all the time, like after a certain time/altitude (when controlling throttle manually).

Also, I'd like to add, it might be a good idea for anyone reading this, to save the previous version zip files you download, so incase you do run into bugs like in that last few updates, you can go back to a previous version that was working. I've got 7 versions from 0.46 to 0.82 (missed 0.8 and 0.81 though) and it takes up less than 3mb. Though you could keep just one previously known working version and delete the others I guess.

Lol from Kevins Dev Blog: "Wheel throttle could be set to 100 with hilarious results" Makes me wish I was testing rovers now.

Ok, so does anyone know where these "flagrant errors" are logged to?

Edited by Sma
Link to comment
Share on other sites

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