Jump to content

kOS Scriptable Autopilot System 0.9


KevinLaity

Recommended Posts

I am having some strange issues, and may have run into a bug. The following happens after I launch my rocket into orbit using a kOS program I wrote:


run BOdeorbit.
Error on line 2: Syntax Error.

The code of the program "BOdeorbit" is as follows:


// This should deorbit the [AUTO] Basic Orbiter

print "Beginning deorbit burn".
lock STEERING to RETROGRADE.
wait 3.
set x to 0.
until x > 1 {
lock THROTTLE to x.
set x to x + 0.05.
wait 0.01.
}
lock THROTTLE to 1.
wait until PERIAPSIS < 0.
lock THROTTLE to 0.
unlock STEERING.

wait until ALTITUDE < 45000.
toggle AG1.
print "Retracting solar panels".

wait until ALT:RADAR < 5000.
stage.
print "Parachute deployed".

wait until ALT:RADAR < 10.
print "Touchdown imminent".

wait 5.

Am I missing something here?

I'm thinking it might be a case of PEBKC. :P J/k...but really though... I don't think you need to capitalize things like AG1, THROTTLE etc. I keep mine all lower case and it works fine. Also your "wait 0.01" I think is almost pointless as I believe it takes longer than that anyway for it to cycle through each line. Try putting those things to lower case and/or removing the wait line I mentioned and see how it goes. Everything else looks fine to me.

Link to comment
Share on other sites

I am having some strange issues, and may have run into a bug. The following happens after I launch my rocket into orbit using a kOS program I wrote:


run BOdeorbit.
Error on line 2: Syntax Error.

The code of the program "BOdeorbit" is as follows:


*** cut to save space***

Am I missing something here?

I've no idea, the code looks fine to me, though that "wait 0.01." seems redundant as was already pointed out. However, I copy pasted that code segment into a deorb.txt on my archive and ran it on a test ship without getting an error. Granted, my test ship consisted of just a command module and kOS sitting on the launch pad, but I got all the appropriate printouts, throttle action, attempt to stage (heard the click), and the module spun around on the ground a bit trying to orient itself. :huh:

Link to comment
Share on other sites

Is it possible to send files to another craft, making it possible to have satellites in orbit storing your data?

I know you could use the archive but this way is waaay more awesome.

I don't think so, not unless you're docked with a ship, then you can:


copy [I]someprogram[/I] to volume 2. //volume 1 being the currently active ship when docked or which ever kOS module you click on first AFAIK and volume 2 would be your target.

Link to comment
Share on other sites

I didn't even know encounter was a thing(guess i need to catch up lol). I'm assuming you tried encounter:eta? or something similar.

Turns out it only works with nodes (it detects encounters on the "brown" path that comes out of a maneuver node). If you haven't set a node because you want the encounter you're already headed to as-is on you current "blue" orbital path, you can't get it. I suppose I could pointlessly set a manuever node right where I am, with a delta-V of zero, just to make a "brown path" that's identical to my "blue path" in order to check for encounter but that seems a it silly.

Link to comment
Share on other sites

Strange bug. I am locking steering using this script - and sometimes it works, sometimes not.

Is there any known workaround? Can the "usual suspects" reproduce this and open a bug ticket?

declare parameter ya,pi,ro.
// rotate ship to yaw, pitch, roll and wait
print "T+" + round(missiontime) + " Turning to expose solar panels...".
print "T+" + round(missiontime) + " Set steering to R(" + ya + "," + pi + "," + ro + ")".
print "".
print "".
print "".
print "".
print "".
sas off.
lock steering to R(ya,pi,ro).
print "Steering: " + steering.
until abs(sin(steering:pitch) - sin(facing:pitch)) < 0.01 and abs(sin(steering:yaw) - sin(facing:yaw)) < 0.01 {
print "Prograde: " + prograde at (0,31).
print " Facing: " + facing at (0,32).
print "Steering: " + steering at (0,33).
}
unlock steering.
sas on.
print "T+" + round(missiontime) + " Done.".

steerbug.PNG

EDIT: This seems to work


lock fset to R(ya,pi,ro).
lock steering to fset.

Edited by baloan
Link to comment
Share on other sites

Strange bug. I am locking steering using this script - and sometimes it works, sometimes not.

I think that the actual steering under the hood is in a different frame of reference than the one exposed to the KOSscript programmer, and when setting the special variable STEERING to a direction you give it, it translates frames of reference between what you told it and what it uses under the hood. But then when printing the value of STEERING out, it doesn't translate it back so you see the under-the-hood version. Thus why locking STEERING to your own variable and printing your own variable gives a different result than printing the STEERING variable directly.

Link to comment
Share on other sites

alright, have loaded 2 savegames with "kOS" parts on my ships. Each one was corrupt, with half the ship missing. This was from quicksaving, then screwing something up, then going back to the quicksave. From the comments here, I take it that kOS corrupting saves is a common occurrence? Any fixes or workaround?

Update : I narrowed it down : opening the console, then running some code, then quick-saving, even if that code has terminated, will corrupt the game.

Toggling power does NOT help. It is still corrupt, even if I turned the power off to the part before quick-saving.

The corrupt comes from using the "set" command. If you set some variables into memory on the ship, boom, save is now corrupt.

Edited by BrickedKeyboard
Link to comment
Share on other sites

alright, have loaded 2 savegames with "kOS" parts on my ships. Each one was corrupt, with half the ship missing. This was from quicksaving, then screwing something up, then going back to the quicksave. From the comments here, I take it that kOS corrupting saves is a common occurrence? Any fixes or workaround?

No, but lots of people have the same problem, and the more that report it the better. I thought it was just me, but clearly it's not. Something is broken about going on-rails and then coming back off-rails again, which also uses the persistence file and has the same symptoms.

Link to comment
Share on other sites

Behold! I bring to you a decently thorough bug report!

Installed mods:

- City Lights & Clouds

- Automatic Vertical Velocity and Altitude Control

- Navball Docking Indicator

- Kerbal Engineer

- Kerbal Joint Reinforcement

- Kethane

- kOS (obviously)

- Near Future Propulsion Pack

- RealChute

- SCANsat

- Science Log Manager

- Steam Guages

- TreeLoader

- Universe Replacer (just for the skybox)

There are two scripts being used here. The first is ExecuteLaunch (my first kOS script :D):


clearscreen.
print "Launching in 5".
wait 1.
print "4".
wait 1.
print "3".
wait 1.
print "2".
wait 1.
print "1".
wait 1.
print "Engine Ignition".
set x to 0.5.
lock STEERING to UP - R(0,0,90).
lock THROTTLE to 0.5.
stage.
until x > 0.95 {
lock THROTTLE to x.
set x to x + 0.05.
wait 0.01.
}
lock THROTTLE to 1.
wait 0.5.
print "Liftoff".
stage.
wait until ALTITUDE > 9000.
print "Beginning gravity turn".
set x to 0.
until x > 59 {
lock STEERING to UP - R(0,x,90).
set x to x+1.
wait 0.5.
}
wait until APOAPSIS > 90000.
print "Waiting for circulation burn".
lock THROTTLE to 0.
lock STEERING to PROGRADE.
wait until ETA:APOAPSIS < 5.
print "Executing circulation burn".
set x to 0.
until x > 0.95 {
lock THROTTLE to x.
set x to x +0.05.
wait 0.01.
}
lock THROTTLE to 1.
wait until STAGE:LIQUIDFUEL < 1.
lock THROTTLE to 0.
stage.
lock THROTTLE to 1.
wait until PERIAPSIS > 85000.
lock THROTTLE to 0.
print "Welcome to space".
wait 5.

The second is BOdeorbit:


//This should deorbit the [AUTO] Basic Orbiter

print "Beginning deorbit burn".
lock STEERING to RETROGRADE.
wait 3.
set x to 0.
until x > 1 {
lock THROTTLE to x.
set x to x + 0.05.
wait 0.01.
}
lock THROTTLE to 1.
wait until periapsis < 0.
lock THROTTLE to 0.
unlock STEERING.

wait until ALTITUDE < 45000.
toggle AG1.
print "Retracting solar panels".

wait until ALTITUDE < 5000.
stage.
print "Parachute deployed".

wait until ALT:RADAR < 10.
print "Touchdown imminent".

wait 5.

The series of events are as follows:

Javascript is disabled. View full album

Will upload persistence and/or craft file on request.

Hope this somehow sheds some light on the situation.

Edited by Thrfoot
Link to comment
Share on other sites

I can't think of any work around. There's absolutely no way to use kOS to do anything other than the example files (for landing and ascent assistance). This is because the very moment you create variables in memory, or have running code, the ship becomes un-savable.

The variables cannot be erased, as near as I can tell.

Anyone have an idea how to get around this?

Link to comment
Share on other sites

Installed mods:

- City Lights & Clouds

- kOS (obviously)

- TreeLoader

I'm using those of your list and could run your deorbit script, so they shouldn't be causing it.

I'll see if running the ascent script prior to the deorbit changes anything, when I wake up (unless someone figures it out :) )

Though

The second is BOdeorbit:


lock THROTTLE to 0.[B][SIZE=6][/SIZE][/b]

that arrow thingy is new, it wasn't in your previous paste, does it exist in your in game script? (the character didn't even want to come through the quote, had to manually c&p it from your post :huh: )

Edited by Sacred Aardvark
Link to comment
Share on other sites

that arrow thingy is new, it wasn't in your previous paste, does it exist in your in game script? (the character didn't even want to come through the quote, had to manually c&p it from your post :huh: )

I… um… what arrow thingy? I see nothing but my code there, and there certainly wasn't one in my original code. :P

Link to comment
Share on other sites

I… um… what arrow thingy? I see nothing but my code there, and there certainly wasn't one in my original code. :P

Ugh... I was afraid of that... Kept on disappearing on me when I was editing that, refreshing the page made it appear occasionally... I might just be sleep deprived :D

giving it one more whirl:

lock THROTTLE to 0.

see it at the end of the line, after the period? :| [edit] nvm, the previous edit made it go bye bye, see image link at the bottom

Proabably not, just checked with Chrome, it isn't there... Opera does show it, weirdness. Firefox not showing it either. :huh:

Think I might be losing my mind, what little is left of it.

[edit] http://i.imgur.com/ji1S3aC.jpg Freaking invisible arrows. -_-

Edited by Sacred Aardvark
Link to comment
Share on other sites

Huh, I have no idea what that little arrow might be. I can't find anything about it on the internets. Maybe its some sort of keystroke indicator that isn't commonly displayed? Or maybe it's just something only Opera shows?

I'm pretty sure it isn't the cause of my troubles though. :)

No idea what it is either, never seen it before and have been using opera for ages, don't remember my opera updating recently either. And it wasn't visible when you first post the code.

Still, humor me and delete the whole line and type it up again, probably wont make a difference and we can chalk it up to opera being silly, but the alternatives of the mods or your ascent script breaking something with the deorbit don't seem that probable either. :/ (unless i'm totally missing something about the code, which doesn't seem unlikely ;) )

Or try running the deorbit script on the ground like I did, if it works it's likely something about the ascent script and not the mods. (which I shall add to my test tomorrow, if I ever make it to bed instead of just lurking the forums like I seem to be)

Edited by Sacred Aardvark
wither and either are the same thing, right? damn typos -_-
Link to comment
Share on other sites

Ugh... I was afraid of that... Kept on disappearing on me when I was editing that, refreshing the page made it appear occasionally... I might just be sleep deprived :D

giving it one more whirl:

lock THROTTLE to 0.

see it at the end of the line, after the period? :| [edit] nvm, the previous edit made it go bye bye, see image link at the bottom

Proabably not, just checked with Chrome, it isn't there... Opera does show it, weirdness. Firefox not showing it either. :huh:

Think I might be losing my mind, what little is left of it.

[edit] http://i.imgur.com/ji1S3aC.jpg Freaking invisible arrows. -_-

I think that is some sort of formatting indicator. I've seen it before in word/open office documents. I think it marks an end of line, or a return (although i thought that was an arrow with a tail that was up, like on the enter key). May have something to do with RTF....maybe...or a character that couldn't be displayed (like how kOS replaces some symbols like _ with arrows).

Link to comment
Share on other sites

Quick question: how does kOS know anything is a variable? The examples use X and Y, but I notice that I often have to use something like alttime1 instead of alttime for kOS to understand what I mean.

Edited by Camacha
Link to comment
Share on other sites

If you try to type a "^" in the terminal in kOS, you get that arrow. I *think* it still works right and raises the number to an exponent.

The up-arrow is the Commodore 64's font set way of printing the caret character, and the game borrows a Commodore 64 font so I guess this is what's happening.

(I sort of wish it had the full Commodore 64 font set so I could draw boxes and lines with it, but it doesn't have those characters.)

Link to comment
Share on other sites

I'm new to KOS and have a few questions.

When I get retrograde is that surface or orbit? and can I switch?

Also so is there a way to convert a vector into a rotation and back. (I know I'll lose roll information.)

I want to work out how to thust 50% between my surface retrograde and the horizon to kill my sidways movment. So I can time a Suicide burn.

Thanks.

Edited by ttnarg
spelling
Link to comment
Share on other sites

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