Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

Is it an editable file on the github (meaning people can try to edit it and those edits would reach you in the form of pull requests for you to accept or reject)?

Short answer: YES! Its one of the branches of the project on Github

https://github.com/erendrake/KOS/tree/gh-pages-source/

Longer answer: I wrote this site using a ruby framework called Middleman, you dont need to know/use ruby ( i dont know any ruby ) to do anything with it. As it's mainly there for the templating and compilation. The pages are written in markdown (eg https://github.com/erendrake/KOS/blob/gh-pages-source/source/structure/vessel.md)

Fixing up documentation is one of the places where community help can really help a lot because it's far easier to tell that the documentation has a problem if you're in the process of actually trying to learn from it than if you're the person who wrote it and already knows what it was supposed to mean.

I think the documentation being an editable github thing might be a good compromise between no user input to the documentation versus documenting by Community Wiki (Which has the problem that people can make up stuff that's wrong and not realize it's wrong because the actual author isn't involved to approve changes).

I cannot agree with you more, I welcome and encourage anyone who wants to contribute to do so, as it frees me to do more work on the next release of kOS.

Anyway, thank you for putting documentation out.

You are welcome, Proper documentation was on my list as a major blocker for new coders. I want to add some videos and examples of simple ascenders/landers/ect.

I'm going through it and I noticed that you mentioned VECTOR as one of the fields of the Direction structure. What is that? Does it return a unit vector in the direction of the Direction?

That is a strange one, it appears to only be valid for "non euler" Directions. All user defined R() are euler so this "DIRECTION:VECTOR" property are only valid for the following built-in terms.

VESSEL:FACING

VESSEL:DIRECTION

VESSEL:UP

VESSEL:NORTH

I dont know if it is terribly useful and i was thinking about taking it out because it was never advertised before and its usage will be confusing.

Link to comment
Share on other sites

Question 2 - about the List documentation:

Is there some way to obtain random access to a single element from a list at its Nth position for any arbitrary N, rather than having to iterate over it sequentially in a FOR loop to get to it? Basically, is there an index operator like:


print "The thing at index 3 is " + things[3].

or


print "The thing at index 3 is " + things:atindex(3).

or


print "The thing at index 3 is " + ListElement( things, 3 ).

If there is an operator like that, the documentation doesn't seem to mention it. (And if there isn't, it would be a really good idea to add it.)

Maybe its the thing called "ITERATOR" that does it, but if so it's not mentioned how to use it anywhere on the page.

I Added index grammar along with the list and it actually took quite a bit of work so of course I failed to include it in the docs :P

SET foo TO bar#3.

alternatively you can use a variable to index into a list


SET blarg TO 3.
SET foo TO bar#blarg.

Unfortunately, I don't have the following statement working yet.

SET bar#3 TO "foo"

the ITERATOR is a structure that was built before I added the FOR command... . I ran out of time this weekend getting that doc in.

EDIT: the FOR command WHICH I ALSO FORGOT TO ADD TO THE DOCS :P :P

Edited by erendrake
Link to comment
Share on other sites

Regarding R(X,Y,Z)....

Documentation suggest that X is pitch, Y is yaw and Z is roll)

I am noticing that currently if, for example, I use the following...

lock steering to prograde + R(90,0,0)

My ship spins and points its nose south.

something I am missing in my construction, change to code or bug?

Link to comment
Share on other sites

So I've not used github before. Is there a three-point set of instructions to edit/add to the documentation? If its harder than that I'll google how to use github and contribute that way.

It shouldn't be too bad. there are two tools you will need to learn a bit about

* git

* markdown

neither are hard :)

1. I would make a github account.

2. Download the github app for your platform (win/mac)

3. Fork https://github.com/erendrake/KOS

4. Use the github app to clone KOS and switch to the gh-pages-source branch

5. Make changes to any of the *.md files.

6. in the github app, commit and sync your changes.

7. make a pull request and ill get the changes into the documentation.

Sorry it was 7 steps, If you have any trouble with any of them i would be happy to help you out. PM me and we can chat about it :)

Link to comment
Share on other sites

Does anyone know how to detect an encounter when there are no maneuver nodes?

I am burning in a certain direction without using maneuver nodes at all. And even though i can see on the map ive made an encounter with the moon. When i use print encounter.

it returns none.

It seems print encounter only returns the encounter when the encounter in in an maneuver node.

So how can i detect when my flight path will encounter another planet or moon even if there are no maneuver nodes?

Link to comment
Share on other sites

You should be able to look at SHIP:OBT:PATCHES It contains a list of all of the orbit segments and how they end.


FOR patch in SHIP:OBT:PATCHES {
PRINT patch:BODY.
PRINT patch:TRANSITION.
}

I have tested the new patches and i have tested the FOR loop but i never tested them together, Please let me know how it goes.

Update: Crap! Looks like i have work to do on that :P sorry about that.

Update2: Looks like I flubbed on an inequality. looks like we are releasing again sooner than i thought.

Edited by erendrake
Link to comment
Share on other sites

Without Nodes it would be difficult.

With the help of nodes you could do something like this :

if ship:obt:body:name = "Kerbin"
{

set target to body("mun").

set n to node(time:seconds+300,0,0,0).
add n.

until n:orbit:apoapsis >= target:orbit:apoapsis
{

set n:prograde to n:prograde+( target:orbit:apoapsis - n:orbit:apoapsis ) / 100000.

}

set encounterCondition to false.
until encounterCondition
{

until encounter != "None"
{
set n:ETA to n:ETA+1.
}

until encounter == "None" OR encounterCondition
{
set encounterCondition to encounter:periapsis <= 100000.
set n:ETA to n:ETA+10.
}

This would create a "dummy" node 300seconds from now, altering the orbit altitude to match the mun's orbit altitude and then "seek" for an encounter.

Although very crude and inefficient, this worked in easily getting to the mun from kerbin.

I hope that soon i'll find the time to continue writing scripts that actually leave LKO ;)

Link to comment
Share on other sites

Here is a simple query... How the heck do you check to see if the engines have cut out?

I'm trying to figure out when the throttle cuts out to the coast to orbit section so I can dump things like shrouds so they fall back to Kerbin when the craft is in a suborbital path instead of staying in orbit if you eject them when you reach full orbit.

Link to comment
Share on other sites

Here is a simple query... How the heck do you check to see if the engines have cut out?

I am unsure of the new direct engine queries, but simply checking the fuel left in the stage should work. If you have fuel left because you turn them off yourself you already know when they cut out :P

Link to comment
Share on other sites

Here is a simple query... How the heck do you check to see if the engines have cut out?

As Camacha said, you could always check for fuel left in the current stage or the entire ship. (ship:liquidfuel / stage:liquidfuel). Keep in mind though, that checking for liquidfuel = 0 won't account the case, where you have 0.01 liquidfuel but no oxidizer left (happend to me once or twice).

If you have an accelerator sensor on your vessel, you should be able to use that as well. (ship:sensors:acc:mag).

Edited by kaesekuchen
Link to comment
Share on other sites

Here is a simple query... How the heck do you check to see if the engines have cut out?

I'm trying to figure out when the throttle cuts out to the coast to orbit section so I can dump things like shrouds so they fall back to Kerbin when the craft is in a suborbital path instead of staying in orbit if you eject them when you reach full orbit.

Are you managing the throttle by hand and using KOS to just manage staging? if so you should be able to watch fuel flow by calculating the change in available fuel.

In the next release you will be able to watch the throttle directly with SHIP:CONTROL:MAINTHROTTLE.

Link to comment
Share on other sites

I'm trying to make a program to handle the things that MechJeb cannot. Eventually I want to make the controls external to the game (ie hardware switches and displays) so being able to trigger sets of things like what happens in RL rockets can be done in my simulator.

Making MJ and kOS handle all eventualities can be harder than flying it all yourself. Eventually the system will be kOS, Mechjeb and Telemachus that will all work together. I do all my launches automatically and then do rendezvous and docking manually using things like the alignment guide and the Lazor docking cam.

But it was getting the shrouds to peel off before the tanks were empty (ie before the auto stage) was what was bugging me. I did figure out the fuel guestimate method but it varies. I just will have to wait until the throttle reading option in the next update I guess.

Love tinkering with the programs through... Made a really nice booboo when a loop didn't break the way I expected and I ended up staging the whole of the rocket in 3 seconds. You should have seen Jeb's face heh.

Link to comment
Share on other sites

Here is a simple query... How the heck do you check to see if the engines have cut out?

I don't know how to answer that for solid fuel boosters, but for liquid engines it's just a mater of running a loop that remembers how much total liquid fuel there was in the previous iteration of the loop, compares it to how much total liquid fuel there is now, and assumes that if the value is dropping that must mean the engines are firing. If the value is remaining constant then that means the engines aren't consuming any fuel - i.e. they've cut out.

Link to comment
Share on other sites

Actually you can't do it with SRBs because like fireworks, once you like the blue touch paper they are gonna go until they burn out (hence why you can't throttle SRB's down).

I like the idea of the fuel test loop though... gonna try that in a minute. Nice one.

Link to comment
Share on other sites

Actually you can't do it with SRBs because like fireworks, once you like the blue touch paper they are gonna go until they burn out (hence why you can't throttle SRB's down).

I know that. But your question had nothing to do with asking how to control them. You were asking how to detect that engines have cut out, which would be a valid thing to ask about solid boosters. You can't affect when they'll cut out but you might want to try to detect when it has happened. So that's why I thought it necessary to point out that I was only offering a solution for liquid fuel engines. Your question could very easily have applied to SRBs, but my answer didn't so I thought I should mention that.

I like the idea of the fuel test loop though... gonna try that in a minute. Nice one.

I also made an asparagus stage trigger that worked by remembering the RATE at which fuel is being consumed, so it could detect when some but not all the engines stopped firing. (i.e. if it used to be dropping at 90 units per sec and now it's dropping at 60 units per sec, and I haven't changed the throttle setting, that probably means 1/3 of the engines have just stopped and it's time to drop a stage.) The problem is that it's normal for there to be small fluctuations in measurements because the amount of time it takes to execute a kOS statement is not fixed, so I had to add some tolerance for normal small changes. (In principle the time to execute a kOS statement is fixed in the kOS mod's code, but in practice it's not quite 100% the same each time, probably because KSP itself has some slight fluctuation in the time it takes between calling the hooks into kOS.)

Edited by Steven Mading
Link to comment
Share on other sites

I can see how you thought that regarding my query... but I did say that I was after figuring out how to check before the fuel in the tank ran out though.

Some of the stuff I am putting together means working with multiple computer languages and with all the ones already in my head it gets a bit crowded and confusing. From KSP to SQL to Arduino to VB to PIC programming it gets frustrating at the best of times so if I came off trying to teach granny to suck eggs it wasn't intentional.

Link to comment
Share on other sites

This mod needs an actual documentation and consistency. e.g., velocity is a vector. Why doesn't it have usual vector suffixes? Which suffixes does it have? In which reference frame do rotational vectors (R()) operate? Where are surface-related prograde/retrograde vectors - are there any at all?

Terminal window input conflicts with HullCameraVDS controls (-/=/BS).

Link to comment
Share on other sites

This mod needs an actual documentation and consistency. e.g., velocity is a vector. Why doesn't it have usual vector suffixes? Which suffixes does it have? In which reference frame do rotational vectors (R()) operate? Where are surface-related prograde/retrograde vectors - are there any at all?

We have been talking about lately how to deal with the inconsistency in reference frame that the KSP API presents to us and how we want to abstract away the crazy from kOS scripters. Expect more of this in weeks to come.

Velocity is not a vector, It is a structure with a few vectors in it

http://erendrake.github.io/KOS/structure/vessel/

This is the new documentation site that we started this weekend and will keep working on :)

Terminal window input conflicts with HullCameraVDS controls (-/=/BS).

What would you like us to do about this?

Link to comment
Share on other sites

We have been talking about lately how to deal with the inconsistency in reference frame that the KSP API presents to us and how we want to abstract away the crazy from kOS scripters. Expect more of this in weeks to come.

Velocity is not a vector, It is a structure with a few vectors in it

http://erendrake.github.io/KOS/structure/vessel/

Ah, that's what got me confused. If you type `print velocity.`, you will get only the first vector as output (in form of V(double,double,double), it seems), and you won't be able to do anything with it. velocity:{orbit,surface}:{x,y,z,mag} works, thanks.

What would you like us to do about this?

Well, from some early version I remember a bug when typing in terminal would stage vessel, kill throttle, etc. You can't block hooks installed by other mods from execution? If not - sorry, didn't know that.

Link to comment
Share on other sites

Ah, that's what got me confused. If you type `print velocity.`, you will get only the first vector as output (in form of V(double,double,double).

You are correct, Honestly i have been thinking about taking it out because its fairly useless and confusing :P

Well, from some early version I remember a bug when typing in terminal would stage vessel, kill throttle, etc. You can't block hooks installed by other mods from execution? If not - sorry, didn't know that.

fully trapping keys is not something I have looked at yet and should. It does look like HullCameraVDS does allow you to move its keybindings if it is really bothering you.

if you add a ticket to the github issue tracker we can try to work on it soon :)

Link to comment
Share on other sites

I installed 0.11 to test it out, but it seems that it's not working properly for me.

I have a ship where a smaller ship equipped with fuel, thruster, and KOS computer will detach and launch upwards.

With ag1 set to decouple and activate engine, I ran this script:


toggle ag1.
lock throttle to 1.
sas off.
lock steering to up.

The ship decouples and its engine activates but the throttle and steering don't get locked to their assignments.

I switched to the ship that detached and tried entering some commands manually. It seems "stage." and "sas off." and simple toggles like those work, but locking steering or throttle has no effect.

How do I get this working?

Link to comment
Share on other sites

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