Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

Download From Github

MAJOR

BREAKING: Commrange has more or less been removed from stock kOS, we realized that most of the behavior of it was copied by other mods and was invisible to users
BREAKING: Body:Velocity now returns a pair of orbit/surface velocities just like Vessel:Velocity does. (previously it returned just the orbit velocity as a single vector.)
This version does not include a module manager file, if you still have one in your folder from P1, delete it.
SHIP:APOAPSIS and SHIP:PERIAPSIS are deprecated for removal later, you can find them both under SHIP:OBT

New Features

Added the ability to get and set the current timewarp "Mode" either RAILS or PHYSICS
Added Boot files that will run when you get to the pad automatically, you select which one will run in the VAB thanks @WazWaz
Vessels and Bodies now can be used interchangeably as much as possible.
Three new prediction routines for finding state of an object at a future time:
POSITIONAT( Object, Time ).
VELOCITYAT( Object, Time ).
ORBITATAT( Object, Time ).
you can now get the FACING of all parts.
ITERATOR:END is now split into :NEXT and :ATEND

Known Issues

due to issues with the new version of RemoteTech, you will always have a connection available for use with kOS, this will be resolved before final release.

Fixes

if you have a target and attempt to set a new target and that fails, you would no longer have a target
increased power requirement of the kOS Module
Bodies are now targetable
MAXTHRUST no longer includes flamed out engines
resource floating values are now truncated to 2 significant digits to match the game UI and behavior
files saved to the local volume maintain their linebreaks
radar altimiter now returns a double
fixed an issues where setting some controls blocked the rest.
allow empty bodies on {} blocks
locks called from another lock are not correctly recognized

Prior changes from Pre-Releaes 1

BREAKING: All direction references are now relative to the controlling part, not the vessel, this will only break on vessels there these two directions are not the same.

Added a 3d Drawing tool for letting you draw lines and labels.

This is the first version but i am very excited about it.
Tour: https://www.youtube.com/watch?v=Vn6lUozVUHA
Added a new and improved file editor so the edit command actually works again in game!
Added the ability to switch to MapView and back in code
Other bug fixes

Link to comment
Share on other sites

Hooray! *scrambles to get scripts working again*

[edit]

- Found one bug with ship:controls, see #137 on github.

- several bugs related to VecDraw, see github.

- the rest of the changes seem to work as advertised although I didn't have a chance to test all of them yet.

- on the github release note you mentioned "rcs controls are not responding." but ship:control:fore/starboard/top work fine for me. What exactly did you mean?

- one change: body:distance now (correctly) returns the scalar between the center of the body and the center of mass of the ship. in 12.1. this wasn't the case (it was from the surface). I think this change isn't mentioned.

- "Added Boot files that will run when you get to the pad automatically, you select which one will run in the VAB thanks @WazWaz" - how is that supposed to happen? I don't see a selection option in the VAB, nor does the boot file seem to be loaded onto the core on launch.

[/edit]

Edited by MrOnak
Link to comment
Share on other sites

- Found one bug with ship:controls, see #137 on github.

that was a last minute change that i forgot to change in the notes

- several bugs related to VecDraw, see github.

Ill let Steven Address these

- on the github release note you mentioned "rcs controls are not responding." but ship:control:fore/starboard/top work fine for me. What exactly did you mean?

This are not the bugs you are looking for /wavehand

but seriously another change that didnt make it into the notes.

- one change: body:distance now (correctly) returns the scalar between the center of the body and the center of mass of the ship. in 12.1. this wasn't the case (it was from the surface). I think this change isn't mentioned.

added

- "Added Boot files that will run when you get to the pad automatically, you select which one will run in the VAB thanks @WazWaz" - how is that supposed to happen? I don't see a selection option in the VAB, nor does the boot file seem to be loaded onto the core on launch.

I have no idea what happened. I have to admit i havent tested this feature a whole lot. I might have broken something after WazWaz's pull request.

Link to comment
Share on other sites

I have no idea what happened. I have to admit i havent tested this feature a whole lot. I might have broken something after WazWaz's pull request.

I works here, though with a minor bug. See the development thread :)

Link to comment
Share on other sites

- "Added Boot files that will run when you get to the pad automatically, you select which one will run in the VAB thanks @WazWaz" - how is that supposed to happen? I don't see a selection option in the VAB, nor does the boot file seem to be loaded onto the core on launch.

You need to have a script starting with boot* in your Archive folder, then you can select one from the available scripts in the tweakables.

Link to comment
Share on other sites

- several bugs related to VecDraw, see github.

Neither was a bug with vecdraw. Both were bugs in the documentation. One was a bug in the user docs, another was an ambiguous and terse sentence in the release notes, thinking it promised something it didn't. Yes, vecdraw shows vectors that are not oriented to the ship's facing. That's correct. That's what the vectors actually are. The way to test whether or not they're showing you the correct thing is to draw a vector with vecdraw and then try to LOCK STEERING TO that same vector, to see if the ship orients along the arrow.

(EDIT: I have fixed the documentation error now on the VECDRAW page).

Edited by Steven Mading
Link to comment
Share on other sites

[...] does anyone have a good webpage that explains the mechanics / math behind transfer orbits?[...]

Wikipedia is a good source. That's what I used. Additionally to a crazy maths brain and passion :D

Link to comment
Share on other sites

For people who have been clamoring for a way to represent vectors in a ship-rotated way, for the purpose of stuff like docking, I have a demonstration below. I would like to implement something a bit more direct than this roundabout way, but it will work at the moment with the next prerelease update, and if you watch the video to the end you can see the hint about how to do it.

NOTE: THIS does depend on a new fixed feature just added last night - of making any and all Directions capable of returning a unit Vector version of the direction (instead of returning V(0,0,0) like many of them did before). I made the docking test as a proof of concept that the feature is working. I don't know when it will be publicly downloadable - that depends on how many other fixes will be bundled with it.

Link to comment
Share on other sites

NOTE: THIS does depend on a new fixed feature just added last night - of making any and all Directions capable of returning a unit Vector version of the direction (instead of returning V(0,0,0) like many of them did before). I made the docking test as a proof of concept that the feature is working. I don't know when it will be publicly downloadable - that depends on how many other fixes will be bundled with it.

If I am understanding you correctly this will make me very happy! :) It means I can get cracking on code without dealing with the impossible rotating reference frame, at least with what I am working on.

Edited by Camacha
Link to comment
Share on other sites

Currently, how does this work with RemoteTech?

there is a config setting to turn on RemoteTech Integration, it is in beta right now and has a few limitations.

The intent is to let you run kOS scripts that have been copied to your craft when you are in communications range and have that script continue to run even if you loose connection. These scripts would also, since they are run locally, not be subject to speed of light delay.

As for its limits. Right now calling into some parts of the RemoteTech API blows up the KSP universe and so i have turned that off. This means that kOS always believes you have a connection to the KSC. If you wanted to help us test this that would be great and before the full release of 12.2 I hope to have the interaction on by default.

Edited by erendrake
Link to comment
Share on other sites

resource floating values are now truncated to 2 significant digits to match the game UI and behavior

Ouch, this is gonna hurt.

lock throttle to (ship:intakeair * 130) works well at high altitudes, but becomes pointless if intakeair is truncated to two digits.

(Not that I'm especially in favor of the stock UI when it comes to intake air. That figure is almost useless, it's actual meaning eludes me. But having no other, I try to make the best of it. Mechjeb somehow computes reasonable-sounding and reliable numbers for "intake air available / needed" -- however they do it, I wish kOS could tap into that.)

Link to comment
Share on other sites

Ouch, this is gonna hurt.

lock throttle to (ship:intakeair * 130) works well at high altitudes, but becomes pointless if intakeair is truncated to two digits.

(Not that I'm especially in favor of the stock UI when it comes to intake air. That figure is almost useless, it's actual meaning eludes me. But having no other, I try to make the best of it. Mechjeb somehow computes reasonable-sounding and reliable numbers for "intake air available / needed" -- however they do it, I wish kOS could tap into that.)

The issue we were running into was that for some resources like LiquidFuel if there was a remainder that was smaller than two digits would show. I was not excited about truncating it this way because i was afraid of this. I'm pretty sure you can still get the full precision amount from the resource list but we should come up with a better way. there are other resources that are very small (like Interstellar's Antimatter). thank you very much for the feedback.

Link to comment
Share on other sites

Are they just the resources? Because I can see some trouble with delicate scripts as well, such as a hover script that takes input from a couple of sensors. Round one one way and the other another way and you might get fluctuations all over the place.

Especially stuff like the D-term in a PID-controller is sensitive to that kind of jitter.

Link to comment
Share on other sites

I would love to use this mod but I`m not sure how to use the scripts properly. There is a website or something where I can look already made scripts and examples for different situations? For example, to get to orbit or automatic landing or something. Please help

Link to comment
Share on other sites

I would love to use this mod but I`m not sure how to use the scripts properly. There is a website or something where I can look already made scripts and examples for different situations? For example, to get to orbit or automatic landing or something. Please help

There was the Space Computer thread, but that is older code that probably will not work in a newer version of kOS in most cases. There is a new initiative for a website with kOS scripts. Not too many scripts are on there yet, but they could provide some solid inspiration.

Though I really have to say that building your own is the most fun by far!

Edited by Camacha
Link to comment
Share on other sites

The Space computer thread is definitely the wrong approach for teaching. It's a list of already working (well, they used to work - they won't now because the mod has moved on) solutions rather than a walkthrough for how to make your own.

I'm in the middle of writing a short "getting started" tutorial intended for those who learn faster by example than by dry reference docs, that assumes you know NOTHING about kOS. It won't do anything too complex because that steals the fun from the player (this is NOT mechjeb) but it should help for things like "how do I write a 'hello world' script and run it?".

The intent is to link to it from the very top of the front page of the document website.

Link to comment
Share on other sites

The issue we were running into was that for some resources like LiquidFuel if there was a remainder that was smaller than two digits would show.

To expand on this, the problem was that in some cases KSP would consume all but the last smidgen of fuel and then never consume the last tiny fraction of a remainder. So you'd query how much liquidfuel you have left and kOS would say something like 0.000123 units of fuel, which is a number so small that KSP won't ever actually burn it. Thus a script that's checking to do something when liquidfuel = 0 would never trigger even though as far as KSP is concerned, 0.000123 units of fuel was behaving identically to having 0 fuel. I think if the amount of fuel left is so small that it won't have enough to last for a single "physics tick", KSP won't use it at all.

Link to comment
Share on other sites

Are they just the resources? Because I can see some trouble with delicate scripts as well, such as a hover script that takes input from a couple of sensors. Round one one way and the other another way and you might get fluctuations all over the place.

Especially stuff like the D-term in a PID-controller is sensitive to that kind of jitter.

This change was only for resources, in the StageValues class when you get a resource by string it sums up that resource and rounds it before returning it to the system.

To expand on this, the problem was that in some cases KSP would consume all but the last smidgen of fuel and then never consume the last tiny fraction of a remainder. So you'd query how much liquidfuel you have left and kOS would say something like 0.000123 units of fuel, which is a number so small that KSP won't ever actually burn it. Thus a script that's checking to do something when liquidfuel = 0 would never trigger even though as far as KSP is concerned, 0.000123 units of fuel was behaving identically to having 0 fuel. I think if the amount of fuel left is so small that it won't have enough to last for a single "physics tick", KSP won't use it at all.

I was apparently too eager to get to lunch to give a full explanation :P Thanks for filling in the blanks Steven.

Link to comment
Share on other sites

To expand on this, the problem was that in some cases KSP would consume all but the last smidgen of fuel and then never consume the last tiny fraction of a remainder. So you'd query how much liquidfuel you have left and kOS would say something like 0.000123 units of fuel, which is a number so small that KSP won't ever actually burn it. Thus a script that's checking to do something when liquidfuel = 0 would never trigger even though as far as KSP is concerned, 0.000123 units of fuel was behaving identically to having 0 fuel. I think if the amount of fuel left is so small that it won't have enough to last for a single "physics tick", KSP won't use it at all.

Maybe the solution is documenting this well and letting players solve it by rounding or whatever, or might that cause other problems (besides the people that do not read whatever documentation)?

The Space computer thread is definitely the wrong approach for teaching. It's a list of already working (well, they used to work - they won't now because the mod has moved on) solutions rather than a walkthrough for how to make your own.

I think it is also the wrong approach for a different reason: an advanced script written by an experience coder often looks incredibly complex. This might scare away people that would otherwise see that things are not that hard when starting with an easier script. As a teaching tool it is probably not very effective, but I think it can not do much harm either. If people intend to copy paste they would probably go for MechJeb.

Edited by Camacha
Link to comment
Share on other sites

Maybe the solution is documenting this well and letting players solve it by rounding or whatever, or might that cause other problems (besides the people that do not read whatever documentation)?

This is a bit of a strange thing because what we are really doing is fixing a bug with the underlying API. If it was up to me i would never give you guys anything other than the full precision version of everything and let you sort it out. This change was to fix something that just didnt make sense, running the engine should take the tank to 0.

Maybe it would have been better to have these numbers "snap" to 0 when they get close enough and they have full precision the rest of the time. that is something we could still change.

Reading documentation!!! HA! you are a funny one ;)

Link to comment
Share on other sites

DOWNLOAD FROM GITHUB

* BREAKING: Direction:Vector will always return a unit vector.

* Direction can now always return a proper vector.

* IE SHIP:FACING returned V(0,0,0) before

* Neutralizing the controls will clear the values of all controls.

This change also contains all of the changes from 0.12.2P1 and 0.12.2P2

Link to comment
Share on other sites

I made an attempt to address the lack of a tutorial approach for basic starting stuff, by making this page:

http://ksp-kos.github.io/KOS_DOC/summary_topics/gettingstarted/index.html

It's now linked-to near the top of the first page of the documentation site.

The intent is to let people walk through baby steps starting from nothing and making small changes one at a time. By the end of the page enough edits have been done to the little script that it's at the point where you have a crude script that launches a ship, but only up to the point of space, without circularizing or doing any of the rest of the fancy work a full launcher script would do. By the time people get to the end of the page if they understand the bits along the way they should be ready to head off on their own and start working in kOS.

Link to comment
Share on other sites

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