Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

Hmm, that explains what Im seeing. Its only the Orbital component that does this yes?

The github docs certainly indicate that Velocity:Surface is relative to the surface of the SoI body. Making Mun:Velocity:Surface the speed the moon passes over Kerbin's surface, and by extension kerbin:velocity:surface must be the speed kerbin is moving across the surface of the sun...

Returns the surface-frame velocity. Note that this is the surface velocity relative to the surface of the SOI body, not the orbiting object itself. (i.e. Mun:VELOCITY:SURFACE returns the Mun’s velocity relative to the surface of its SOI body, Kerbin).

Or is this just badly worded and all vectors come out relative to the SoI they are run in and not the SoI the body orbits in? (assuming the script is running in kerbin's SoI...which it is right now). I dont want Duna:Velocity:Orbit to be relative to Kerbin unless i specify so, thats needlessly cryptic, by my understanding of the above quoted lines Duna's SoI body is the Sun, Kerbin has jack to do with it.

edit: im going back to longitudes anyway i think. I dont want to transform everything out into the Sun's sphere, I suck horribly at vector and matrix math.

Edited by celem
Link to comment
Share on other sites

Hmm, that explains what Im seeing. Its only the Orbital component that does this yes?

The github docs certainly indicate that Velocity:Surface is relative to the surface of the SoI body. Making Mun:Velocity:Surface the speed the moon passes over Kerbin's surface, and by extension kerbin:velocity:surface must be the speed kerbin is moving across the surface of the sun...

Returns the surface-frame velocity. Note that this is the surface velocity relative to the surface of the SOI body, not the orbiting object itself. (i.e. Mun:VELOCITY:SURFACE returns the Mun’s velocity relative to the surface of its SOI body, Kerbin).

I dont want Duna:Velocity:Orbit to be relative to Kerbin unless i specify so, thats needlessly cryptic, by my understanding of the above quoted lines Duna's SoI body is the Sun, Kerbin has jack to do with it.

"The SOI BODY" refers to the SOI body where *YOU* are at the moment, not the one the remote body is in. Duna isn't hardcoded to tell you its orbital velocity relative to Kerbin. It happens to be telling it relative to Kerbin because Kerbin is where your vessel is at the moment and therefore it's the temporary center of your universe. If you escaped Kerbin and went into interplanetary oribt around the sun, then duna would start reporting its orbital velocity relative to the sun.

It's matching the weird behavior coming from Unity itself because that's how SQUAD made the universe work - the frame of reference moves with you.

In general, any time you want to change the reference frame, just subtract the desired origin out. If you want duna's velocity relative to the sun, then just say:


set duna_vel_vs_sun to duna:velocity:orbit - sun:velocity:orbit.

That will be guaranteed to give you a sun-centric velocity whether the sun is your current SOI or not.

Or to get the speed that would be indicated on the navball if it was in target mode, it's the same sort of principle - your speed relative to the frame of reference of the target:.


set target_rel_vel to ship:velocity:orbit - target:velocity:orbit.
set target_rel_speed to target_rel_vel:mag.

You are right that there is a slight confusion over surface speed as it is documented. It's NOT the velocity relative to the body's SOI - it's the orbital velocity in the reference frame of your current ship's SOI body, PLUS the offset that occurs due to the rotation of the body's SOI body's rotation. The definition in the docs works when your ship is the the same SOI as the body in question (i.e. both you and the mun are orbiting kerbin right now), but isn't exactly right when that's not true.

Link to comment
Share on other sites

Unfortunately right now there is no way to do it in kOS.

I would have used this feature to easily check if a part is a decoupler, a tank, a fairing or something else. Is there a function to create a list of decouplers or some other type of parts?

At the moment I'm using this script:


SET AllDecouplers TO LIST("radialDecoupler1-2",
"radialDecoupler",
"radialDecoupler2",
"stackSeparatorMini",
"stackSeparator",
"stackSeparatorBig",
"decoupler1-2",
"stackDecouplerMini",
"stackDecoupler").

SET MyDecouplers TO LIST().
LIST PARTS IN MyParts.

FOR x IN MyParts
{
IF AllDecouplers:CONTAINS(x:NAME)
{
MyDecouplers:ADD(x).
}
}

The best would be to have a function or a command like:


LIST DECOUPLERS IN MyDecouplers.

But in the documentation I can find this only for all parts and engines.

Edited by Carsaxy
Link to comment
Share on other sites

I would have used this feature to easily check if a part is a decoupler, a tank, a fairing or something else. Is there a function to create a list of decouplers or some other type of parts?

At the moment I'm using this script:


SET AllDecouplers TO LIST("radialDecoupler1-2",
"radialDecoupler",
"radialDecoupler2",
"stackSeparatorMini",
"stackSeparator",
"stackSeparatorBig",
"decoupler1-2",
"stackDecouplerMini",
"stackDecoupler").

SET MyDecouplers TO LIST().
LIST PARTS IN MyParts.

FOR x IN MyParts
{
IF AllDecouplers:CONTAINS(x:NAME)
{
MyDecouplers:ADD(x).
}
}

The best would be to have a function or a command like:


LIST DECOUPLERS IN MyDecouplers.

But in the documentation I can find this only for all parts and engines.

Unfortunately yours is the only solution for now. Would you mind posting your suggestion about LIST DECOUPLERS in XXX to github?

Link to comment
Share on other sites

Hmm, I've noticed a very strange bug, the symptoms are that "print somelist" only prints "LIST of X ITEMS" rather than each individual item in the list. This then screws up my autostager in very strange ways, as it relies on lists of fuel tanks/SRBs. As far as I can tell the lists are being created properly, just that somelist:REMOVE(x) randomly stops working.

I'm not sure what seems to trigger it, apart from maybe reverting to launch (which I do often). When it happens the only thing I can do is to close KSP completely and restart it, going back to the main menu and reloading a save doesn't seem to fix it. I'll try and figure out what seems to be causing it.

But anyway, here's another quick question. How can I display the same figure as orbital speed in the navball? I've tried this:

print +SHIP:VELOCITY:ORBIT but obviously it's a vector whereas I'd like to show m/s.

Link to comment
Share on other sites

Unfortunately yours is the only solution for now. Would you mind posting your suggestion about LIST DECOUPLERS in XXX to github?

I would suggest something more drastic:

'type' suffix for all parts wich return a list of types, for example the Mk1-pod will have there types: "Manned", "ReactionWheel", "Control", "TinyNode", "SmallNode" and something else. But maybe something similar can already be done using modules;

an easy way to set custom list, for example:


LOCK MyDecouplers TO LIST( x IN SHIP:PARTS IF x:TYPE:CONTAINS("Decoupler"))

;

I would suggest falso custom functions, but I'm sure (I wish) the developers are already thinking about that.

I can't find where to write these suggestions on github.

Link to comment
Share on other sites

Hmm, I've noticed a very strange bug, the symptoms are that "print somelist" only prints "LIST of X ITEMS" rather than each individual item in the list. This then screws up my autostager in very strange ways, as it relies on lists of fuel tanks/SRBs. As far as I can tell the lists are being created properly, just that somelist:REMOVE(x) randomly stops working.

I don't see any connection between the problem of lists being printed tersely and the problem of REMOVE not working right. I don't get the description of the problem.

Lists being printed tersely is a sort of problem. I'm not sure what the proper solution should be. I don't think it's right to always spew a wall of text at you whether you wanted it or not, so there would have to be some sort of optional way - effectively two different kinds of ToString() - one verbose and one terse.

I'm not sure what seems to trigger it, apart from maybe reverting to launch (which I do often). When it happens the only thing I can do is to close KSP completely and restart it, going back to the main menu and reloading a save doesn't seem to fix it. I'll try and figure out what seems to be causing it.

But anyway, here's another quick question. How can I display the same figure as orbital speed in the navball? I've tried this:

print +SHIP:VELOCITY:ORBIT but obviously it's a vector whereas I'd like to show m/s.

All vectors have a :MAG suffix that returns their magnitude as a singleton scalar.

SHIP : VELOCITY : ORBIT : MAG.

Link to comment
Share on other sites

Here's a couple of screenshots to show what I mean:

This is what the output of "print tanklist" looks like when the bug hasn't been triggered, you can see it lists each item in the list, just by issuing "print tanklist"

http://i.imgur.com/FvIgSD1.png

Now this screenshot is after the bug has been triggered, you can see that it no longer lists each individual items via "print tanklist" and I have to setup a for loop to print them.

http://i.imgur.com/tGvsOQr.png

Link to comment
Share on other sites

Is there a way I can get rid of everything on the terminal?

As I am just learning,I mess up a lot and end up not being sure where I am in my code.

How can I clear everything and start my code again?

(P.S. due to being a stubborn ass I am on 0.25.)

Clearscreen.

Link to comment
Share on other sites

I have script that does this

<code>

// M1s are engines (monoprop ones FYI)

print M1s[0]:ThrustLimit. // prints current manually set thrust limit eg 35

print M1s[1]:ThrustLimit. // prints current manually set thrust limit eg 54

set M1s[0]:ThrustLimit to 0.5.

set M1s[1]:ThrustLimit to 22.

print M1s[0]:ThrustLimit. // prints '0.5'

print M1s[1]:ThrustLimit + "<<<WHAT!!!!". // prints '1<<<WHAT!!!!'

</code>

Seemingly the ThrustLimit is being range checked into the {0 <= T <= 1} range....:( (I need more thrust than 0-1%)

Is there a work around or did I do something wrong or bug?

edit:

appears to be a reported bug. Is there a work around?

http://www.reddit.com/r/Kos/comments/2udqcn/possible_bug_in_setting_thrust_limiters/

will trying setfield and getfield? as my self help.

update for those that google this:

<code>

//brick bat coding solution that works. set thrust limiter of second engine tagged "M1" to 44.5

set M1s to SHIP: PARTSDUBBED("M1").

set EF1 to M1s[1]:GetModule("ModuleEngines").

EF1:setField("thrust Limiter", 44.47). // possibly rounds this to 44.5 internally (or maybe but unlikely IMO for display).

</code>

Edited by Onchyophora
clunky workaround found
Link to comment
Share on other sites

appears to be a reported bug. Is there a work around?

Hmm. It was reported on reddit, but the relevant info (that the range 0..1 gets interpreted as 1% not 100%) never made it to github where the issues get tracked, so it got lost.

I'll go update the issue.

EDIT: UPDATE: As far as I can tell, the problem was was already fixed a while back, according to this:

https://github.com/KSP-KOS/KOS/pull/559#discussion-diff-24644269

Are you on an old version?

Edited by Steven Mading
Link to comment
Share on other sites

I may be really stupid and I don't quite understand the documentation completely, how do I add an activate antenna (RT2) command in my script? A communutron 16. I fiddled with DOaction but I cannot get it to work. I want something simple that detects that specific antenna without me naming it.

Link to comment
Share on other sites

Okay! While I'm asking silly questions, is there a way that I can type in all my code and then activate it with a command?

I have some code to put a ship in orbit and I never get it typed in in time using a wait command, or I mess up because I'm rushing, and It's either that or wait a really long time.

Can I just type in a command at the beginning, and then when I'm ready activate the code?

Link to comment
Share on other sites

I'm having problems getting the amount of fuel in a tank. the tank has the right tag and the program is selecting the right part but stops there. I'm using the command "PRINT SHIP:PARTSTAGGED("TEST")[0]:RESOURCE:AMOUNT." What is wrong?

Thanks

edit: how do I remove the emoticon?

Edited by oliverjrose99
Link to comment
Share on other sites

Hi, quick question. I added kOS module to probes and command module parts with config like this:

@PART

[*]:HAS[@MODULE[ModuleCommand]]

{

MODULE

{

name = kOSProcessor

diskSpace = 2500

}

RESOURCE

{

name = ElectricCharge

amount = 5

maxAmount = 5

}

}

But I can't get more than 500 disk space, how can I add more?

Link to comment
Share on other sites

I'm having problems getting the amount of fuel in a tank. the tank has the right tag and the program is selecting the right part but stops there. I'm using the command "PRINT SHIP:PARTSTAGGED("TEST")[0]:RESOURCE:AMOUNT." What is wrong?

Thanks

edit: how do I remove the emoticon?

What is the error? Shouldn't you specify which resource are you looking for?

Link to comment
Share on other sites

I can't get more than 500 disk space, how can I add more?

I believe this is by design, you are supposed to copy scripts from volume 0 (ships/scripts/ AKA the archive) into volume 1 (the ships disk). Or you can just run everything from volume 0:

SWITCH TO 0.

Link to comment
Share on other sites

The docs do say this:

Once a vessel is more than 100,000 meters away from mission control, by default it cannot access the files on the archive. Commands such as SWITCH TO , and COPY FROM will fail to work when trying to access the archive volume while out of range. This can be changed by putting antennae on the vessel. With enough antennae it becomes possible to reach the archive drive from farther away. Using this method it is possible to alter the software stored on a vessel after launch.

I'm not sure if it still applies as I've never run into it.

Link to comment
Share on other sites

edit: how do I remove the emoticon?

You have to click the "go advanced" button when editing, and there will be an option to disable smileys. Franky, I think that's utterly backward. Actually showing the text you *really did* type is what I'd call basic vanilla mode and invoking the option to do something fancy with it is what' I'd call "advanced". Not the other way around.

Link to comment
Share on other sites

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