Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

On Github

[h=3]"New" features[/h]

[h=3]Bug Fixes:[/h]

  • Many Doc fixes
  • Fixed bug with setting KAC Alarm action to correct value
  • Fixed some unneeded log spamming

Edited by erendrake
Link to comment
Share on other sites

This i my code:


// known state
sas on.
wait 1.
sas off.
rcs off.
set tval to 0.


set G to 3531600000000/BODY:MASS.
set a to (BODY:RADIUS + (APOAPSIS + PERIAPSIS)/2).
print a.
set da to max(0.001,maxthrust/mass).


set runmode to 31.


until runmode = 0
{
if runmode = 31// get manuver node
{
// set v1 to sqrt(G * (BODY:MASS + SHIP:MASS) * ((2/(APOAPSIS + BODY:RADIUS)) - (1/a))).
set v1 to velocityat(ship, time:seconds+eta:apoapsis):orbit:mag.
set v2 to sqrt(G * (BODY:MASS + SHIP:MASS)/(BODY:RADIUS + APOAPSIS)).
print v1.
print v2.
set deltav to v2 - v1.
set node1 to NODE(TIME:SECONDS + ETA:APOAPSIS, 0, 0, deltav).
add node1.
set burntime to node1:deltav:mag/da.
print burntime.
if nextnode = node1
{
set runmode to 32.
}
}
else if runmode = 32
{
set warp to 3.
if node1:eta < burntime + 60
{
set warp to 0.
set runmode to 33.
}
}
else if runmode = 33
{
lock steering to node1:deltav.
if node1:eta < burntime + 1
{
if node1:deltav:mag > 2*da
{
set tval to 1.
}
set runmode to 34.
}
}
else if runmode = 34
{
if (node1:deltav:mag < 2*da)
{
set tval to min(1, node1:deltav:mag / da).
}
if (node1:deltav:mag / da) < 0.1
{
wait 0.1.
set tval to 0.
remove node1.
set runmode to 0.
}
}


if (STAGE:SOLIDFUEL < 1) and (SHIP:SOLIDFUEL > 0)
{
wait 1.
}
if (STAGE:LIQUIDFUEL < 1) and (SHIP:LIQUIDFUEL > 0)
{
wait 1.
}
lock throttle to tval.
}

Manuver Node is generated in runmode 31.

The script should be capable of circularizing any orbit around kerbin.

Thanks for looking over it.

Your equation for a, the semi-major axis, is incorrect for the circular orbit you wish to achieve. You need to calculate the semi-major axis for the desired orbit, not use the semi-major axis of the current orbit if you wish to use that form of the equation. Also there is no need to include the mass of the ship in your calculation of orbital speed, it is negligible relative to the mass of the body you are orbiting.

For a circular orbit the equation for orbital velocity simplifies to:


set v1 to sqrt(BODY:MU/(APOAPSIS + BODY:RADIUS)).

Link to comment
Share on other sites

Hello, I am new to Kerbal OS. I am having troubles with steering commands. I have tried all steering commands, with the most basic rockets. But none of them work. The gimbal starts to wobble very fast as soon as the steering command triggers, but won't change the rocket direction. I have made sure that SAS is turned off, and it still won't control the rocket, but just start too freak out the gimbal while maintaining the rocket strait. All other commands, logic and loops work perfectly.

Does anyone has an idea of what I am doing wrong? Anyone has had the same problem before?

For example, this won't work :

LOCK STEERING TO R(90,80,0).

Edited by Pro7ech
Link to comment
Share on other sites

It could also have to do with the fact that KSP's logic for measuring the fuel in a stage is currently sketchy at best.

Just want to remind everyone that detecting when your engine has run out of fuel by polling the amount of fuel left is so kOS 0.15, dude. :P

Ever since we got access to right-click menus this has gotten very simple: there's a Status field for the engine. Just wait until it says "flame-out!"

Link to comment
Share on other sites

Hello, I am new to Kerbal OS. I am having troubles with steering commands. I have tried all steering commands, with the most basic rockets. But none of them work. The gimbal starts to wobble very fast as soon as the steering command triggers, but won't change the rocket direction. I have made sure that SAS is turned off, and it still won't control the rocket, but just start too freak out the gimbal while maintaining the rocket strait. All other commands, logic and loops work perfectly.

Does anyone has an idea of what I am doing wrong? Anyone has had the same problem before?

For example, this won't work :

LOCK STEERING TO R(90,80,0).

It is usually helpful for us to know what other mods you are running.

In this case I assume you are running one of the realism overhaul packs? We have a known issue that craft with little to no reaction wheels don't use enough steering deflection to be useful. If you look around there are some fairly good workarounds

Link to comment
Share on other sites

It is usually helpful for us to know what other mods you are running.

In this case I assume you are running one of the realism overhaul packs? We have a known issue that craft with little to no reaction wheels don't use enough steering deflection to be useful. If you look around there are some fairly good workarounds

Yes, my mistake. I am running the realism overhaul pack. I am aware that reaction wheels are not as powerfull than in normal mode. But shouldn't the autopilot also use the gimbal (vectored thrust) of the rocket to steer the rocket? Is there a command for it to only steer rocket with using gimbal?

I have read some stuff about it. It seems to be a common problem about vectoring range, with no solution atm but using powerfull sas or rcs.

I have also read something about using "Raw control scheme", what is it? Surface control?

Edited by Pro7ech
Link to comment
Share on other sites

Yes, my mistake. I am running the realism overhaul pack. I am aware that reaction wheels are not as powerfull than in normal mode. But shouldn't the autopilot also use the gimbal (vectored thrust) of the rocket to steer the rocket? Is there a command for it to only steer rocket with using gimbal?

I have read some stuff about it. It seems to be a common problem about vectoring range, with no solution atm but using powerfull sas or rcs.

I have also read something about using "Raw control scheme", what is it? Surface control?

Raw control means directly controlling the various steering apparatus.

Normally when you set kOS to point towards a direction the program controls all your RCS and gimbal to make sure you point your nose in that direction. But using raw commands you can tell your spacecraft to rotate in a certain direction with a certain strength. If you write your own PID controller this means you can build your own steering system that bypasses the kOS system.

Link to comment
Share on other sites

Raw control means directly controlling the various steering apparatus.

Normally when you set kOS to point towards a direction the program controls all your RCS and gimbal to make sure you point your nose in that direction. But using raw commands you can tell your spacecraft to rotate in a certain direction with a certain strength. If you write your own PID controller this means you can build your own steering system that bypasses the kOS system.

I see, thank you very much. Will need quite some work to make it reliable and safe for my kerbals haha

Link to comment
Share on other sites

I dont see in the docs anywhere about how to init arrays? or do we? and can we access the subscripts with a variable intead of a real number?



// initialize a list:
set foo to list(10,15,20,"hello",BODY:kerbin). // just to prove the lists can be heterogeneous.

// access with subscripts:
set idx to 2.
print foo[idx].

The markup syntax looks like it got a bit borked, but the examples showing it are here:

http://ksp-kos.github.io/KOS_DOC/structures/misc/list.html#constructing-a-list

Link to comment
Share on other sites

Is there a "prompt" or "input" like command in KOS yet? The most recent time I can find this question in the thread is July 2014.

Edited by SGCam
Link to comment
Share on other sites

How can I use the suffix "ControlFrom"? none of these work for me:


//The root part of my ship was Mk2 Landercan.
print ship:rootpart:controlfrom. // It show me error : "Operation is not valid due to the current state of the object."
set ship:rootpart:controlfrom to true. //Error : "Set suffix 'controlfrom' not found on Object Part(Mk2LanderCabin ~~~~~~~~~~~

print partslist[14]:controlfrom. // partslist[14] was a docking port and it prints same error as above.
set partslist[14]:controlfrom to true. // same error as above.

Obviously all other suffixes of "part" works fine. I found no changelog about it and I think the code I wrote is not that different from the example on this page...

Link to comment
Share on other sites

Is there a "prompt" or "input" like command in KOS yet? The most recent time I can find this question in the thread is July 2014.

There isn't any, though I heard it is on the to-be-done list. For now, you can use some libraries from KSLib: https://github.com/KSP-KOS/KSLib If what you really need, is a simple menu, there is a code for that there.

Link to comment
Share on other sites

I am so completely new and lost at this Add-On. Browsing through the kOS wiki and tutorials was just overwhelming. But maybe I don´t have to try reinventing the wheel. Does anyone have an existing script that detects fuel at 0% and stages? (assuming I can tag the tanks in question). Also looking for a solution to automatically fire an action group at a certain altitude (maybe even ascent/descent ?). If I see how its done, I could adapt it for my own crafts.

Many thanks if anyone could help me with that. :)

Edited by DaniDE
Link to comment
Share on other sites

I am so completely new and lost at this Add-On. Browsing through the kOS wiki and tutorials was just overwhelming. But maybe I don´t have to try reinventing the wheel. Does anyone have an existing script that detects fuel at 0% and stages? (assuming I can tag the tanks in question). Also looking for a solution to automatically fire an action group at a certain altitude (maybe even ascent/descent ?). If I see how its done, I could adapt it for my own crafts.

Many thanks if anyone could help me with that. :)

http://ksp-kos.github.io/KOS_DOC/tutorials/quickstart.html#step-5-add-staging-logic

Link to comment
Share on other sites

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