Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

Is there any way to send a command to a CPU on another ship?

Not yet. And this is only be possible within physics range

- - - Updated - - -

Just checking...but the still isn't a way to set an rt target with kOS yet is there? I looked through the last 15 or 20 pages. Not a big deal, I did manage to get it to pop up the target selection guide at least.

It requires some overhaul in RT API, so not yet.

- - - Updated - - -

Question: how can I get how fast my vessel is currently rotating? As in, if I'm out in space and the vessel is spinning on its centreline, is there a variable I can call that will tell me what my speed of rotation is?

For now only in the loop by remebering previous roll and dividing difference in roll by deltaT passed since last ibservation

Link to comment
Share on other sites

Question: how can I get how fast my vessel is currently rotating?

ship:angularvel

Gotchas:

- It's in raw universe-relative axes, not ship-relative axes

- The raw universe axes are LEFT HANDED, therefore angular velocity follows a LEFT handed rule. Most physics texts teach things with right-handed rules so this may confuse you.

- Most physics texts teach things in radians, which are mathematically nicer in a lot of ways, but kOS goes with the philosophy of trying to make everything be in degrees. There are a few exceptions that are exceptions ONLY because we didn't catch them (KSP's API is utterly undocumented, so in a lot of cases they return degrees and in other cases they return radians, and they don't tell us which is which - we have to experiment to find out. That means a few cases slip through the cracks.) IF you find angular velocity is in radians, keep in mind that is something we consider a bug and it will become degrees when we update.

Link to comment
Share on other sites

I am trying to create a script that rotates an "Infernal Robotics" part. I can get the list of action, but calling the move action does not work: http://imgur.com/JCsOQvd

Any ideas?

The error mesage is correct - there are no events Move +, you should call DOACTION(), but you should use new API for IR stuff - but the docs seem to be outdated.

Try this page: https://raw.githubusercontent.com/KSP-KOS/KOS/develop/doc/source/addons/IR.rst

Edited by Ziw
Link to comment
Share on other sites

Hmm. I have just been trying to do some steering.

Somewhat surprisingly, all the geometry stuff is mainly sweet. I kinda like coordinate systems, basis vectors for spaces and affine transformations and I are old friends

: )

My problem was it just didnt work. but I told it what i wanted it to do. :/

Being new to this... I told it lot. and often.

Too often?

I was issuing the lock command inside this loop...

// basic turn with height test case.

until ship:altitude >30000 {

MyAxisPitch (GTurnAxis,10 + (Ship:Altitude - 10000)* 50/20000). // recomputes the steer to vector

print ("FV" + steerTo:forevector ).

lock steering to getSteering(). //simply returns the steerTo direction

wait 0.5.

}

Question: is there something wrong with doing that inside an until loop?

Yeah it works with it outside (now)

Does the lock go out of scope or something and get cleaned up?

or did I botch it somewhere else, and fix it without noticing and Just think the above is the problem?

ALSO for my own edification. lock commands basically used to be poor mans function and bind things as one line call backs..?

on commands work like they go put in an event queue?

Also the gui part of setting the boot script doesnt work for me. I edit craft files to fix it. :cool:

Is that a known thing or is something broken on my system. (I think it used to work for me in 0.9)

Link to comment
Share on other sites

Something I just realised, you can actually do OOP in kerboscript:

set foo_a to list().
set foo_index to -1.

function foo_new {
parameter a.
foo_a:add(a).
set foo_index to foo_index + 1.
return foo_index.
}

function foo_geta {
parameter this.
return foo_a[this].
}

function foo_seta {
parameter this.
parameter a.
set foo_a[this] to a.
}

This is a script implementing a class foo which has a single field a and access methods for it. Of course, compared to languages actually designed for OOP it looks horrible, but the semantics are there!

EDIT: fixed stuff. Still, this is off the top of my head, without actual testing.

Edited by Garek
Link to comment
Share on other sites

Question: is there something wrong with doing that inside an until loop?

Yeah it works with it outside (now)

Can you be more precise about your example? Can you show, for example, both the version that works and the version that doesn't? (Instead of showing the one that doesn't, but then merely describing (without showing) the one that works). Also, we don' know what the functions you're calling look like.

Link to comment
Share on other sites

Can you be more precise about your example? Can you show, for example, both the version that works and the version that doesn't? (Instead of showing the one that doesn't, but then merely describing (without showing) the one that works). Also, we don' know what the functions you're calling look like.

Yeah i was hoping there was known new thing about local scope and life times of locks.

As that didnt ring bell, it is likely something a bit gnarly. (or I just FuBarred. aka SNAFU)

The in the example functions all return sensible values and stuff, as I was using vec draw to draw all the vectors and directions(forevetcor/topvector)

another possibility is I drew so much dynamically updated VECDRAW stuff, that the locks simply didnt happen?

if and when i can get it sorted into a neat/small this does X (no worky) and this Y does (worky) I will have i imagine solved my own dilemma.

Ta for trying though.

Currently, probably by programming in subset of available ways, I have got myself in a steering works paradigm.

Now i am stuck in the tradeoff of disk space versus code clarity. Ahh the memories come flooding back.

(switch to archive is my friend i shall not want. duh.)

---------------------------------------------------------

edit:

And that said i think 'switch to' produces "interesting" effects when combined with boot when also combined with quick save quick load.

On my computer, when I have set my rocket to boot_foo it gets copied onto my rockets disk as boot.

After reload, it reruns boot from the current volume. If I had switched to archive before the save it runs the boot from archive... oops?

or maybe its a feature? !

As now reboots execute a slightly different code then I can have a one universal restart program on the archive,

that can first do some kind of universal re init of rocket state. Then switch to local volume and runt he boot that is there.

example code coming when i get my act together.

Edited by Onchyophora
Link to comment
Share on other sites

given this line prior code. (will already exist in fileName)

global G_RunTasks to list().

is this line of code possible? ( the \" are C style escapes fro what i want. to happen)

log "G_RunTasks:Add(\"RunStateInit\")." to fileName .

Can I make literal string that contains a quote char. char(34).

edit : WAT? print (">""<"). produces this as output >""<

but print (">"P"<"). decides that is two strings with an unexpected P in the middle....

So I can get two "" sequential "" in string but not one?

and print "X" + """" + "X". produces XX as output.

Any chance of print (">""<"). being changed to produce this as output >"<

Edited by Onchyophora
Link to comment
Share on other sites

Hi all,

I'm having issues with LOCK STEERING TO <any-direction>.

What I see the craft does:

1. Turns to the desired vector, until it is within ~0.2 degrees.

2. Stabilizes the steering and performs a roll of several degrees.

3. Stops controlling steering at all. (yaw, pitch and roll controls are neutral).

4. Slowly drifts away from the desired direction.

That's my first experience with kOS. Could you please confirm if this is a wrong behavior of kOS?

I'm running 1.0.2 on Linux x86_64, with 30 mods installed including RemoteTech (RT is disabled in kOS settings).

kOS version 0.17.2.

kOS code I'm using:


SET SteerVect to NEXTNODE:BURNVECTOR:NORMALIZED.
LOCK STEERING to LOOKDIRUP( SteerVect, SHIP:FACING:TOPVECTOR).

NEXTNODE exists and it is a node of 1000 m/s.

Edited by orfest
Link to comment
Share on other sites

Hi all,

3. Stops controlling steering at all. (yaw, pitch and roll controls are neutral).

4. Slowly drifts away from the desired direction.

here but for the grace of god go us. I may have seen that.

Did your craft run out of power?

(mine does that when it runs out of power, although it may also on other occasions do that for code related reasons I have not got nailed down.)

(normally I dont miss stuff like did my craft run out of power, but the programming is an added distraction.)

(I am programmer IRL, so i am learning kOS while playing career, so i am writing code on parts and science challenged rockets.

I have just enough... (maybe enough panels and batteries to fly my mission, and when I FUBAR, I run out of power.

My newish rule of thumb is to periodically stop looking at the code. and play KSP again and make sure the bugs i am fixing are in the code not the rocket.

)

Link to comment
Share on other sites

Thanks for your reply.

I have ~20000 units of electiricity.

I did more tests with Physics time per frame set to 0.12sec.

COOKED controls perform not as good as I expected. Angle between SHIP:FACING:VECTOR and SteerVect stabilizes after ~15 seconds at ~2.4 degrees.

If I want "LOCK STEERING" to be more accurate than what I get out-of-the-box, can I somehow tune the COOKED controls? Edit a config file? Re-compile kos.dll with better setting?

Implementing a PID-regulator using RAW controls takes time and consumes a lot of precious disk space on the vessel.

Link to comment
Share on other sites

Hi all,

I'm having issues with LOCK STEERING TO <any-direction>.

What I see the craft does:

1. Turns to the desired vector, until it is within ~0.2 degrees.

2. Stabilizes the steering and performs a roll of several degrees.

3. Stops controlling steering at all. (yaw, pitch and roll controls are neutral).

4. Slowly drifts away from the desired direction.

That's my first experience with kOS. Could you please confirm if this is a wrong behavior of kOS?

I'm running 1.0.2 on Linux x86_64, with 30 mods installed including RemoteTech (RT is disabled in kOS settings).

kOS version 0.17.2.

kOS code I'm using:


SET SteerVect to NEXTNODE:BURNVECTOR:NORMALIZED.
LOCK STEERING to LOOKDIRUP( SteerVect, SHIP:FACING:TOPVECTOR).

NEXTNODE exists and it is a node of 1000 m/s.

Also make sure your script doesn't finish, controls are released when it does. An alternative is to turn on sas right before finishing so you won't drift.

As a side note, I remember there was a bug that made your vessel unable to be manually steerable after the script finished. Does that happen to you?

Link to comment
Share on other sites

I'm sure the script is running, because every second it prints the angle between SteerVect and SHIP:FACING:VECTOR.

I can perfectly steer it manually after the script finishes.

Link to comment
Share on other sites

I'm sure the script is running, because every second it prints the angle between SteerVect and SHIP:FACING:VECTOR.

I can perfectly steer it manually after the script finishes.

Hey I have a similar issue with a retrograde vector losing precision as the velocity decrease, like it does during the landing phase... Pretty annoying =/

Link to comment
Share on other sites

Any chance of print (">""<"). being changed to produce this as output >"<

Previously I asked about this as for, nefarious (hacky) coding reasons, I wanted to have a string with " char in its body. ALA C str = "\"";

It is really kinda hard to get one in kOS as


print (">""<"). // produces this as output >""<
print "X" + """" + "X". produces XX as output.

always even numbers of quotes.

I can has a possible solution!

tag well known rare part type with the tag name "

find the part, get the tag name, use + to build any string I want with single double quotes. Profit.

Now all I have to do is write enough scripts with out it to fly enough missions to upgrade the VAB so I can set tags and see if my evil plan works.

reminds me of the first machine code debugger I built, with basic & poke... V0 only debugged/single;stepped some instructions so I need to write the version 1,debugger

only using those machine code instructions.(no jump relative etc). Bootstrap.

signed: Jack Built Coding Enterprises.

I love kOS. I have not laughed while coding for years.

Link to comment
Share on other sites

I'm sure the script is running, because every second it prints the angle between SteerVect and SHIP:FACING:VECTOR.

I can perfectly steer it manually after the script finishes.

Do you get the same problem if you simply

lock steering to nextnode.

?

Link to comment
Share on other sites

edit (deletia: sorry barking up a wrong tree)

nvm

This bit confuses me: >>> 2. Stabilizes the steering and performs a roll of several degrees.

becuase: LOOKDIRUP( SteerVect, SHIP:FACING:TOPVECTOR).

That specifically says never ever perform a powered roll..

as lookdirup( XXX ,SHIP:FACING:TOPVECTOR). is whatever way we happen to be pointing right now.

ALSO LOL @ me. My cooked steering works much better now I leave SAS off. Way less overshoot.

Edited by Onchyophora
Link to comment
Share on other sites

Thanks for your reply.

I have ~20000 units of electiricity.

I did more tests with Physics time per frame set to 0.12sec.

COOKED controls perform not as good as I expected. Angle between SHIP:FACING:VECTOR and SteerVect stabilizes after ~15 seconds at ~2.4 degrees.

If I want "LOCK STEERING" to be more accurate than what I get out-of-the-box, can I somehow tune the COOKED controls? Edit a config file? Re-compile kos.dll with better setting?

Implementing a PID-regulator using RAW controls takes time and consumes a lot of precious disk space on the vessel.

Do you have more than one reaction wheel? I've noticed that sometimes a probe core with a reaction wheel will interfere with a SAS unit below it and cause that behaviour. switching either one off solved it for me.

Link to comment
Share on other sites

Do you get the same problem if you simply

lock steering to nextnode.

?

Yes, the same.

- - - Updated - - -

I have 1 active small inline reaction wheel and 2 disabled reaction wheels. The probe core is Probodobodyne OKTO2, which has no reaction wheels.

Now I'm trying to make kOS perform 2 maneuver nodes in a row. It executes the first one just fine, but on the second one it stops steering.

Whatever, I'm going to write a PID to steer.

- - - Updated - - -

Ok, after carefully inspecting the save file, it appeared that the FlighComputer (from RemoteTech) was set to mode KillRot.

Setting it to OFF resolved the issue of the craft not steering, now it steers just awesome :).

Link to comment
Share on other sites

So, I have a weird staging loop going on in a portion of my script, and I don't know why. It goes as follows (I cut out all irrelevant bits).

until mode = 0 { //0 will represent off

if stage:LiquidFuel < 1 {

lock throttle to 0.

wait 0.5.

stage.

print "Firing stage.".

wait 1.

set throttle to TVAL.

}

}

Sorry about the lack of spaces, mobile doesn't like spaces in front.

EDIT: found the reason: auto-staging doesn't like manual staging commands. Deleted a line in my code that manually staged, and now it works fine.

Edited by Storywalker4
Link to comment
Share on other sites

question regarding this image:

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

You can see on the right-click menu I have three science experiments - "Collect Data", "Collect Samples" and "Telemetry Report". When I query the Avionics Package for modules I get three "ModuleScienceExperiment" modules. So far so good, but when I go and try to check out the events for the 3 modules they all come back with "Collect Data". Activating them all individually with doAction() just runs the same experiment three times.

So I can only assume that the same module is being returned. How do I differentiate between modules of the same name? It mentions in the docs that modules can have the same name but I couldn't find anything on what to do about accessing different modules with the same name

ok I read the docs again and this is definitely not covered. For now I'll just call an action group with the three experiments added to it

Link to comment
Share on other sites

The variable Alt:radar doesn't seem to be working; it appears to give the same value as just Altitude; i.e., the altitude above "sea level".

Known issue?

Odd, I use it in my lander script, it works there.

I use it as:

lock radarAlt to alt:radar.

How do you call it?

Link to comment
Share on other sites

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