Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

I can't find any mention of this - is anyone else having weird problems when either of the kOS parts are attached to their ships? Weird things like parts falling off on the launchpad, rockets exploding for no reason during ascent etc?

Parts falling off on the launchpad sounds like a bug I have been experiencing too. I think it is an old bug, where quicksaving a running kOS unit and reloading causes some weird things. I have been holding off on reporting it until I could reproduce it.

Link to comment
Share on other sites

There you go, true and proper fly-by-wire :) This is something I have been wanting to do for a while now, and kOS 0.15 finally gave me the tools to do it the right way. What is so special about this vehicle, you ask? It is controlled by its engines and engines alone. No SAS, no reaction wheels, no magic lock commands, no RCS - nothing. Only its four engines actively interact with the world, just like a real vehicle would have to do. The craft is not the best looking I have ever built and it is one of the more basic implementations of this technology, but I wanted to test and show what pilot inputs can do. For the same reason no mods other than kOS and FAR have been used.

What I love about this craft is that it flies like a pig without the script. You cannot control it in any useful shape or form. The script has a basic sensitivity setting which ranges from very docile to incredibly nervous and twitchy. This lends itself to some more intelligent scripts, allowing the pilot to make use of the agility of the craft when needed and giving you more control and subtlety when desired. This is all not far from how real life fly-by-wire craft are built, with inherent unfavourable or unstable properties, taming them through the smarts of a flight computer.

The next logical step would be to expand the script to easily accept any number of engines, rather than the current conveniently picked four. After that there is a whole range of possibilities, but it might be interesting to experiment with scripts that protect the craft from pilot error. This script has been tailor made for use with my Xbox 360 controller, but can be easily adapted to be used with a keyboard. To prevent the usual over-engineering of scripts I tend to get caught up in I went for a functional approach, so it is probably not the most elegant. Suggestions for improvements are welcome.

Please report any issues you may find :)

clearscreen.
print "Fly-by-wire-o-tronic 1.0".
print "Written by Camacha".
print "Status: running...".

//hitting abort ends program
abort off.

stage.

//sets analogue stick sensitivity, range 0-200
set sens to 75.

list engines in englist.
set engine_0 to englist[0].
set engine_1 to englist[1].
set engine_2 to englist[2].
set engine_3 to englist[3].

until abort=true {

//for keyboard control use alternate line instead: set maintrot to ship:control:pilotmainthrottle * 100.
//when using a keyboard, remember to set throttle to 0 before running script

set maintrot to (ship:control:pilotmainthrottle - 0.5) * 200.

set engine_0:thrustlimit to maintrot + (ship:control:pilotroll * sens).
set engine_1:thrustlimit to maintrot + (ship:control:pilotpitch * sens).
set engine_2:thrustlimit to maintrot + ((ship:control:pilotroll * -1) * sens).
set engine_3:thrustlimit to maintrot + ((ship:control:pilotpitch * -1) * sens).
}.

clearscreen.

Edit: it has become clear there is an issue with player inputs fouling up kOS outputs for the same command. It is advised to substitute your axis for different ones until (if and when) the issue has been addressed.

Edited by Camacha
Link to comment
Share on other sites

Not elegant? for what this script does it's just so nimble. I am very impressed how short your code is and the amount of control it gives the pilot.

If I would be able to to finally get script control over the rotation of the craft so I can determine what its roll angle is, I could make something similar for a normal aircraft.

Link to comment
Share on other sites

Not elegant? for what this script does it's just so nimble. I am very impressed how short your code is and the amount of control it gives the pilot.

If I would be able to to finally get script control over the rotation of the craft so I can determine what its roll angle is, I could make something similar for a normal aircraft.

It's coming. Actually, it's already there but it's undocumented because the docs are in a temporary freeze while they get moved from one markdown system to another. That looks almost ready, and once it is I'll be able to make a post about it here.

Link to comment
Share on other sites

2 questions:

Will future versions of kOS be able to detect biomes?

for the moment the only way vessels can communicate is by their names. Is there, a way to trick kOS in such, a way it reads multiple info from one name by dividing the name and using something similar to getchar ?

for example:

lets say we have a station with 4 docking ports.

all docking ports are free so the name of the station is "S0000".

when a new module arrives its kOS script reads the name, then divides it like so: S 0 0 0 0. and by that it knows it arrived at the correct place "S" and that all its docking ports are free to use.

the script decided that the second docking port is the best option for docking.

after docking the station renames itself to "S0200". (where "2" is the code of the module. witch it i can store info of the type of that module, how big it is etc...).

a different module arrives. again it divides the station name S 0 2 0 0.

the script decided that the second docking port is the best option for docking. but its taken by a "type 2" module.

with that knowledge the new module decides to dock to docking port 3.

the script also know how big the "type 2" module so he can plan a docking trajectory that will avoid collision.

after docking the station renames itself again to S0240.

i know its possible to code using whole names but that would require a HUGE list with all combinations.

im asking because i have a whole space program with ships named in a special system "[number]_[name]" and a "loader" program for every one of those vessels witch a number on the back. and many program names just have a different number at the back so im wondering if this can be done with a more efficient code than this:

if x="1_ROVERmk3"		{copy loader1.ks from 0. copy START.ks from 0. copy TRANSFER.ks from 0. run loader1.}.

Link to comment
Share on other sites

Not elegant? for what this script does it's just so nimble. I am very impressed how short your code is and the amount of control it gives the pilot.

Thanks, your words are flattering. I must admit I was pleased with how concise and effective the script turned out to be, but I did not go through a lot of trouble to make it as compact or fast as I possibly could. I normally do that, but it eats up a lot of time and slows down development considerably.

Personally I would prefer locks using instead of a loop, and maybe that the repetitive values in the script would somehow scale automatically, rather than repeating them over and over. I think both those things are not really viable at the moment because of how kOS operates, and they are really only needed because of my personal ideas of what would entail a perfect script anyway. I think I need to let that go.

Link to comment
Share on other sites

A Tutorial Video describing some features of Directions and how they work

Note: some of what this video uses is only in pre-release 0.15.4 from github right now and is NOT in the full release yet.

These are the features used in the video that are only in the pre-release at the moment, and are not in the documentation yet:

* ANGLEAXIS(degrees,axisVector) - creates a Direction that rotates degrees around axisVector

* LOOKDIRUP(lookatVector,lookupVector) - creates a Direction that points the nose at lookatVector, and points the vessel's top at lookupVector. It's equivalent to a rotation that rotates the Z axis to the nose and the Y axis to the roof (the X axis then points to the right of the YZ plane as you look down the Z axis).

* ROTATEFROMTO(vector1,vector2) - creates one of the infinite many directions that could rotate a vector from vector1 to vector2

* direction:FOREVECTOR - alias for the old :VECTOR suffix - the nose direction of the craft - If you were to apply the rotation to the universe, it's the Z axis after the universe grid was rotated to the new direction.

* direction:TOPVECTOR - the roof direction of the craft if it was to be oriented in this direction - If you were to apply the rotation to the universe, it's the Y axis after the universe grid was rotated to the new direction.

* direction:STARVECTOR - the right-wing direction of the craft if it was to be oriented in this direction - If you were to apply the rotation to the universe, it's the X axis after the universe grid was rotated to the new direction.

* direction:INVERSE - the Direction that has the opposite effect that this direction has. Often you have to use this when flipping between thinking of rotating the axes of the universe to rotating the object in the universe instead.

* multiplication of direction * direction works correctly now - dir1*dir2 starts from dir2 and rotates it by dir1 - useful for things like ANGLEAXIS, as in ANGLEAXIS(deg,vector)*SHIP:FACING to get a new direction from rotating the current facing around an axis.

I'm about to head out for Christmas to visit the folk's house for a few days so I wanted to get this out there before I left.

I decided that it would take too long to wait for the docs of these features to become public because that won't happen until the pre-release becomes a full-release, and people were having questions about this topic now.

I recorded this video about a month ago but was holding off on making it public.

Edited by Steven Mading
bbcode's list formatting didn't take - changing it to manually do it.
Link to comment
Share on other sites

If I may, why are the kOS parts only ones that can be mounted in a stack? Why not a part that can be mounted radially?

No real reason. We have wanted to add more parts but have not made the time. Its just a matter of time :)

Link to comment
Share on other sites

What is the easiest way to fire action groups?

I want to be able to toggle certain action groups on/off using commands. Is this possible?

Yes, AG1 is the command for action group 1 I believe.

See the Boolean Commands section on this page for details.

D.

Link to comment
Share on other sites

What is the easiest way to fire action groups?

I want to be able to toggle certain action groups on/off using commands. Is this possible?

It really is that easy:

ag1 on.
wait 3.
ag1 off.

You can also toggle:

ag2 off.
wait 3.
ag2 toggle.
wait 3.
ag2 toggle.

Link to comment
Share on other sites

Could it be possible to use the program to receive the key input and handle it differently? (e.g. using using WASD to move a hover vehicle and have the program control it's motion instead of the default simple rotation)

Even if this isn't possible, I just had an idea of how my hover vehicle COULD potentially work...

Link to comment
Share on other sites

Could it be possible to use the program to receive the key input and handle it differently? (e.g. using using WASD to move a hover vehicle and have the program control it's motion instead of the default simple rotation)

I am going to blatantly self promote my post on the previous page. I did exactly that using the new pilot inputs. There does seem to be an issue or complication where the original input interferes with the new output, but it is very possible to work around that - for instance by using a different axis and remapping the keyboard/controller input accordingly. Admittedly, its not ideal, but it works pretty well.

Link to comment
Share on other sites

I started with a clean version of 0.90.0 and the newest version of kOS and merged the two GameData folders but when I open the console it is still half transparent and I can't type anything, only close it. I tried moving the plugins to the plugin folder, and turned my computer on and off again. Still not working, and this happens every update with me. Any suggestions?

Link to comment
Share on other sites

No real reason. We have wanted to add more parts but have not made the time. Its just a matter of time :)

Fair enough about the time issue. It makes sense to focus on getting the virtual machine working how you want it first.

It would be awesome to have some more part options. Maybe storage space upgrading through the tech tree etc. Unfortunately, I myself currently have time, but only have my phone on which to work :/

Link to comment
Share on other sites

My code: http://hastebin.com/ubidihumid.vbs[1]

After i manually select a target it keeps printing "Please Select a Target" Any idea why?

Even if i change the line to

if target = body("Kerbin") {

it still prints "please select a target"

Looks to me like it's because you've got a not-equals (<>) instead of an equals in the if statement. I'm not sure, I'm still getting into this.

hmm, or maybe put the whole logical test inside parentheses?

Edited by Snoman314
Link to comment
Share on other sites

That's the point though, i want it to finish the loop if the target selected is not kerbin. But even if i change the line to = instead of <> just to test the rest of the script it wont execute it.

I also tried changing the else to something like elseif target=kerbin but then it didn't even print that either.

Link to comment
Share on other sites

My current problem is that I can't type into the terminal at all. It never seems to come into 'focus'. Is anyone else having this problem?

Edit: I'm getting a lot of these in the log:


[EXC 00:57:22.960] MissingFieldException: Field '.Part.uid' not found.
InternalProp.OnUpdate ()
InternalModel.OnUpdate ()
Part.InternalOnUpdate ()
Part.Update ()

Edited by Snoman314
Link to comment
Share on other sites

I started with a clean version of 0.90.0 and the newest version of kOS and merged the two GameData folders but when I open the console it is still half transparent and I can't type anything, only close it. I tried moving the plugins to the plugin folder, and turned my computer on and off again. Still not working, and this happens every update with me. Any suggestions?

Which "newest version of kOS" do you mean? The pre-release from Github or the publically official ones from curse or kerbalstuff? Currently the official ones aren't working with 0.90 yet, but there's a pre-release on github that is but has some other issues with 0.90 (mostly, not issues where it's broken, but issues where it is thematically clashing with 0.90's career restrictions and allowing you to bypass them - for example setting a maneuver node via kOS, or getting the next predicted encounter with kOS, both do not first check to see if your tracking center upgrade level supports it.)

Edit: just saw your last post show up. Yes, if you're getting complaints about part.uid then you are definitely not running the version that's compatible with 0.90. Part.uid is one of the things SQUAD changed between version 0.25 and 0.90.

Link to comment
Share on other sites

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