Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

That was my original plan. The laser distance mod has it's own problems, from what I've read.

Hmmm, too bad.

A simple proximity sensor would be awesome for mechanical stuff.

- - - Updated - - -

Do all three options actually run the same script?

Actually yes. But just for the time being. My intention is they will be different.

What I want to do is load a huge list of part lists for robotic operations, then run a second processor to watch and adjust for changes in leg positions resulting from primary code, and then a third processor to do the same for secondary leg positions. Proportional leg segment positions...

Edited by Dr_Goddard
added info
Link to comment
Share on other sites

Actually yes. But just for the time being. My intention is they will be different.

What I want to do is load a huge list of part lists for robotic operations, then run a second processor to watch and adjust for changes in leg positions resulting from primary code, and then a third processor to do the same for secondary leg positions. Proportional leg segment positions...

Ok. I tried changing the file contents for all three. No difference. Here's what happens, it might be related to persistence files.

I have three boot files (boot1.ks, boot2.ks, boot3.ks)

I try to change the boot file with the slider in VAB. There are three detents. The first says boot.ks (this is an old file name). The second says boot.ks again. Then the third says boot1.ks(whatever comes first alphanumerically).

After switching to 3(boot1.ks) the first and second detent positions both say boot1.ks.

I removed the cores, saved the game, rebooted.

Attached the cores again. Same result.

removed all but 1 core. same result.

Link to comment
Share on other sites

Feeling I haven't got anything to lose, I installed the Laser Distance Mod. Now kOS does seem to see it but I can't do anything with it, all commands are returning an error.

Anyway ... I could really use some help here. I can build engines, play the bass guitar, paint, sing, build a house, I've even built my own car ... I just can't code.

Link to comment
Share on other sites

Hello,

so I was trying to get started with this mod, but a strange thing appeared - I searched and found nothing - I can normally type into the terminal, but whenever I open a new file, I can't use several keys, for example when I press R, only RCS gets activated and nothing else happens. When I enable and disable all things in the menu on the right hand side like UCP, STAT, RT2, etc, it actually types the letter into the file, but I am still in control of the vessel, so it's basically impossible to write anything. If I need to make space, I stage. If I need to press shift for special characters, my throttle goes up. I know I could go around this by locking stages and disabling engine, but is this really supposed to happen? Thanks

(and sorry if this has already been answered, I can't seem to find anything)

Link to comment
Share on other sites

Hello,

so I was trying to get started with this mod, but a strange thing appeared - I searched and found nothing - I can normally type into the terminal, but whenever I open a new file, I can't use several keys, for example when I press R, only RCS gets activated and nothing else happens. When I enable and disable all things in the menu on the right hand side like UCP, STAT, RT2, etc, it actually types the letter into the file, but I am still in control of the vessel, so it's basically impossible to write anything. If I need to make space, I stage. If I need to press shift for special characters, my throttle goes up. I know I could go around this by locking stages and disabling engine, but is this really supposed to happen? Thanks

(and sorry if this has already been answered, I can't seem to find anything)

That is not supposed to happen. Do you use other mods, and did you try uninstalling and reinstalling again?

Link to comment
Share on other sites

I created a user defined language file for kOS scripting in Notepad++, to make my scripting easier.

DOWNLOAD v 1.0

Install instructions below.

EDIT: Updated color scheme here: v1.01

Released under GNU GPL version 3, if that's important for this. It's just an xml file, so it is its own source.

It automatically color codes things to make the script clear, as well as allowing things like folding bracketed "{ }" sections down for easier editing.

Suggestions on better formatting are appreciated. If I missed any keywords let me know.

Currently:

Flow control -- navy blue, bold, italic

Standard commands (SET, etc.) -- blue

Functions (things with parentheses after) -- black, bold

Things in quotes -- purple

LIST type things -- brown

Other recognized words (like :suffixes and 'ship') -- black

Operators ( + / and, etc.) -- blue

Numbers -- green

Anything I didn't tell it to recognize (which is hopefully just your variables) -- black with yellow highlighting.

Example:

Zqw2rE2.jpg

Install instructions:

1. In notepad++ 6.7, go to Language>Define your language.

2. Import the downloaded file.

3. ****It seems you have to restart Notepad++ at this point or it won't let you select the new format.*****

4. Go to Language>kOS Script.

Edited by Wercho
Link to comment
Share on other sites

That is not supposed to happen. Do you use other mods, and did you try uninstalling and reinstalling again?

Only mechjeb, but I don't have the mechjeb module currently on that ship.... I literally installed kOS 10 minutes ago, but I'll try reinstalling and report back soon

EDIT: Okay, removed the mechjeb too and reinstalled kOS, still same. I should probably add I use linux too

Edited by Mirean
Link to comment
Share on other sites

Feeling I haven't got anything to lose, I installed the Laser Distance Mod. Now kOS does seem to see it but I can't do anything with it, all commands are returning an error.

Anyway ... I could really use some help here. I can build engines, play the bass guitar, paint, sing, build a house, I've even built my own car ... I just can't code.

I will try and help you.

Caution though. I am extremely busy in real life.

Lets imagine you want a timing pulse. You will need some bumps on your flywheel and a laser pointed at them.

You will create a modest of one device and measure the difference between when the laser sees the bump and when it's looking at smooth wheel.

That will be easy.

Hey! you will be able to adjust the timing manually.

I respect your talents. Much like my pedigree. No guitar tho.

I'll sketch out the code this evening.

In the mean time, why not send me what you have so I can look at it?

Link to comment
Share on other sites

I had a question about this, because It was something I thought of earlier browsing this in curriosity to see if I may want to try using this in the future, But, I was wondering, is there a way to set it so if your velocity 'upwards' is above a certian m/s2 that you can have it control the throttle, so that way it maintains a constant Meters per second squared acceleration, rather then just 'full' or 'reduced' throttle?

Link to comment
Share on other sites

What I have is no code. I do have screenshots.

There have been internal combustion engines before, but they were very slow, lacked power and needed support from launch stabilizers - fixed to the launchpad.

Mine can drive around en hopefully even power airplanes. This is unique in KSP, never done before.

XPT8sRH.png

And one day we'll have this:

8If3pf4.png

Link to comment
Share on other sites

Too complicated. Why don't you use the laser distance mod to check for a nub on your flywheel? Far simpler, and true to the way ignition really works.

Laserdist is unable to be reliable at detecting hits on parts of the same vessel to which the laserdist is attached. I've wasted days and days trying every which combination to work out why and I can't find anything that fixes it at all. It has something to do with the timing of when parts are moved by the main game, and when the callbacks are called by the main game. it seems to be interleaving the movement of parts with the calls to those parts' callbacks, in a way that randomly jumbles whether all, some, or none of the parts have been moved by the time the mod tries to perform its ray cast. When I cast the ray, some of the parts are located where they belong on THIS physics frame and some are located where they belong on the NEXT physics frame, making the laser miss half the time. I've had a zillion bits of advice on moving the code to fixedUpdate, or to lateUpdate - I've tried them all. it makes NO difference. Advice on the unity forums themselves about the problem presume I'm writing an entire Unity game from scratch on my own and I am the one in charge of when the parts get moved and I can control that code, which I cannot because that's SQUAD's doing.

For the moment I've thrown up my hands and given up. I have no clue. I suspect it may be related to why sometimes I can't click on parts with the right mouse button and I have to try several times to get a hit - that UI code works by ray casting too so it may be an underlying problem I just cannot fix.

- - - Updated - - -

Hello,

so I was trying to get started with this mod, but a strange thing appeared - I searched and found nothing - I can normally type into the terminal, but whenever I open a new file, I can't use several keys, for example when I press R, only RCS gets activated and nothing else happens. When I enable and disable all things in the menu on the right hand side like UCP, STAT, RT2, etc, it actually types the letter into the file, but I am still in control of the vessel, so it's basically impossible to write anything. If I need to make space, I stage. If I need to press shift for special characters, my throttle goes up. I know I could go around this by locking stages and disabling engine, but is this really supposed to happen? Thanks

(and sorry if this has already been answered, I can't seem to find anything)

The first and obvious question is : does your terminal window look greyed out and semitransparent or is it opaque.

If it's semitransparent, then that means it doesn't have keyboard focus. If you can't make it get focus by clicking on it, then that's the root cause of the problem and where the bug really lays. Incidentally, clicking anywhere outside the window (like on the control panel to adjust the UCP, STAT, RT2, etc buttons) makes the terminal lose focus and you have to re-click the terminal to get it back.

Edited by Steven Mading
Link to comment
Share on other sites

The first and obvious question is : does your terminal window look greyed out and semitransparent or is it opaque.

If it's semitransparent, then that means it doesn't have keyboard focus. If you can't make it get focus by clicking on it, then that's the root cause of the problem and where the bug really lays. Incidentally, clicking anywhere outside the window (like on the control panel to adjust the UCP, STAT, RT2, etc buttons) makes the terminal lose focus and you have to re-click the terminal to get it back.

Yup, it's greyed out and clicking on it doesn't change it. For the moment, I'm editing the script file in gedit but that seems pretty clunky to me

Edited by Mirean
Link to comment
Share on other sites

Well ... I'd like to start with displaying crankangle value on the screen. I'll rotate the crankshaft to the right angle, read the crankangle value and then it's a simple act of

The error in your screenshot says you never set the variable PIST to anything.

When I gave the example "assume PIST is the piston part and CRANK is the crank part" I meant "this example assumes you've already set those variables to those values before you run this example code, or it won't work.".

For how to set them in the first place, I recommend looking at the name tag system as a starting point:

http://ksp-kos.github.io/KOS_DOC/general/nametag.html

- - - Updated - - -

Yup, it's greyed out and clicking on it doesn't change it. For the moment, I'm editing the script file in gedit but that seems pretty clunky to me

Is anyone else out there running on Linux and experiencing the same problem? There are a few ways that Unity, really annoyingly, chose to make the Linux implementation differ for no good reason (they're not differences due to the OS. They're differences due to Unity just *choosing* to make things different on different OS's) It makes testing a mod a nightmare at times.

Link to comment
Share on other sites

Oh god, I am stupid. The editor window was not greyed out, however, main window was. *facepalm*

anyways there is one more problem...when I type LOCK STEERING TO Up. , it just tips over and heads right into the ground. Same happens with North + R(90, 0, 0). It worked perfectly fine when I had only this in my script, but now, in more complex script, it doesn't work. I'm sure it's just my stupidity again, but just to be sure, I'm asking here.

Thanks

EDIT: When I click into the terminal, I write there, but when I click back to the editor, terminal greys out. So not completely fixed for me :/

Edited by Mirean
Link to comment
Share on other sites

Oh god, I am stupid. The editor window was not greyed out, however, main window was. *facepalm*

anyways there is one more problem...when I type LOCK STEERING TO Up. , it just tips over and heads right into the ground. Same happens with North + R(90, 0, 0). It worked perfectly fine when I had only this in my script, but now, in more complex script, it doesn't work. I'm sure it's just my stupidity again, but just to be sure, I'm asking here.

Thanks

EDIT: When I click into the terminal, I write there, but when I click back to the editor, terminal greys out. So not completely fixed for me :/

IIRC, the terminal is supposed to grey out when the editor is open, as the focus is now on the editor.

Link to comment
Share on other sites

anyways there is one more problem...when I type LOCK STEERING TO Up. , it just tips over and heads right into the ground. Same happens with North + R(90, 0, 0). It worked perfectly fine when I had only this in my script, but now, in more complex script, it doesn't work. I'm sure it's just my stupidity again, but just to be sure, I'm asking here.

Generally this is caused by the script immediately ending after that command. You have to make sure the script keeps running, for example by:

lock steering to up.
wait 5.

or

abort off.
lock steering to up.
until abort = true {}.

Link to comment
Share on other sites

my code looks like this:


print "Initiating ascent sequence in 5.".
LOCK THROTTLE TO 0.
SET now to time:seconds.
WAIT UNTIL time:seconds > now + 5.
print "Now.".
STAGE.
LOCK THROTTLE TO 1.
LOCK STEERING TO Up.
WAIT UNTIL SHIP:ALTITUDE > 500.
// more code here

and it still doesn't work..

If I run it like this, it will immediately pitch over and crash. So I enabled SAS, let it go for a while, disabled SAS and of course, it immediately pitched over again. This is screenshot from just a moment after pitching over

Edited by Mirean
Link to comment
Share on other sites

I had a question about this, because It was something I thought of earlier browsing this in curriosity to see if I may want to try using this in the future, But, I was wondering, is there a way to set it so if your velocity 'upwards' is above a certian m/s2 that you can have it control the throttle, so that way it maintains a constant Meters per second squared acceleration, rather then just 'full' or 'reduced' throttle?

The way I would do this is in an UNTIL loop, where the UNTIL loop went until a condition was met that meant you didn't want this anymore.

eg. for a launch script:

UNTIL ship:altitude > desiredAltitude {
WAIT 0.001.
IF ship:verticalspeed > vertspeedlimit {
SET ship:control:mainthrottle TO desiredAccel*ship:mass / ship:maxthrust.
} ELSE {
...set the ship throttle to whatever else you want it to be
}
}

This might have typos, but I've used similar scripts in the past.

This is the math behind the throttle equation:

F = ma, so to get a specific accel you adjust the force with the throttle

F = throttle*maxthrust

throttle*maxthrust = mass*desiredAccel

If you've got thrust limiting on the engines, you obviously need to replace maxthrust with more complicated stuff.

Link to comment
Share on other sites

If I run it like this, it will immediately pitch over and crash. So I enabled SAS, let it go for a while, disabled SAS and of course, it immediately pitched over again. This is screenshot from just a moment after pitching over

In what fashion does it pitch over? Violently or just steadily? Are you sure your probe core (or whatever you use for control) is the right side up?

Try to find out whether what kOS thinks is up matches with the actual up direction.

Link to comment
Share on other sites

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