Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

here's another slightly more advanced option for staging using part modules if all you want to do is know when your engine has stopped (example code pulled from my USI Sounding Rockets launch script)


// tagged name for my first stage booster
set sre1 to ship:partstagged("sre1")[0].

// wait for the engine to flame out
until sre1:getmodule("ModuleEnginesFX"):getfield("status") = "flame-out!" {}.

// do staging stuff

Link to comment
Share on other sites

@Steven Mading, @Gaiiden

Thank you both for your answers !

I'll try Steven's things to hopefully be able to launch a rocket straight up properly :wink:

I noted Gaiiden's tweak but that's a bit advanced for my kOS level: I'll consider using it whenever I get more comfortable with kOS.

EDIT:

So the staging thing is solved (also realised I had a double "stage" instruction in the code).

But the wobbling is still present: I tried rolling the rocket in the VAB so that the red north line on the navball is right, but the only thing that changes is that the rocket rolls itself back to north-up on the navball. Pitch and yaw still wobble like crazy. Adding fins prevent it from flipping, but it doesn't solve the issue though.

On the other hand, rolling works perfectly... :)

EDIT2:

OK, it seems I can't run the program at all anymore :/

vf6lcvH.png
Edited by Gaarst
Link to comment
Share on other sites

But the wobbling is still present: I tried rolling the rocket in the VAB so that the red north line on the navball is right, but the only thing that changes is that the rocket rolls itself back to north-up on the navball. Pitch and yaw still wobble like crazy. Adding fins prevent it from flipping, but it doesn't solve the issue though.

Well, kOS's "cooked" steering modes use KSP's PID controller, which is a bit dubious. If you were to use stock SAS to try and send the same rocket upwards, I imagine it would weave just as much. You could write your own PID controller and use raw control, or use a mod that lets you tweak the stock PID controller (they exist), or ask about kOS / MechJeb integration...

Link to comment
Share on other sites

Well, kOS's "cooked" steering modes use KSP's PID controller, which is a bit dubious.

That's not really true. It uses its own steering mechanism that is just as poor as KSP's stock one, but it isn't *actually* using the same code as the stock one unless you use the SAS steeringmodes like set sasmode to "prograde"..

It actually is sharing the same code as RT's flight computer uses, although that won't be true anymore on the next release.

- - - Updated - - -

OK, it seems I can't run the program at all anymore :/

The output_log message that accompanies that screen message will have the more detailed description, more verbose than what's in the terminal screenshot. Can you post that?

Link to comment
Share on other sites

The output_log message that accompanies that screen message will have the more detailed description, more verbose than what's in the terminal screenshot. Can you post that?

output_log here, but good luck with finding anything in it, as I get spammed with the same line of codes over and over again (that's another thing... :mad:)

I'll try to find the relevant section and isolate it.

Edit: removed the spam on the output_log

Edited by Gaarst
Link to comment
Share on other sites

It looks like this bug:

https://github.com/KSP-KOS/KOS/issues/1117

Maybe.

Is there a FROM loop with a lock throttle in it? If so, try re-writing it as an UNTIL loop for the temp workaround. It's fixed in develop, but that's not released yet.

Yes there is:


print "..." + countdown.
wait 1.
if countdown = 2 {
lock throttle to 1.0.
print "Throttling up to 100% !".
}
}
lock steering to up.
stage.
when ship:maxthrust = 0 then {
print "No liquid fuel. Attempting to stage.".
stage.
print "Stage activated.".
preserve.
}
wait until ship:altitude > 70000.
print "Counting down:".from {local countdown is 10.} until countdown = 0 step {set countdown to countdown -1.} do {

I put the lock throttle command inside the countdown because i wanted the rocket to actually launch at 0 (not like in the tutorial).

Thanks for the answer, I'll just move the lock throttle outside the from and it should fix it.

Link to comment
Share on other sites

hi everyone, does anybody have a code how to predict landing location on the surface of Kerbin using kOS? I'm writing a code for an ICBM. Thanks a lot!

This would be a very hard problem to solve without very hard math (likely differential equations), because Kerbin has atmosphere. On a world without air it would be easier to predict.

Link to comment
Share on other sites

I can't seem to get the Waypoints structure working.

I've tried manually creating a waypoint using Kerbal Waypoint Manager, then doing this

PRINT WAYPOINT("wp"):Name.

I tried to list all waypoints...

LIST ALLWAYPOINTS().

LIST Name IN ALLWAYPOINTS().

LIST Name FROM WAYPOINT IN ALLWAYPOINTS().

Nothing seems to work. Any tips would be appreciated.

Link to comment
Share on other sites

I can't seem to get the Waypoints structure working.

I've tried manually creating a waypoint using Kerbal Waypoint Manager, then doing this

PRINT WAYPOINT("wp"):Name.

I tried to list all waypoints...

LIST ALLWAYPOINTS().

LIST Name IN ALLWAYPOINTS().

LIST Name FROM WAYPOINT IN ALLWAYPOINTS().

Nothing seems to work. Any tips would be appreciated.

Define "nothing seems to work". Its impossible to diagnose without being told what you're seeing when you try.

Link to comment
Share on other sites

You can't call a function in a separate script or on a separate processor. A limited workaround is to run a script on a separate core, and have it watch for some condition like a change in the nametag of a part.

Script 1 changes the nametag, script 2 sees the change and runs it's routine.

Link to comment
Share on other sites

Q1: How to change kOS's full physics range? (i.e. 2.5 km)

A1:

Q2: Online manual(http://ksp-kos.github.io/KOS_DOC/) says:

Once a vessel is more than 100,000 meters away from mission control, by default it cannot access the files on the archive.

But I succeed to cpoy files from Volume_0 to VOlume_1 when I was very far from Kerbin(when I was near Dres). What did I do wrong? and How shall I verify this rule?

A2:

Q3: There are two keywords("batch" and "deploy") in online manual. How to use these keywords?

A3:

A4: what's meaning of the math function round(a,B)?

Online manual says "Rounds to the nearest place value". Waht's the nearest place value meaning?

A4:

Link to comment
Share on other sites

You can't call a function in a separate script or on a separate processor. A limited workaround is to run a script on a separate core, and have it watch for some condition like a change in the nametag of a part.

Script 1 changes the nametag, script 2 sees the change and runs it's routine.

No no no. Absolutely false.

This works:

program1.ks


function aaaa {
return "aaaa".
}

program2.ks


run program1.
print "now calling aaaa: it returned:" + aaaa().

What you can't do is call a function from the interpreter when it was declared in a program.

This is how libraries are designed to work in kerboscript. They are programs you run which contain nothing but functions in them that are left behind for you to call later.

Edited by Steven Mading
Link to comment
Share on other sites

since the RT config option may be going away, I'm wondering how I might go about recovering log data from a local volume that I can't connect to? As in I launch a ballistic sounding rocket from KSC that's not meant to have a connection but is logging data locally, data which I would prefer be saved to a text file rather than just the console. Given that I can go out and recover the vehicle if it lands okay, I should also be able to recover this log data in text form. It would be nice if it were dumped to a text file when the vessel is unloaded from the persistence file upon recovery.

Link to comment
Share on other sites

By kOS, Can I create, compile or run a .ks file in the folder "GamePath\Ships\Script\NewFolder\"?

Thanks.

You can make a symbolic link to the folder. For example, my scripts are in C:\KSP\Script which is linked to C:\KSP\Kerbal Space Program RP-0\Ships\Script

Link to comment
Share on other sites

I have a strange and nasty bug with my RO install. If I timewarp with my execute maneuver node script running the gimballing section of any engine that has previously been activated starts to flicker. Throttling up in this state causes the game to crash with the navball disappearing, the screen turning black, and altitude and velocity displays showing NaN.

Has anyone else had symptoms like this? I inspected the log file and oddly the first error that appears is FAR complaining that something to do with its voxelisation process being NaN.

Link to comment
Share on other sites

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