Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

45 minutes ago, rkarmark said:

My is on windows 10, steam, got the zip from spacedock, 32 bit and intel intergrated graficks (sorry i am not the best at english)

The cause of the problem with blocks for letters was found and fixed.  We released a new version just to fix it.  Are you on kOS version 0.19.1 ?  if so then update to 0.19.2 and it should make the problem go away.  If you are already on version 0.19.2 and still have the problem, then please tell us because that would be a different, new bug then.

Link to comment
Share on other sites

I'll be starting a new career from scratch tonight using the UnmannedBeforeManned mod to make it interesting with kOS.  I figured as long as I'm doing that I may as well broadcast it on Twitch as I do it.  Even if I don't get many viewers at all, I'm basically just broadcasting what I was going to do on my own anyway.  Come on in and join the peanut gallery and offer up "advice" if you like.

https://www.twitch.tv/dunbaratu

Start time is 7:00pm tonight in Central US timezone, which is UTC-6 timezone (so, 1am UTC).

I don't know how long I'll play for yet, because that kind of depends on viewership.  I'll be going at least a couple of hours for my own purposes, and could keep going for a long marathon session if there's enough of an audience to talk to.

Fuller description here:

https://www.reddit.com/r/Kos/comments/4a0q0m/going_to_try_a_live_kosdriven_career_from_scratch/

Link to comment
Share on other sites

On 3/11/2016 at 6:34 PM, TJ179 said:

Hey. 

 

i want to make an script in kos that can calculate und flay from any planet to an other planet, like Trigger Transfer Window

i had tried a lot but i have nothing that works in the right way... :(

can someone help me please? 

There is a lot of very complicated math that goes into doing something like that.  One of the nice things about KSP mods being open source is that you can always go look and see how someone else does something.  So, you can try checking out the Transfer Window source to see how Trigger does the math.  Otherwise, you can search for other guides on Lambert solvers.  It took me over a month to write my solver, and I am planning on re-writing to use another calculation method that should be faster and more robust.  I'm weary of siting specific links without gauging your interest in that level of math, since most of my research involved reading legit calculus, astrophysics class powerpoints from the internet, and master theses.

Link to comment
Share on other sites

And I am back, with version 11 of my kOS landing program!

 

 

What's changed?

  • I've completely rewritten the program, it's much cleaner, easier (to understand heh) and more precise than the previous ones
  • The base is working perfectly, I will only change some factors in the future, to make the landings perfect, the hardest part is done, just some tweaks
  • The program can now handle incredibly high TWR's (>5 - unlimited), due to better formulas etc. My program I previously showed off in a video was only able to reliably land rockets up to a max. TWR of ~4.5
  • THe program can now make a much better estimate of how long the landing burn has to be, because it now calculates the TWR the vessel has right now, but also calculates how high the TWR will be after the landing, so it takes the average out of these two to fine-tune it's landing burn

 

Steering is currently being worked on, but I first want(ed) to get the throttling done properly!

 

 

Here's a DSCOVR - like landing attempt of my Falcon 9 first stage in the ocean (Remember, only the landing itself is actually done by the program - for now... ;)

 

 

 

Edited by Kartoffelkuchen
Link to comment
Share on other sites

Sorry to ask such a basic question. I've got a small test rocket on the pad and i'm trying to read the amount of fuel in the stage. I'm using RO/RealFuel .

When I do

>List Resources.

Stage      Resource Name                  Amount
------------------------------------------------
0          Aniline                        178.81
0          ElectricCharge                  26.49
0          Furfuryl                        44.70
0          IRFNA-III                      323.59
2          Aniline                        220.76
2          Furfuryl                        55.19
2          IRFNA-III                      399.50
4          Aniline                        220.76
4          Furfuryl                        55.19
4          IRFNA-III                      399.50

>print stage:number.
4
 

But when I try to do Print Stage:Aniline.  I get 0. If I try Stage:Resources all it shows is the electriccharge. So how do I get the amount of Aniline left?

EDIT: GOT IT, I have to start the first stage before it shows resources.

Edited by katjap
Found it!
Link to comment
Share on other sites

3 minutes ago, ILikeIke said:

What's the simplest way to write a PID loop? I've seen great examples of how to make a PID loop longhand, but I can't figure out what it means by when it says "pidloop feature" (first paragraph, http://ksp-kos.github.io/KOS_DOC/tutorials/pidloops.html). Can anybody show me where to find an example of this?

There’s a new section of that page that shows a relatively simple example of using pidloop(), translating the longhand PID loop script from the previous section: http://ksp-kos.github.io/KOS_DOC/tutorials/pidloops.html#using-pidloop

Link to comment
Share on other sites

16 hours ago, katjap said:

EDIT: GOT IT, I have to start the first stage before it shows resources.

Yeah. basically the definition of "current stage" that it's using is "everything connected to the currently active engines".

 

Link to comment
Share on other sites

// function can not be compiled
function lockSteering {
    parameter x.
    lock Steering to x().
}

// this part can be compiled
lock st001 to Heading(...).
lockSteering(st001@).

The new delegates allow for a nice workaround to the problem of compiling Steering/Throttle locks. This works as long as each of the compiled locks has a unique name (st001, st002, ...). This saved me a ton of loading time for scripts that could not be compiled before!

Link to comment
Share on other sites

First, I'm sorry if this has been answered but I haven't found that so:

Been away from KOS for a while now. Has anything changed recently? I am no longer able to load the code into the KOS units (none of them) in VAB. I distinctly remember a slider in VAB where one could pre-load the code before launch. That slider is no longer available to me. Only slider is hdd size.

Just in case it matters, here is my mod list

Spoiler

KAS

KER

KIS

KOS

KWCommunityfix

KW Rocketry

Magic Smoke Industries

MRS

Proc Fairings

Proc Parts

RT

SCANSat

SpaceY

StockBugFixPlus

TriggerTech

TweakScaleMaster

Umbra Space Industries

 

UPDATE: Re-downloaded KOS and the slider is back so it appeared to have been a corrupt download.

Edited by LN400
Adding latest
Link to comment
Share on other sites

I'm having an issue with the warp display: I regularly come to a state where the display is stuck in "rails" mode (1x) while physics warp is active. In this state, even shutting down the KOS core and manually resetting the warp does not help. So it might be a KSP issue.

Is this known? I haven't found any reference for it, the closest is an old kOS issue where warp behavior would be stuck in physics mode.

Link to comment
Share on other sites

2 minutes ago, pellinor said:

I'm having an issue with the warp display: I regularly come to a state where the display is stuck in "rails" mode (1x) while physics warp is active. In this state, even shutting down the KOS core and manually resetting the warp does not help. So it might be a KSP issue.

Is this known? I haven't found any reference for it, the closest is an old kOS issue where warp behavior would be stuck in physics mode.

Known might be a little strong, but I have indeed run into issues with warp modes both with and without kOS installed.  There must be some internal logic that KSP uses to toggle between the two that doesn't always trigger correctly.  In my scripts I simply force whatever mode I want to use `set warpmode to "rails".`.  I've also been able to fix the display in the past by manually increasing warp to "1" and then back down to "0" using the keyboard.

Link to comment
Share on other sites

Bug Report: Blizzy Toolbar setting resets every time game exits

 

Just as the title says, it resets every time the game exits, requiring the user to reapply the setting. It's a minor annoyance to be sure, but it's there none the less. Been this way since 0.19. Submitted it on github as well.

Link to comment
Share on other sites

Thank you for this mod. I finally solved the problem of my fighter jet overcompensating at low speed due to thrust vectoring by introducing an infinite loop that checks the speed and turns the vectoring on/off:

LIST ENGINES IN engList.
SET limit TO 220.

WHEN ((GROUNDSPEED > limit + 5) and (engList[0]:GETMODULE("KM_Gimbal_3"):GETFIELD("gimbal") = FALSE)) or ((GROUNDSPEED <= limit - 5) and (engList[0]:GETMODULE("KM_Gimbal_3"):GETFIELD("gimbal") = TRUE)) {
IF engList[0]:GETMODULE("KM_Gimbal_3"):GETFIELD("gimbal") = TRUE {
FOR eng IN engList {
   eng:GETMODULE("KM_Gimbal_3"):SETFIELD("gimbal",FALSE).
}.
} else {
FOR eng IN engList {
   eng:GETMODULE("KM_Gimbal_3"):SETFIELD("gimbal",TRUE).
}.
}.
PRESERVE.
}.

The only problem is that I don't know how to terminate the script. Not that I need to do it, it works like a charm, but it makes me feel uncomfortable knowing that I don't know how.

I couldn't find it in the documentation. Is there some Exit function I can write in the command window to kill the script?

Edited by theend3r
Link to comment
Share on other sites

1 hour ago, theend3r said:

The only problem is that I don't know how to terminate the script. Not that I need to do it, it works like a charm, but it makes me feel uncomfortable knowing that I don't know how.

I couldn't find it in the documentation. Is there some Exit function I can write in the command window to kill the script?

The easiest way is to provide your own exit variable, and disable the `preserve.` call if that variable is true.

In addition, you could simplify the trigger execution by enabling different triggers based on the state:

list engines in engList.
set limit to 220.
set running to true.

function watchToLock {
    when GROUNDSPEED < limit - 5 then {
        for eng in engList {
            if (eng:GETMODULE("KM_Gimbal_3"):GETFIELD("gimbal") = false) {
                eng:GETMODULE("KM_Gimbal_3"):SETFIELD("gimbal", true).
            }
        }
        if running watchToUnlock().
    }
}
function watchToUnlock {
    when GROUNDSPEED > limit + 5 then {
        for eng in engList {
            if (eng:GETMODULE("KM_Gimbal_3"):GETFIELD("gimbal") = true) {
                eng:GETMODULE("KM_Gimbal_3"):SETFIELD("gimbal", false).
            }
        }
        if running watchToLock().
    }
}
watchToLock().
wait until abort.
set running to false.
wait 0.001.

This way your trigger condition is only evaluating fairly simple math on a single bound variable, rather than trying to walk the module tree every single update.

When you break execution (return from the program to the interpreter) the trigger will automatically be removed.  If you need it removed before returning to the interpreter, you can add `or running` to the trigger condition, and just wrap the entire body in an `if` condition `if running { for eng in...`

Edited by hvacengi
Update code
Link to comment
Share on other sites

Hi,

i just found out about this mod and I have to say I am intrigued...

I plan on starting a new career built around kOS. Do you guys have any suggestions as to what other mods i should be using along with kOS to make a "perfect" install (that will be outdated in a few weeks so I get to start all over again... but that's part of the fun, right?).

So far I'm thinking of something like this:

kOS (obviously)

RemoteTech

SCANsat

DMagic Orbital Science

Kerbal Alarm Clock

Precise Node

Kerbal Engineer

Transfer Window Planner (maybe)

FAR (maybe)

KW Rocketry

RealChute (maybe)

Some form of Life Support (maybe)

Am I missing anything you guys would consider vital? Are there any known incompatabilities with any of these mods? I would also likesomething along the liines of KSP Interstellar but I am worried that the rather complex engine management of KSP-I could prove somewhat problematic. Can you suggest other mods that add futuristic engines (I use KSP-I mostly for the engines) that don't require quite as much micromanagement?

Link to comment
Share on other sites

6 hours ago, hvacengi said:

The easiest way is to provide your own exit variable, and disable the `preserve.` call if that variable is true.

In addition, you could simplify the trigger execution by enabling different triggers based on the state:


list engines in engList.
set limit to 220.
set running to true.

function watchToLock {
    when GROUNDSPEED < limit - 5 then {
        for eng in engList {
            if (eng:GETMODULE("KM_Gimbal_3"):GETFIELD("gimbal") = false) {
                eng:GETMODULE("KM_Gimbal_3"):SETFIELD("gimbal", true).
            }
        }
        if running watchToUnlock().
    }
}
function watchToUnlock {
    when GROUNDSPEED > limit + 5 then {
        for eng in engList {
            if (eng:GETMODULE("KM_Gimbal_3"):GETFIELD("gimbal") = true) {
                eng:GETMODULE("KM_Gimbal_3"):SETFIELD("gimbal", false).
            }
        }
        if running watchToLock().
    }
}
watchToLock().
wait until abort.
set running to false.
wait 0.001.

This way your trigger condition is only evaluating fairly simple math on a single bound variable, rather than trying to walk the module tree every single update.

When you break execution (return from the program to the interpreter) the trigger will automatically be removed.  If you need it removed before returning to the interpreter, you can add `or running` to the trigger condition, and just wrap the entire body in an `if` condition `if running { for eng in...`

Thanks! That's a nice solution but I wanted to avoid locking myself out of the terminal by using any "until" loops. I actually had a more efficient solution but that locked me out in a similar manner. 

Edited by theend3r
Link to comment
Share on other sites

1 hour ago, bertibott said:

Hi,

i just found out about this mod and I have to say I am intrigued...

I plan on starting a new career built around kOS. Do you guys have any suggestions as to what other mods i should be using along with kOS to make a "perfect" install (that will be outdated in a few weeks so I get to start all over again... but that's part of the fun, right?).

Am I missing anything you guys would consider vital? Are there any known incompatabilities with any of these mods? I would also likesomething along the liines of KSP Interstellar but I am worried that the rather complex engine management of KSP-I could prove somewhat problematic. Can you suggest other mods that add futuristic engines (I use KSP-I mostly for the engines) that don't require quite as much micromanagement?

I could recommend SETIctt and mods that are covered with it. I also prefer FAR, but it is optional, it might be "too much" as starting point for KSP playtrough. You also might choose unmaned before maned instead of SETI balance mod, but it is better for you to read more about it in main SETIctt thread.

Link to comment
Share on other sites

SAS on.
RCS on.
print "Attitude Control System Enabled.".
lock steering to (-1) * Ship:Velocity:Surface.
when steering = (-1) * Ship:Velocity:Surface then {
     set SASmode to "stabilityassist".
     unlock steering.
     print "Manual control enabled. Hold within 20° of retrograde.".
}

if SteeringManager:ANGLEERROR > 20 { 
     print "Spacecraft orientation is not within 20° of retrograde. ACS is re-orienting the spacecraft.".
     lock steering to (-1) * Ship:Velocity:Surface.
     when steering = (-1) * Ship:Velocity:Surface then {
          set SASmode to "stabilityassist".
          unlock steering.
          print "Manual control enabled. Hold within 20° of retrograde.".
     }
     print "Spacecraft re-orientation successful.".
}

-----

I'm trying to write a script that will hold a spacecraft within 20° of retrograde, and this isn't returning any errors, but it's also not rotating the spacecraft. Does anybody have an idea about what I could be doing that's wrong?

Link to comment
Share on other sites

20 hours ago, ILikeIke said:

I'm trying to write a script that will hold a spacecraft within 20° of retrograde, and this isn't returning any errors, but it's also not rotating the spacecraft. Does anybody have an idea about what I could be doing that's wrong?

when steering = (-1) * Ship:Velocity:Surface then {
...
if SteeringManager:ANGLEERROR > 20 {

Steering is a bound variable, and will return the direction that steering locked to, not the direction your ship is facing.  If you want to use vectors, use ship:facing:vector, but you might as well use the steering manager's angle error suffix since you're already using it anyways.  In addition, once you unlock steering, the steering manager will stop updating the angle error (because there is no reference direction to compare to).  I'd say you're using your vector condition and steering manager condition backwards.

I'm also a little confused by your mixing of if and when without showing a loop.  The if block will only be executed once, and it will be evaluated immediately after setting up the when block.  If the condition for your if block does not evaluate true, it will pass over it and go to the next section of the program.  If there is no additional section of the program, it will return to the terminal unlocking steering in the process.

You also don't need to continually set sasmode to "stabilityassist", it defaults to stability assist mode whenever you turn on SAS (KSP limitation, not kOS).

Is there a particular reason you aren't using the cooked steering and locking to the direction you desire, instead of letting it drift?

Edited by hvacengi
Link to comment
Share on other sites

59 minutes ago, ColKlonk said:

Well.. I'm fairly happy with this accuracy.

Automated launch to orbit, locks onto a target inclination. An accuracy of 0.007 degrees give me about 830m at 400Km.

Nice!  Figuring out target-rendezvous launches is my next major project.

Somewhat unrelated question: how’d you move the navball to the left?

Link to comment
Share on other sites

10 hours ago, hvacengi said:

when steering = (-1) * Ship:Velocity:Surface then {
...
if SteeringManager:ANGLEERROR > 20 {

Steering is a bound variable, and will return the direction that steering locked to, not the direction your ship is facing.  If you want to use vectors, use ship:facing:vector, but you might as well use the steering manager's angle error suffix since you're already using it anyways.  In addition, once you unlock steering, the steering manager will stop updating the angle error (because there is no reference direction to compare to).  I'd say you're using your vector condition and steering manager condition backwards.

I'm also a little confused by your mixing of if and when without showing a loop.  The if block will only be executed once, and it will be evaluated immediately after setting up the when block.  If the condition for your if block does not evaluate true, it will pass over it and go to the next section of the program.  If there is no additional section of the program, it will return to the terminal unlocking steering in the process.

You also don't need to continually set sasmode to "stabilityassist", it defaults to stability assist mode whenever you turn on SAS (KSP limitation, not kOS).

Is there a particular reason you aren't using the cooked steering and locking to the direction you desire, instead of letting it drift?

To be totally honest, this is my first time programming anything like this in kOS (previously I've only done launch scripts, and that was in pre-1.0), so I honestly can't justify my decisions in terms of what I thought was best practices. For starters, I have no clue how to use vectors to rotate the ship, though I plan on trying to learn. What's the difference between a vector and a rotation?

i didn't know that I needed a loop for an if statement. I tried using the "preserve." command, but got an error about using it outside a loop, which I didn't understand at all.

i thought I was using cooked steering as much as I was able to, because I was under the impression that I couldn't use cooked steering to aim for retrograde. How would pure cooked steering look for this?

Link to comment
Share on other sites

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