Jump to content

[KSP 1.10.1 and 1.11] kOS v1.31.0 : kOS Scriptable Autopilot System


Recommended Posts

1 hour ago, scimas said:

Check the ModuleManager documentation, it does allow checking for presence of modules among many many other things.

 

6 hours ago, darthgently said:

Is there a way to tell by the syntax of the KOSProcessor entry in the .cfg whether it is checking to see if it is already there or not?  Or does that logic occur elsewhere?  Pardon my jumping in please, but this applies to something.  I want something to grep for to automate this kind of audit for this and related situations

For module checking you want to use something like this:

 

@PART[*]:HAS[MODULE [kOSProcessor]{ }

Link to post
Share on other sites

Just to add that you'd use a ! to negate the check i.e. anything that tries to add in a kOS processor module should be checking that there isn't already one.

Something like kos-for-all goes through all parts with the Command module, adding kOSProcessor if there isn't already one. I imagine it would be harder to find examples where the check isn't done properly (if at all).

Link to post
Share on other sites
26 minutes ago, ElWanderer said:

Just to add that you'd use a ! to negate the check i.e. anything that tries to add in a kOS processor module should be checking that there isn't already one.

 

True, but it so depends on what you want to do.  If you're just checking for it to be there, before pushing the module, yeah.  But, you really want a sequential patch.

@PART[*]:HAS[MODULE[kOSProcessor]]:NEEDS[Gobbledegook]
{
    %diskSpace = 10000
    %ECPerBytePerSecond = 0.00001
    %ECPerInstruction = 0.000008
}

@PART[*]:HAS[!MODULE[kOSProcessor]]:NEEDS[Gobbledegook]
{
    %MODULE
    {
        %name = kOSProcessor
        %diskSpace = 10000
        %ECPerBytePerSecond = 0.00001
        %ECPerInstruction = 0.000008
    }
}

 

Edited by TranceaddicT
Link to post
Share on other sites

In the interest of good form and efficiency I want to use "listeners" over polling when possible. 

I have a stack of vessels connected to a main vessel and they each have multiple potential control points.  I want to detect when each has been separated and which control point takes over on that vessel any time it changes.  I'm wanting to allow for mods (TCA, mechjeb), ksp, or me (setting "control from here" for docking etc), or whatever changing the control point for whatever reason so my code can simply adapt to the situation or change it to what it requires.  One thing I'm working on is changing the colors of the nav lights on the craft to reflect current dorsal, ventral, starboard, port sides of the vessel (like the nav lights on aircraft or boats) so I can tell at a glance the orientation of the vessel as the colors change along with the change in control point (and control point orientation).  Can I "listen" for this change of control point in some non-blocking notification style way or do I have to poll for it using a WHEN that evals every loop?  I realize that from a user perspective the WHEN/ON seems like a type of event listener, but it is really polling every loop from what I can tell

Maybe a better way to ask this is what is the nature of cooked, recurring, and callback triggers with regards to whether it is more of an event listener or basically just polling.  My take so far is that some (but not all) LOCKs and cooked stuff seem like they may be more of a non-blocking event listener type mechanism underneath updating the locked variable from which can be read the most current value in a quasi-polling kind of way, while recurring WHEN/ON stuff is basically polling.  And the GUI callbacks appear to be true listeners, but a lower priority than most other code.  I haven't fully digested delegates yet but I'm thinking they could work like true listeners also.  That said, can I listen for point of control change or will I need to do a WHEN/ON or some type of delegate (that I've yet to fully understand)

Thanks!

Edited by darthgently
Link to post
Share on other sites

What is the best forum for discussing KOS coding detail questions?  I've about got my nav light script how I want it but want to know the best way to make it always running on all of my ships.  I don't want just hack it then have to fix it later.  But this forum seems a bit quiet for that kind of getting into the weeds on things

 

Here is question relevant to this forum: is there a way to attach an exit function to the code that always executes even if terminated by the user (ctrl-c etc)?

Edited by darthgently
Link to post
Share on other sites
  • 2 weeks later...
  • 3 months later...
16 hours ago, infinite_monkey said:

Can someone point me to a formula that limits my steering vector by a maximum AoA angle?

This is how I do it:

 
FUNCTION launchSteerUpdate
{
    LOCAL cur_v IS SHIP:VELOCITY:SURFACE.
    LOCAL new_v IS HEADING(launchBearing(),launchPitch()):VECTOR.
    LOCAL max_ang IS launchMaxSteer(). // returns different values depending on height/velocity

    IF VANG(cur_v,new_v) > max_ang
    {
        // limits the maximum angle between our surface velocity vector
        // and where we are aiming to steer
        SET new_v TO ANGLEAXIS(max_ang,VCRS(cur_v,new_v)) * cur_v.
    }

    SET LCH_VEC TO new_v. // LCH_VEC is a global where I store the vector I want to steer to
}

 

Link to post
Share on other sites
  • 2 months later...
44 minutes ago, tonimark said:

i have to say that this is intarelly broken:

546 issues on github , this mod is a mess

do your flights manually instead

All modders out here do this stuff for free, they don’t get paid and completely do this in their free time. Your statement above is just frustrating for the people behind it (or rather dunbaratu, he’s the only developer left). They put hours and days into project just to provide us with free updates. kOS is a huge mod/repository trying to maintain it alone is very hard to do, so please don’t post such comments. Instead we should all thank dunbaratu for all his work on kOS. Just yesterday he released a huge update. 

And then if you aren’t happy with a mod, provide and post comments that can help the developer(s) to improve their mod, your comment isn’t helping anyone. 

Link to post
Share on other sites

Did you try using it recently? I've been using this mod with very few issues for quite a while. Many of the issues on GitHub are minor things that are easy to code around, or feature requests from people. 

Link to post
Share on other sites
7 minutes ago, Zelda said:

Did you try using it recently? I've been using this mod with very few issues for quite a while. Many of the issues on GitHub are minor things that are easy to code around, or feature requests from people. 

i thought it may be not fuctional with 1.11 have you tried it?

Link to post
Share on other sites
16 minutes ago, tonimark said:

i thought it may be not fuctional with 1.11 have you tried it?

There is description in changelog for latest release on github what is working and what not with KSP v1.11 in greater detail. Short answer, yes, it works with KSP 1.11, with in KSP and unity game engine limitations.

Link to post
Share on other sites
22 minutes ago, tonimark said:

i thought it may be not fuctional with 1.11 have you tried it?

I haven't tried 1.11 personally, but from what I've read on the kOS Discord server, the latest release is compiled against 1.10 and should work with 1.11 as well.

 

Edit: What kcs123 said. :)

Edited by Zelda
Link to post
Share on other sites
6 hours ago, tonimark said:

i have to say that this is intarelly broken:

546 issues on github , this mod is a mess

5 hours ago, tonimark said:

lets hope that it won't affect it's fuction 

So you just decided to call a mod a mess and spread misinformation based on the number of issues? Without even trying to see whether most of its functionality is affected or not?

Link to post
Share on other sites
10 hours ago, tonimark said:

i have to say that this is intarelly broken:

546 issues on github , this mod is a mess

do your flights manually instead

good luck getting anyone who actually uses this mod to agree with you there, bud

Link to post
Share on other sites
2 minutes ago, Drew Kerman said:

good luck getting anyone who actually uses this mod to agree with you there, bud

the concept may seems like something unconvient at first but it can be to revolutinatize automation in SSTO flights and interplanetry transfer making playing the game by idling

Link to post
Share on other sites
5 hours ago, Steven Mading said:

The "soft" release yesterday has a bug related to using TimeSpan in a few places where it should be using TimeStamp.  Expect another update today or tomorrow.

There is a new kOS 1.3.1.0 that fixes this on the Github page.  I won't put it on Curse or SpaceDock until it's been on Github for a day or two, just to be sure people have tried it and not complained about a major problem before I do that.

(When I do that, I'll also update the first post of this thread and make it official.  But until then you can try it and report any problems.)

Link to post
Share on other sites

kOS v1.3.1.0 official announcement

(See First Post in this thread for links to download it.)

There's a lot of small changes over the last year that have added
up to a big release. This release supports KSP 1.10 and KSP 1.11.
It has no specific KSP 1.11 changes but it has been tested and it does
work with KSP 1.11.

(NOTE ABOUT KSP 1.11 - If you want to put a kOS part into one of
the new cargo inventory slots that came with KSP 1.11, you can do so
but remember to FIRST attach it to the vessel in the VAB/SPH so you can
adjust the disk space and boot file settings, then detach it from the
vessel and drag it into the cargo slot - that way it has the settings you
gave it. If you just drag it directly into the cargo slot from the parts
bin then it only has the default values.)

The most important changes are probably in steering and control.
Cooked steering shouldn't waste as much RCS as it used to, and if you
are using raw control you now have the ability to set the player's trim
settings for yaw, pitch, and roll so you can steer using those and
not completely lock the player out of control. There is also a
panic button for telling kOS to suppress all of its controls if the
player needs to take over the controls regardless of what the script
is doing.

As always, recompile KSM files with this release. Especially as there
was an important KSM bugfix.

BREAKING CHANGES

  • TimeSpan used to mean a fixed stamp in time (the name was not
    really accurate). Now there are two types, TimeStamp and
    TimeSpan, and the one that USED to be called TimeSpan
    is now called TimeStamp, with TimeSpan now being a new
    type that didn't exist before. This could affect scripts if
    you ever did a check for :istype("TimeSpan") (because of
    the rename) but shouldn't affect anything else.
  • Even more than usual it's important to recompile any KSM files.
    A major bug in how KSM files were written was discovered that this
    release fixes. There's a chance your existing KSM files may
    already be wrong. If you have any bug reports about a KSM file
    not working right, please try testing again with this release by
    recreating the KSM file. There's a small chance you might have
    had the bug this release fixes. (Look for "KSM" in the bug section
    below.)
  • If you are using the output of SteeringManager:WRITECSVFILES,
    be warned that output now has a new column in the second-to-last
    position, the MinOutput column. That means the MaxOutput column
    has shifted one position to the right. This should only affect
    people who are analyzing that data with external software.
  • In order to support Kerbal Alarm Clock version 3.0.0.2 or higher
    it was necessary to break compatibiltiy with versions of Kerbal
    Alarm Clock that are older than that. The API wrapper changed
    enough that backward compatibility is too messy to maintain.
  • The :LIST suffix of VOLUME said in the documentation
    that it returns a LIST when in reality it always returned
    a LEXICON. If you relied on this and wanted the lexicon
    not the list, you need to now use the new suffix :LEXICON
    because the old suffix :LIST has been changed to match the
    documentation and be a real actual LIST now.
  • Temperature tolerance for the kOS parts was way too high, making
    them effective heat shields when they shouldn't be. If you had been
    taking advantage of this before that might not work anymore.
  • CREATEORBIT() used to take mean anomaly at epoch as a value in
    radians, which didn't match how everything else in kOS works.
    It is now expecting it in degrees as described in BUG FIXES
    below.
  • If you ever happend to have a string literal with a backslash
    followed by a quote mark (\") that has now become a special
    escaped quote char and is no longer literally a backslash and
    quote mark.

NEW FEATURES

  • Maneuver Nodes can now be constructed with either ETA time or
    with UT time, and you can read their time either as UT (:TIME)
    or as ETA (:ETA). They also can take in the new Timestamp
    or TimeSpan types instead of just a Scalar number of seconds if
    you like.
    pull request
  • There's a new button, "Reread Boot Folder", on the kOS toolbar
    window when you're in the VAB or the SPH. This button lets you
    tell kOS to re-read the boot directory when you've just added
    a new file to it, so you don't have to leave the VAB and come
    back for it to show up in the list of boot files.
    pull request
  • The old TimeSpan type has been renamed to TimeStamp and
    a new TimeSpan type has been made in its place. This is to
    fit the design pattern where a "stamp" is a fixed point in time (a
    date and a time of day) and a "span" is a time offset. The main
    difference in Kerbal is whether you count years and days
    starting at 1 or at 0.
    pull request
  • Suffixes :PARTSTAGGED, :PARTSNAMED, and :PARTSDUBBED
    can now be used with parts instead of with entire vessels. Doing
    so searches just the sub-branch of the ship starting from that
    part, instead of the whole ship.
    pull reqeust
  • Added a new Suffix to RCS parts, :DEADBAND that lets you
    finally override the game's enforced 5% deadband on RCS
    controls. It turns out the deadband isn't in the controls,
    but rather it's in the RCS Parts themselves and doesn't apply
    to other torque sources like reaction wheels. That's why
    you notice it when translating (where only RCS works) and not
    when rotating (where reaction wheels do something and take
    up the slack left by the RCS thrusters not responding).
    pull request
  • Big overhaul to SteeringManager's internals:
    There's been some important refactoring in SteeringManager that
    should reduce the control vibrations and consequently the
    RCS fuel wastage especially in Realism Overhaul (which relies
    more on RCS than stock does). Also, there's some
    user-settable epsilon values - if you want to change the tuning
    you can adjust SteeringManger:ROTATIONEPSILONMIN and
    SteeringManager:ROTATIPONEPSILONMAX.
  • The random number generator now can be fed a seed.
    pull request
  • PIDLoop is now a serializable structure so you can save
    your PID's settings and bring them back from a file. Also
    PIDloop's CSV output now has a Minoutput column.
    pull request
  • Enlarged max allowed terminal font size to 48, to benefit
    people with tiny pixels (i.e. 4k monitors).
    pull request
  • Uses the changes to Kerbal Alarm Clock's API that started
    with Kerbal Alarm Clock v3.0.0.2. (This does break compatibility
    with older versions of Kerbal Alarm Clock, though.)
    pull reqeust
  • On-Screen warning when SAS is fighting kOS: The message
    appears when both SAS and lock stering have been active for a
    few seconds and goes away when one or the other is turned off.
    pull request 2780
    pull request 2783
  • Emergency Suppress Autopilot: You can now click an emergency
    toggle button on the kOS toolbar dialog window that will
    temporarily suppress all of kOS's locked steering so you have
    manual control. If you use this, the script will still keep
    running and think it's moving the controls, but the steering
    manager will ignore the script's commands until you turn the
    suppression toggle off. This can also be bound to an
    action group for the kOS PartModule if you want a fast hotkey
    for it.

    pull request
  • Part suffixes that allow you to traverse the symmetrical
    sets of parts. (i.e. if you place 4 fins in radial symmetry,
    and have a reference to one of the fins, you can find the other
    3 fins that it is symmetrical with.)in the same symmetry set)
    pull request
  • The player's own TRIM controls are now settable by script.
    (Example use case: You want an autopilot to control an
    airplane by moving the trim but not the main controls so
    the player is still free to push the main control stick at
    any time).
    pull request
  • ETA:NEXTNODE now an alias for NEXTNODE:ETA
    pull request
  • Trajectories Addon updated to support Trajectories v2.4 changes.
    (Thanks PiezPiedPy)
    pull request
  • Kuniverse:launchcraftwithcrewfrom()
    (Thanks JonnyOThan)
    pull request
  • New suffixes for the special case where a Vessel is really an
    asteroid. (Thanks JonnyOThan)
    pull request
  • Ability to read the stock game's Delta-V readouts for the vessel.
    (Thanks ThunderousEcho)
    pull request
  • New subtype for Part - the RCS part type, with information
    about how its nozzles are aimed, what fuel it uses, the ISP,
    max thrust, etc. (Thanks RCrockford)
    pull request 2678
    pull request 2809
  • Can now use \" in string literals for embedded quote marks.
    Also can prepend the string with @ to turn this off and keep
    it literal. (thanks thexa4)
    pull request
  • New Engine value suffix :CONSUMEDRESOURCES, and new
    Type ConsumedResource it returns. These
    give more information about fuels the engine uses. Mostly
    relevant when RealFuels mod is installed so every engine is a
    bit different. (Thanks RCrockford)
    pull request
  • Can CreateOrbit() from position and velocity (before
    it only worked with Keplerian parameters).
    (Thanks ThunderousEcho)
    pull request

BUG FIXES

  • Fixed: Kerbal Alarm Clock alarms had no ToString() so when you
    printed them you saw nothing. Now they show the alarm info.
    pull request
  • Fixed: The suffix Widget:HASPARENT was documented but didn't
    actually exist. It exists now.
    pull request
  • Fixed: Primitives like Scalars, Strings, and Booleans previously
    were not serializable with WRITEJSON() on their own as bare
    variables. They could only be written when inside containers like
    LIST() or LEXICON(). Now they can be written directly.
    pull request
  • Fixed: KSM files would corrupt one of the kRISC instruction
    operands (leading to any number of random results when running the
    program) if the size of the operand pack happened to be just barely
    over 2^8, 2^16, or 2^24 bytes. (When calculating how many bytes
    addresses need to be to access the enire operand pack, its count
    of the size of the pack was off by 3. This could make the last
    operand in the pack get garbled when it loaded into memory from
    some random other part of the file instead of where it was supposed
    to come from.)
    (Thanks to newcomb-luke for discovering the problem and the cause)
    pull request
  • Fixed how positions of packed vessels were off by one
    physics frame from the positions of everything else. This
    is apparently how things are reported b the KSP API and this
    had to be adjusted for.
    (Thanks marianoapp)
    pull request
  • Fix Vecdraw labels no longer showing up in flight view
    pull request 2799
    pull request 2804
  • Remove strange blank setting on the difficulty options
    screen.
    pull request
  • OPENPATH() now returns false on file not found rather
    than bombing out with an exception.
    pull request
  • RangeValue now allows use of bigger ranges and for ranges
    that increment by fractional amounts.
    (Before, it couldn't do floating point and couldn't do
    anything bigger than 2^31.)
    pull request
  • Fix raw control :NEUTRALIZE never having quite done
    what it said it did right.
    pull request
  • EVA Kerbals no longer have duplicate KOSNameTags when
    you have the Breaking Ground DLC installed. (The problem
    came from how KSP mashes two kerbal templates together
    into one kerbal to put the DLC science features into an
    EVA Kerbal.)
    pull request
  • VOLUME:LIST now actually returns a list like it says
    in the documentation. Use VOLUME:LEXICON to get
    the lexicon you used to get from VOLUME:LIST.
    pull request
  • UNSET now fails silently on non-existant variables as the
    documentation claims it should, instead of crashing with
    a nullref error.
    pull request
  • Fixed a mistake that made it possible to process lines of
    input out of order if they flood into the terminal very fast.
    It was noticed in JonnyOThan's TwichPlaysKSP, which pastes
    entire scripts of input into the interpreter in one big chunk.
    pull request
  • ADDONS:KAC:ALARM[n]:NOTES now returns the right thing.
    (It used to just return the same thing as :NAME.
    (Thanks JonnyOThan)
    pull request
  • The ConnectionManager dialog box at the start of a career was
    repositioned to where it is unlikely to appear secretly hidden
    behind other mod's dialog boxes. (Other mods putting their)
    dialogs in front of kOS's and not blocking clickthroughs made
    some users accidentally pick a ConnectionManager and dismiss
    the dialog before they ever saw it.)
    pull request
  • UI sound effects from kOS (error beep, SKID sounds) no longer
    have an origin point in 3-D space inside the part. They are
    now "ambient". This is to get sound mods to stop dampening
    the volume the same way they'd dampen sounds from engine
    parts, etc.
    pull request
  • Parts no longer have excessive temperature tolerance.
    (Thanks robopitek)
    pull request
  • CREATEORBIT() now takes mean anomaly at epoch as degrees. It
    was in radians before which didn't match how other things worked.
    (Thanks vzynev)
    pull request
  • Better fuel stability (ullage in RealFuels) calculation.
    (thanks RCrockford)
    pull request
  • Documentation fixes. Too numerous to mention each. You can
    click each of the links below to see them all:
    pull request 2675
    pull request 2680
    pull request 2707
    pull request 2712
    pull request 2724
    pull request 2751
    pull request 2772
    pull request 2775
    pull request 2776
    pull request 2777
    pull request 2784
    pull request 2788
    pull request 2791
    pull request 2800
    pull request 2819
    pull request 2833
  • kOS can now handle KSP's technique of having multiple KSPfields
    of the same name that resolve the name clash by only having one
    visible at a time. KSP started doing this on a few fields
    about a year ago and caused bugs like "authority limiter"
    not working. (#2666)
    pull request
  • kOS no longer allows ModuleManager configs to give it negative mass.
    (Antimatter summons the Kraken.)
    pull reqeust
  • ETA:APOAPSIS no longer returns Infinity on hyperbolic
    orbits (While infinity is a correct answer, kOS scripts
    would crash when they get infinity on the stack. So now
    it says zero instead).
    pull request

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...