Jump to content

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


Recommended Posts

1 hour ago, DunaManiac said:

Will there be a 1.5 version?

We're in the middle of running regression tests on the current 1.4.5 version's ZIP (it takes time because it involves having scripts actually play out the game for reals, not just unit testing).  So far it looks good with nothing changing.  If everything is fine, then all I have to do is edit one small number in a file and CKAN should start allowing it for KSP 1.5 without needing a new release.

In the meantime you can try the current release ZIP that was for KSP 1.4.5 on  KSP 1.5 - I've been doing that for my testing and it has been working so far.

Link to post
Share on other sites

Since Tundra Exploration's new BFR uses the RetractableLiftingSurfaceModule for the "flapping" fins, I have a question: for now, this mod only knows 2 states - retracted and extended. The real BFR will use them for steering, though. What would kOS need from the module so it can control the exact angle (or maybe an extension percentage) of the lifting surface?

 

Link to post
Share on other sites
1 hour ago, infinite_monkey said:

Since Tundra Exploration's new BFR uses the RetractableLiftingSurfaceModule for the "flapping" fins, I have a question: for now, this mod only knows 2 states - retracted and extended. The real BFR will use them for steering, though. What would kOS need from the module so it can control the exact angle (or maybe an extension percentage) of the lifting surface?

 

Is the mod itself capable of leaving a wing in a halfway between state?  That would have to be true first.  kOS can only tell another mod to do a thing that other mod is already designed to do by a human player.

Link to post
Share on other sites
2 minutes ago, Steven Mading said:

Is the mod itself capable of leaving a wing in a halfway between state?  That would have to be true first.  kOS can only tell another mod to do a thing that other mod is already designed to do by a human player.

No, currently not, but @linuxgurugamer wanted to know what would be necessary to do so. I'll let him know.

Link to post
Share on other sites
2 hours ago, infinite_monkey said:

No, currently not, but @linuxgurugamer wanted to know what would be necessary to do so. I'll let him know.

Argg. I typed a long reply, but I accidentally typed some kind of hotkey that made the forum software throw away my composed post and I can't get it back.

Just pass this on to @linuxgurugamer :

As long as your mod exposes to the user a means to manually cause the activity in question with one of the following systems below, kOS should automatically make it possible for a script to do it too:

1 - A KSPField on the rightclick menu:  kOS scripts can "get" the value of a KSPField that is GUI Visible, and can "set" the value of a KSPField that is GUI editable.  If you use a floating point slider widget, then when setting the value kOS will examine that widget's options to make the kOS script abide by the same min/max and "round to nearest detent" rules that the human with a mouse has to live with.

<or>

2 - A KSPEvent on the rightclick menu:  kOS scripts can "click" these buttons as long as they are GUI visible and enabled.

<or>

3 - A KSPAction: kOS scripts can set a KSPAction to TRUE or set it to FALSE, just like what happens when the action group they're part of gets toggled.  But it will only unlock this feature if the player has upgraded their VAB/SPH to the point where the stock game allows custom action groups.  (This kOS feature doesn't really depend on the custom action group system.  It just sets the individual KSPActions one at a time.  But we put this limit in place to match the "feel" of the stock game's rules.)

If none of the above automatically generated kOS systems are good enough for what you want, then you can instead submit a PR to the kOS github, in which you make a new Addon in the src/kOS/Addons directory to add some custom code to kOS just for interacting with your mod.  This is probably a bit more hassle than you want to deal with given how many mods you maintain, but I just mention it for completeness.

Edited by Steven Mading
Link to post
Share on other sites
  • 2 weeks later...

I've just started playing, and I have no idea how to save my programs. I've tried making a file, giving it .ks, and putting in the right place, and I still cannot find it. If I try to load it it says "moonlanding.ks" not found. Help!

Link to post
Share on other sites
3 minutes ago, DunaManiac said:

I've just started playing, and I have no idea how to save my programs. I've tried making a file, giving it .ks, and putting in the right place, and I still cannot find it. If I try to load it it says "moonlanding.ks" not found. Help!

Short answer:

Save and load it on the archive instead of the local volume by naming the filename with a preceding "0:" in front of it, for example, "0:myfile.ks".  Outside of the game you can see the "0:" files in your Ships/Script directory of your KSP home.

Long answer:

There are two "volumes" that each kOS unit can "reach" - the small capacity local one that is *inside* the part, and the infinite capacity global one that is conceptually a big data center "inside" the space center so to speak.  The local drive disappears when the ship goes away.  The global one stays around.  To keep the file around, store it on the global one.

The local drive is called "volume 1" and the global one is called "volume 0", or "the archive". These volumes can be used like "drive letters" in Windows, with a colon, "1:myfile.ks" or "0:myfile.ks".  By default you start on the local drive "1:".  There is a config setting to change this if you like, but I recommend just getting in the habit of using the drive numbers.

Files in the archive (volume 0) can also be edited from outside the game by using whatever external text editor program you feel like.  It maps to a directory on your hard drive.  Specifically it's located in (KSP_HOME)/Ships/Script (note, NOT under GameData), where (KSP_HOME) is wherever your kerbal space program game folder is.  We put it outside the GameData folder because it's content YOU own, not content the kOS mod owns, and de-installing kOS shouldn't get rid of your scripts you worked so hard on.

Link to post
Share on other sites

@DunaManiac screenshots or it didn't happen :)

On a serious side, I think you started with the default settings, which means core starts on its local volume designated as 1:/.

If you saved a file made in a text editor outside the game into the Ships/Script folder, then, for any ship, that file is on the "archive", or volume 0:/.

To run files from the archive, there are two methods:

1. In the kOS terminal, enter SWITCH TO 0. <Return> RUN MYSCRIPT. <Return>

2. In the terminal, enter RUNPATH("0:/MYSCRIPT.KS"). <Return>

Note that with the RUNPATH() command, you need to type full name, including the extension .ks or .ksm. With the RUN command, the default extensions can be omitted.

Also, you can turn on "Start on archive" option in settings and you can copy files from the archive to ship's local drive. More on that in the docs: https://ksp-kos.github.io/KOS/general/volumes.html

Link to post
Share on other sites
6 minutes ago, Pand5461 said:

@DunaManiac screenshots or it didn't happen :)

On a serious side, I think you started with the default settings, which means core starts on its local volume designated as 1:/.

If you saved a file made in a text editor outside the game into the Ships/Script folder, then, for any ship, that file is on the "archive", or volume 0:/.

To run files from the archive, there are two methods:

1. In the kOS terminal, enter SWITCH TO 0. <Return> RUN MYSCRIPT. <Return>

2. In the terminal, enter RUNPATH("0:/MYSCRIPT.KS"). <Return>

Note that with the RUNPATH() command, you need to type full name, including the extension .ks or .ksm. With the RUN command, the default extensions can be omitted.

Also, you can turn on "Start on archive" option in settings and you can copy files from the archive to ship's local drive. More on that in the docs: https://ksp-kos.github.io/KOS/general/volumes.html

Okay. 

vDpniro.png

Is this the right place?

Link to post
Share on other sites
1 hour ago, DunaManiac said:

Thank you. I just realised I wasn't putting .txt as well as filename.ks.:blush:

Go into your File Explorer's settings and disable the setting that causes it to blatantly lie about what filenames are.  Tell it to show the truth about the last part of the filename after the dot properly  (I refuse to call them "extensions"  They're not an "extra", this isn't MS-DOS anymore.  They're no longer a separate field apart from the filename anymore dangit.  Ages ago, Microsoft finally woke up and followed the rest of the world in doing it the right way with the filenames being all one string.  But they still have leftover garbage like this in the user interface that pretends the file "extension" is somehow not part of the filename.).

Then go find the idiot at Microsoft who thought that feature could possibly benefit *anybody* and punch that guy repeatedly about 100 times for me please.  The File Explorer outright lying about file extensions has caused a large number of tech support headaches for so many unfortunate tech support people over the ages who have to field questions from users who got mislead by it.

You probably told it to make a new file of type "text document", and then it secretly added ".txt" to the name *without telling you* and then when you explicitly renamed it to ".ks" it still kept the secret ".txt" after the ".ks" even though you were *explicitly telling it* you wanted it renamed to .ks.  Yeah, I've seen this before.

Edited by Steven Mading
Link to post
Share on other sites
10 hours ago, Steven Mading said:

Then go find the idiot at Microsoft who thought that feature could possibly benefit *anybody* and punch that guy repeatedly about 100 times for me please.  The File Explorer outright lying about file extensions has caused a large number of tech support headaches for so many unfortunate tech support people over the ages who have to field questions from users who got mislead by it. 

You have given me a good laugh :). Very first thing after windows install for me is to enable showing file extension as well as hidden folders on machine. Almost forget about it when I need to work on someone else machine. And I can only add that is not only one useless "feature" in windows. List goes on and on. Each time I encounter on something similar I keep wondering if they using drugs or something when they deceided to made things works like it is. One of worst things is that they change location of system critical programs after each update, like "run" shortcut or access to control panel for example.

Link to post
Share on other sites
13 hours ago, kcs123 said:

You have given me a good laugh :). Very first thing after windows install for me is to enable showing file extension as well as hidden folders on machine. Almost forget about it when I need to work on someone else machine. And I can only add that is not only one useless "feature" in windows. List goes on and on. Each time I encounter on something similar I keep wondering if they using drugs or something when they deceided to made things works like it is. One of worst things is that they change location of system critical programs after each update, like "run" shortcut or access to control panel for example.

A few days ago we wasted about  an hour at a friend's house trying to get the firefox userContent.css file to work (it's supposed to override CSS with your own rules if you have a problem with what a particular website is doing with it's CSS.  We were trying to use it to suppress the <div> section for an Ad banner that was allowing the ad to escape from its sandbox and fill a much bigger box than it's supposed to, so it filled the whole screen on Geoguessr.)  In the end, after trying a zillion things to figure out why it wasn't working, it turns out it was because the file we were editing had been secretly called userContent.css.txt even though we explicitly named it userContent.css, and the .txt never showed up anywhere we could see.

The primary file manipulation tool of the OS shouldn't have blatant lying turned on as it's *default* behaviour - a default that will sometimes re-assert itself after updates.

Edited by Steven Mading
Link to post
Share on other sites

Unsure if this has been asked or answered or even if possible. I've been through the KOS documentation and if it is there I cannot find it..

What I am looking for is a way to toggle/set precision control ala CAPS LOCK, toggle/set staging locks,and last but not least press the keyboard key without physically pressing it. To specify I mean keys like O or P or something like that. Not like WSADQE..

Something along the lines of IF SHIP:STATUS <> "FLYING" { SET PRECCTRL TO OFF. }

Thank You

 

 

 

Edited by SiRCrashaLot
Link to post
Share on other sites
1 hour ago, Luovahulluus said:

Which versions of kOS, KSP and Trajectories mod play nice together?

I use the latest trajectories - downloaded manually instead of from CKAN because CKAN thinks the latest version is the second latest. 

I use kOS from CKAN, but replace the plugin dlls with versions built from source using visual studio.

These work fine.

Link to post
Share on other sites

to any one who is intrested in a kos rover driver

i have upgraded KK4TEE rover.ks

its not finist yet but it worke VERY good

i have seen my rovers going dowan a 40 deg hill on the mun and flying over craters lip and landing whit no harm

gui version
https://gist.github.com/danielboro/5edffc6071f27bf7651f443c985b8c59

terminal version
https://gist.github.com/danielboro/38ae24f97d209d8d853f78bf1fbad641

scili.ks to allow rovers to collect science on the way
https://gist.github.com/danielboro/a2cd2379afa7b9aba5def6bab7024fcd

it can auto complit missions to collect science

Link to post
Share on other sites

A programming problem:

I have a rover autopilot that has several driving modes: manual, go-to-coordinates, go-to-target, circumnavigate. It's all in one file, a loop that allows switching between different modes on the fly. It's designed to be always on the background, keeping the rover upright and safe even on manual mode.

I found a pathfinding program on Reddit, that would be a great addition to my autopilot. I'm trying to combine the two scripts. The problem is, the path finding program is actually three programs: coordinate conversion, path finding, and execution. Those are designed to run one after the other, and then end. The path finding code would be great for me without any(?) modification, but how do I use it? Is there a way to pass parameters to it and have it return the solution to my main program? Or do I have to insert the code to my current file as a function?

Link to post
Share on other sites

By@Luovahulluus
You can pass parameters into a program. In the past it was a case of RUN filename(param1, param2, etc.). I imagine you can do something similar with RUNPATH, though I've not checked the syntax. Edit: yes, this is valid e.g. RUNPATH(filename, param1, param2, etc).

The program you call needs to declare the parameters you'll be passing in.

I believe a program can RETURN, so you'd have something of the form MYVARIABLE = RUN(X,Y). Again, I've not checked that in the docs yet. If it doesn't work, you could always set-up a global in your outer program then get the inner program to alter it.

Edited by ElWanderer
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...