Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

So I'm just getting into kOS, mostly to support a shuttle program I'm in the planning phases of. I have a few scripts to automatically perform life support and other mundane tasks (this is also getting ready to support my station efforts). Anyway, I like simple, so each LS task (fuel cell, purification, etc) runs on its own CPU. Now for the meat of my post.

Is anyone interested in additional CPU models? I have one made that is radially attachable and fits inside a Universal Storage science bay. If so, I'll improve the textures a bit and throw it up on kerbal stuff.

HwebnJL.png

Edited by kujuman
Link to comment
Share on other sites

Is anyone interested in additional CPU models? I have one made that is radially attachable and fits inside a Universal Storage science bay. If so, I'll improve the textures a bit and throw it up on kerbal stuff.

I am currently working on a fresh set of kOS parts, but that does not mean those can be the only models available :)

Did you base it on any specific computer of real life part?

Link to comment
Share on other sites

I am currently working on a fresh set of kOS parts, but that does not mean those can be the only models available :)

Did you base it on any specific computer of real life part?

Yay! New parts are always good :D

I just did a search for space shuttle computer and I got this page http://www.nasa.gov/mission_pages/shuttle/flyout/flyfeature_shuttlecomputers.html I like the style of rack mounted computers with plugs for ground testing and such, so I just made it fit in the US container. Yay computers!

Link to comment
Share on other sites

i think i found my second favourite ksp mod

http://giant.gfycat.com/SafeHandyFirecrest.gif

forget space ships, just kOS+IR by themselves would make for an awsome game

Would you be so kind to maybe provide your servo script? I did some kOS programming long ago, and I really want to start fiddle with the kOS+IR and an example of the a servo scrip would help greatly.

Link to comment
Share on other sites

With the new version, might kOS be able to measure the position of a part while it's moving attached to a craft? I need some kind of an on/off switch. Think of it as the sensor on your bike with the magnet attached to the spokes of the wheel.

Link to comment
Share on other sites

With the new version, might kOS be able to measure the position of a part while it's moving attached to a craft? I need some kind of an on/off switch. Think of it as the sensor on your bike with the magnet attached to the spokes of the wheel.

Supposedly a position number was added to IR's right click panel recently at the request of us here in kOS for specifically that purpose. Make sure your IR DLL is up to date.

Link to comment
Share on other sites

To be honest, the more I try to get a meaningful vessel direction, the less I want top continue with kOs : I want to use it for the challenge of automating my vessel, not for the hassle of deciphering Kerbal internal's references... ;.;

Link to comment
Share on other sites

To be honest, the more I try to get a meaningful vessel direction, the less I want top continue with kOs : I want to use it for the challenge of automating my vessel, not for the hassle of deciphering Kerbal internal's references... ;.;

What are you trying to do with it? A lot can be accomplished in a way that actually ignores the underlying weirdly rotated reference frame by just always thinking in terms of vectors relative to other vectors rather than relative to the absolute axes of the universe. Dot products, cross products, and rotations around vectors can allow you to write math expressions that cancel out how the underlying universe's axes are rotated.

Link to comment
Share on other sites

Dot products, cross products, and rotations around vectors can allow you to write math expressions that cancel out how the underlying universe's axes are rotated.

This is exactly what is deceiving me; if you look at the navball, there is no need to do maths do get basic information. I accept to have to calculate a transfer angle to duna, not to have to calculate the pitch of my vessel.

Link to comment
Share on other sites

This is exactly what is deceiving me; if you look at the navball, there is no need to do maths do get basic information. I accept to have to calculate a transfer angle to duna, not to have to calculate the pitch of my vessel.

Pitch of which way the nose is facing:


LOCK currentPitch TO ( 90 - VANG(SHIP:UP, SHIP:FACING:VECTOR) ).

If you want the pitch of which way you are actually traveling, in case you are not headed nose-first or are tumbling, then replace SHIP:FACING:VECTOR with SHIP:VELOCITY:SURFACE or SHIP:VELOCITY:ORBIT.

And since SHIP:UP is rotating as you move around in orbit, you have to keep re-querying that, which is the same problem as you could get with any navball reading, even if it was just encapsulated in one single suffix.

Would it be better to have some direct navball-oriented data? Sure. Is it top priority? Not for me anymore at the moment, given how easy it is to derive from what is there. It used to be worse but it's gotten better - good enough to be workable. There's other deeper architectural stuff that it's more worth it for me to spend time on, because it's stuff that user scripts *cannot* work around easily in one simple subtraction of two values the system lets you query - like getting the terminal to work remotely, or adding user function calls.

Adding navball-oriented pitch and roll to a Direction is easy enough if someone wants to open up the code and add it. Just be careful not to create a name clash with the already existing (and badly named) :PITCH and :ROLL that's already there.

Edited by Steven Mading
Up yours, forum auto-smiley default settings I can't change.
Link to comment
Share on other sites

what an awsome mod!

Excellent!

hqdefault.jpg

This is exactly the direction I was hoping people would take with kOS. Combined with KerbalEDU and some plans for the future, this might become an even more powerful tool than it already is.

Link to comment
Share on other sites

Hi all,

another small request for help with this amazing mod. I'm trying to calculate where two inclined orbits cross (i.e. the ascending node relative to the target) and I'm utterly stuck. I've spent about a week mulling this over and Googling, but to no avail. Certain we've got the necessary information available in the form of ship & target obt:LAN and obt:inclination (relative to the reference plane), but I don't understand how to take these measurements and turn them into a LAN for the target's orbit relative to the ship.

I note that the incnode script on the KOS wiki (http://ksp.baldev.de/kos/mtkv3/incnode.txt) solves this using vectors - surely this isn't necessary, and we can just work it out using the reference plane?

Any pointers or reading material gratefully received!

Link to comment
Share on other sites

Hi.

I need to rebuild from scratch my whole space program, is there some sort of kos exchange site where i can look up some functioning code? so i don't spam the forum every 5 min.

Are you aware of the fantastic new documentation? There are a lot of example bits in there :) Beyond that it comes down to a lot of experimentation anyway.

Edited by Camacha
Link to comment
Share on other sites

Just what I need! One little problem, when I try the search for Infernal Robotics, nothing shows up. I'm totally fresh with kOS (programming in general, last scripting I did was in Amiga OS, 16 years ago) and I don't even know the right word for this IR part position readout, let alone searching for it.

Link to comment
Share on other sites

Just what I need! One little problem, when I try the search for Infernal Robotics, nothing shows up. I'm totally fresh with kOS (programming in general, last scripting I did was in Amiga OS, 16 years ago) and I don't even know the right word for this IR part position readout, let alone searching for it.

The code in this post might be useful. You will need to change the module to the appropriate Infernal Robotics one (DTMagnetometer to MuMechToggle) and change the |b| to whatever field you want to get from the right click menu. Do not forget to name your part and to apply the name to the code.

Should be easy breezy ;)

Link to comment
Share on other sites

Just what I need! One little problem, when I try the search for Infernal Robotics, nothing shows up.

That's because Infernal Robotics is being supported in kOS in a very generic way that tries not to play too many favorites. Instead of implementing "this is how you use Infernal Robotics parts in kOS" we implemented "this is how you access the user interface widgets and tools that any other mods can generically put onto parts". And Infernal Robotics is just one such mod you can access this way.

If you're using search terms on the docs, try "PartModule" - that's where you'll get a lot of hits about how the system works. The PartModule that IR adds to allow user interaction with their parts is called (for some reason I don't get - they made the name not me) "MuMechToggle".

Link to comment
Share on other sites

Here is the code im running:

DECLARE RANGE1.

DECLARE RANGE2.
DECLARE DELAY1.
DECLARE DELAY2.

SET LEFT1 TO SHIP:PARTSTAGGED("LEFT1")[0].
SET LEFT2 TO SHIP:PARTSTAGGED("LEFT2")[0].
SET LEFT3 TO SHIP:PARTSTAGGED("LEFT3")[0].
SET LEFTSTR1 TO SHIP:PARTSTAGGED("LEFTSTR1")[0].
SET LEFTSTR2 TO SHIP:PARTSTAGGED("LEFTSTR2")[0].

SET RIGHT1 TO SHIP:PARTSTAGGED("RIGHT1")[0].
SET RIGHT2 TO SHIP:PARTSTAGGED("RIGHT2")[0].
SET RIGHT3 TO SHIP:PARTSTAGGED("RIGHT3")[0].
SET RIGHTSTR1 TO SHIP:PARTSTAGGED("RIGHTSTR1")[0].
SET RIGHTSTR2 TO SHIP:PARTSTAGGED("RIGHTSTR2")[0].

UNTIL SHIP:ALTITUDE > 20000

{

IF GEAR = 1
UNTIL GEAR = 0

{

SET RANGE1 TO 20*SHIP:CONTROL:PILOTMAINTHROTTLE.
SET RANGE2 TO -20*SHIP:CONTROL:PILOTMAINTHROTTLE.
SET DELAY1 TO .35 - 0.045*SHIP:CONTROL:PILOTMAINTHROTTLE.
SET DELAY2 TO .15 - 0.125*SHIP:CONTROL:PILOTMAINTHROTTLE.


LEFTSTR1:GETMODULE("MUMECHTOGGLE"):SETFIELD("MIN ROTATE", RANGE2).
LEFTSTR1:GETMODULE("MUMECHTOGGLE"):SETFIELD("MAX ROTATE", RANGE1).

LEFTSTR2:GETMODULE("MUMECHTOGGLE"):SETFIELD("MIN ROTATE", RANGE2).
LEFTSTR2:GETMODULE("MUMECHTOGGLE"):SETFIELD("MAX ROTATE", RANGE1).

RIGHTSTR1:GETMODULE("MUMECHTOGGLE"):SETFIELD("MIN ROTATE", RANGE2).
RIGHTSTR1:GETMODULE("MUMECHTOGGLE"):SETFIELD("MAX ROTATE", RANGE1).

RIGHTSTR2:GETMODULE("MUMECHTOGGLE"):SETFIELD("MIN ROTATE", RANGE2).
RIGHTSTR2:GETMODULE("MUMECHTOGGLE"):SETFIELD("MAX ROTATE", RANGE1).

///////////////////////////////////////

LEFT1:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 1).
LEFT2:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 1).
LEFT3:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 1).

RIGHTSTR1:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE +", 1).
RIGHTSTR2:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE +", 1).
LEFTSTR1:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 1).
LEFTSTR2:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 1).

WAIT DELAY1.

LEFT1:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 0).
LEFT2:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 0).
LEFT3:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 0).

WAIT DELAY2.

RIGHTSTR1:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE +", 0).
RIGHTSTR2:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE +", 0).
LEFTSTR1:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 0).
LEFTSTR2:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 0).

RIGHT1:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 1).
RIGHT2:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 1).
RIGHT3:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 1).

LEFTSTR1:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE +", 1).
LEFTSTR2:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE +", 1).
RIGHTSTR1:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 1).
RIGHTSTR2:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 1).

WAIT DELAY1.

RIGHT1:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 0).
RIGHT2:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 0).
RIGHT3:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 0).

WAIT DELAY2.

LEFTSTR1:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE +", 0).
LEFTSTR2:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE +", 0).
RIGHTSTR1:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 0).
RIGHTSTR2:GETMODULE("MUMECHTOGGLE"):DOACTION("MOVE -", 0).

}.
}.

craft file. you will need infernal robotics, tweakscale, kOS and mechjeb.

https://www.dropbox.com/s/31n4keupexdr22p/WALKER-1.craft?dl=0

jLj244b.png

-set up the servo speeds as shown

-activate smart a.s.s. to lock craft direction UP

-set attitude adjustment to "use stock sas"

-select "control from here" on the probe core as shown

-make sure gear is deactivated before running the script (look for the indicator top center of screen, it should not be highlighted)

-set throttle to 0

-activate action group 0. this will recenter the leg servos. the craft will not work without this activated. deactivate to allow craft to crouch down for pilot to enter and exit the craft.

-run script

-"g" toggles leg pumping

-throttle controls speed, at 0 the craft walks in place , 1 should be top speed (although in practice this isnt the case as i have yet to tweak the timing properly)

-"j" and "l" are for turning (adjust speed of the "COURSE" group to change turning speed)

-"i" and "k" are for pointing the toes up or down. this is for going up or down hill, as well as fine tuning speed.

-":" and " ' " will shift the weight of the craft backwards and forwards. im not sure why i put this in, but it helps a little to fine tune the balance

-"h" and "n" rotate the turret

here's another little program that i made while putting this together, this gives you some useful info for doing stuff:

SET partslist to ship:PARTSTAGGED("left1").
/// tag the part you want to test, replace "left1" with the tag.

for x in partsList {
print x:GETMODULE("mumechtoggle"):allevents.
print x:GETMODULE("mumechtoggle"):allactions.
print x:GETMODULE("mumechtoggle"):allfields.
}.

Edited by Parallax
Link to comment
Share on other sites

Is it possible to do a Lock steering to ship:prograde but only have the pitch of the prograde and set the compass?

Edit: nvm, SHIP:PROGRADE:PITCH is what I was looking for.

Edit 2: Is this RO compatible? Trying to lock a heading doesn't seem to work.

Edited by Robotengineer
Link to comment
Share on other sites

Edit: nvm, SHIP:PROGRADE:PITCH is what I was looking for..

Sadly, no it isn't. The :PITCH suffix doesn't really mean "pitch". It's a badly named suffix dating back to the original mod author that we're now sort of stuck with for backward compatibility. What it *actually* does is rotate around the X axis of the universe, wherever that X axis happens to currently be pointed.

To get what you want I recommend this:


lock proPitchOrb to 90 - VANG(SHIP:VELOCITY:ORBIT,SHIP:UP:VECTOR).
lock proPitchSrf to 90 - VANG(SHIP:VELOCITY:SURFACE,SHIP:UP:VECTOR).

.

I don't know your purpose, so it's up to you which kind of prograde you want - the orbital or the surface.

Both of them work by using the up vector as the normal to the horizon, and comparing the angle between that and your movement vector.

In general, that's the solution to the problem "what is the angle between vector V and plane P" - it's (90 - (angle between V and P's normal)).

Link to comment
Share on other sites

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