Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

13 hours ago, ILikeIke said:

To be totally honest, this is my first time programming anything like this in kOS (previously I've only done launch scripts, and that was in pre-1.0), so I honestly can't justify my decisions in terms of what I thought was best practices. For starters, I have no clue how to use vectors to rotate the ship, though I plan on trying to learn. What's the difference between a vector and a rotation?

i didn't know that I needed a loop for an if statement. I tried using the "preserve." command, but got an error about using it outside a loop, which I didn't understand at all.

i thought I was using cooked steering as much as I was able to, because I was under the impression that I couldn't use cooked steering to aim for retrograde. How would pure cooked steering look for this?

When I say pure cooked steering, I mean leaving SAS off and letting kOS's steering manager handle the controls instead of KSP.  You can use cooked steering to point at anything you can quantify.  In fact, you can lock the steering to either a vector, or a direction (the steering manager will automatically translate a vector into a rotation).  Use the vector drawing feature to help you visualize the vectors you want to steer to.  In your specific case, a simple command of `lock steering to srfretrograde.` or `lock steering to retrograde.`will work.

Regarding the programming, I recommend reading up on the recommended programming patterns here: http://ksp-kos.github.io/KOS_DOC/tutorials/designpatterns.html#sequential-programs since it explains some of the dynamics of loops.  I always try to write a program sequentially first, then as a loop, and then I look to add triggers if they will help.  But avoid using triggers (when/then or on) until you understand the flow of your program (because they are more complicated than they appear).

The deal with the required "loop" is that when a program exits back to the terminal, it will release controls.  If you type it in at the terminal directly, these things will persist until you cancel them or reboot, but we have to release the controls and stop checking triggers when a program ends to prevent very unexpected behaviors (imagine every when block you ever add being evaluated forever).  It can honestly be as simple as `wait until false.` though I would suggest you make the condition detectable (like `wait until abort. abort off.` that way you can use an action group to end the loop). 

Edited by hvacengi
Link to comment
Share on other sites

The objective is to launch an ISS into Polar orbit, then automatically construct a big space station without any green people

After much fidgeting of parameters to the basic launch system... nirvana is achieved, with no changes to original launch algorithm.

A target inclination of 90 (Polar) set, and orf it goes..

This pic depicts a few minutes after second stage separation ( as it follows a lower.faster orbit ) plus as 1 second boost to separate payload from 2nd stage.

The KOS CPU has guided the craft to a 89.998 degree polar course... not bad for this launch.. but it's not consistent, and can vary wildly.

What's important is that it can keep the error within  0.01 degrees which is easily correctable with RCS, enabling docking procedures.

dUJOApC.jpg

Edited by ColKlonk
Link to comment
Share on other sites

On 2016-03-23 at 10:37 PM, ColKlonk said:

The objective is to launch an ISS into Polar orbit, then automatically construct a big space station without any green people

After much fidgeting of parameters to the basic launch system... nirvana is achieved, with no changes to original launch algorithm.

A target inclination of 90 (Polar) set, and orf it goes..

This pic depicts a few minutes after second stage separation ( as it follows a lower.faster orbit ) plus as 1 second boost to separate payload from 2nd stage.

The KOS CPU has guided the craft to a 89.998 degree polar course... not bad for this launch.. but it's not consistent, and can vary wildly.

What's important is that it can keep the error within  0.01 degrees which is easily correctable with RCS, enabling docking procedures.

 

 

Very impressive! I am also working on trying to automate my space station building a resupplying, would you be able to share your code for inspiration? 

Link to comment
Share on other sites

59 minutes ago, axelaxel said:

 

Very impressive! I am also working on trying to automate my space station building a resupplying, would you be able to share your code for inspiration? 

No problem - It'll be all up for grabs when done. 

I'm just having a problem switching some motors off via Active Groups, I'm not sure whether it's KOS or AGX but am trying different ship configs as it's messing up my control system. The biggest problem is working out how KOS and KSP interact - takes time and documentation is mostly vague at best.. and shyte the same engine hasn't switched off again (running tests while browsing/typing ) It's not the code as I switch it off 3x to prove a point to myself here - I'll set it to another AGX number.

Anyway this is what I'm getting... the Inclination lock is mostly less than 0.003 and the LAN lock is coming on nicely.

Inclination lock should be true.. but as said... working out what KOS is up to !!

Once both LAN and INC lock are achieved then the race for rendezvous starts as the ship climbs to target altitude.

0CWuhGt.jpg

edt:

Ignore my stupidity.. I'm such a dickhead.. found the problem... 

The code needs cleaning up and what  I'll do is post the stages, as the whole sequence is in 4 stages..

Circular orbit, LAN/INC locks, Rendezvous, Final approach and dock.

Edited by ColKlonk
Link to comment
Share on other sites

8 hours ago, axelaxel said:

Very impressive! I am also working on trying to automate my space station building a resupplying, would you be able to share your code for inspiration? 

On 3/23/2016 at 5:37 PM, ColKlonk said:

The objective is to launch an ISS into Polar orbit, then automatically construct a big space station without any green people

You should both be very pleased then because I'm planning on making it so that kOS is able to launch new ships from scripts using the craft file name.  The intention is to enable completely autonomous station building and re supply runs.  We're also looking into a "mainframe" terminal that runs at the KSC and would allow a master script to monitor ships and perform actions as necessary.

Link to comment
Share on other sites

6 hours ago, hvacengi said:

You should both be very pleased then because I'm planning on making it so that kOS is able to launch new ships from scripts using the craft file name.  The intention is to enable completely autonomous station building and re supply runs.  We're also looking into a "mainframe" terminal that runs at the KSC and would allow a master script to monitor ships and perform actions as necessary.

 

14 hours ago, ColKlonk said:

No problem - It'll be all up for grabs when done. 

 

Sounds great! Looking forward to learning a lot from both.

Link to comment
Share on other sites

7 hours ago, hvacengi said:

You should both be very pleased then because I'm planning on making it so that kOS is able to launch new ships from scripts using the craft file name.  The intention is to enable completely autonomous station building and re supply runs.  We're also looking into a "mainframe" terminal that runs at the KSC and would allow a master script to monitor ships and perform actions as necessary.

Very nooice

Also to give it a 'real' feel is to have a TV monitor that relays on-board camera pictures - working together with remote tech.

 

Link to comment
Share on other sites

What is the backward-compatibility policy of this mod?

I've discovered that SHIP:STATUS no longer says "PRELAUNCH" (it says "LANDED") when on the launchpad. From testing I've narrowed it down to an API change made in 1.0.5, and the related changes made in kOS v0.18.2 (or thereabouts).

I still use 1.0.4 due to bugs in 1.0.5, so I was wondering if it can/would be fixed? Or not worth it?

If not, you might want to update the version checker stuff so it warns if you're using an incompatible version.

 

Edited by surge
minor grammar
Link to comment
Share on other sites

Here's 'Phase-1'.. (of 4 )

It's not perfect... but consistently gives the same results plus/minus small errors (ahh life... )

A slight number problem here and there.. but this is a cosmetic problem and doesn't effect final results.

Video: https://youtu.be/o2mY9KYmtRo

DropBox version (better resolution) https://www.dropbox.com/s/5j69bj46h42x0nt/Phase-1.mp4?dl=0

Code: https://www.dropbox.com/s/7um2z0urrj0fsg2/Cols_KosMod_P1.zip?dl=0

The basic functionality of this phase:

- Find target (if exists - or use defaults) parameters and calculate Launch Time, Launch Angle/Course. Wait for launch time.

- Stage-1 takes the rocket to approx 110 Km altitude, controls Roll Maneuver, Pitch Angle, SRB separation , Fairing Separation.

Most actions are done via Action Groups which are grouped into sections (number ranges) that are unique to a particular stage.

This enables modular construction (as well as programming) without having to re-invent new AG or Module groups.

- Stage-2 places the rocket about 20m/s short of orbit Delta-V at an altitude of approx 200 Km.

This is the stage that controls the Target Inclination Lock, and both LAN and INC lock are brought within RCS correction range.

 

Cooked controls are used throughout as it's easier, and would like to get the automated docking done first before venturing into PID loops.

I have made a numerical PID loop but needs more work to 'keep it calm'... this will be applied later - but there is always the problem with KOS's instruction rate wrt KSP. Will it be enough for effective control in the launch stages ?

The next phase will be posted when done . . might take a while as busy with RL

 

 

Edited by ColKlonk
Link to comment
Share on other sites

Down to testing the LAN and INC Locking mechanism... it's on the right track, but the thrusters are a bit weak - I'll have to add more 'power'.

Approaching South Pole

0E3s1Dz.jpg

Note LAN and INC

qmtVdMQ.jpg

Correct 'engines' firing to correct LAN in this case

NBPsouV.jpg

LAN has changed.. too little so we need to put more thrusters on board

5S9Fdva.jpg

 

Edited by ColKlonk
Link to comment
Share on other sites

On 3/28/2016 at 10:28 PM, surge said:

What is the backward-compatibility policy of this mod?

I've discovered that SHIP:STATUS no longer says "PRELAUNCH" (it says "LANDED") when on the launchpad. From testing I've narrowed it down to an API change made in 1.0.5, and the related changes made in kOS v0.18.2 (or thereabouts).

I still use 1.0.4 due to bugs in 1.0.5, so I was wondering if it can/would be fixed? Or not worth it?

If not, you might want to update the version checker stuff so it warns if you're using an incompatible version.

 

Unfortunately our general backwards compatibility message has to be that we simply don't offer support for previous versions of KSP, nor for previous versions of kOS.  This is an unfortunate oversight on our part with regard to the version checker details, as I did have it fixed at one point.  We will be releasing an additional version before we switch to KSP 1.1 compatibility and I'll see if I can get the version checker stuff fixed at that point.  (There are some complications with trying to replace information on already released versions, but I'll see if it can be helped).

Regarding your specific problem, I can't really figure out why the launch status broke.  The underlying type used by KSP added an integer equivalent for the underlying enum, but otherwise the definition is the same.  For that reason all of the boot scripts failed to load until we updated the reference.  v0.18.2 is definitely the release where we updated to KSPv1.0.5 compatibility, so you'll need to use a version prior to that.

Link to comment
Share on other sites

On 3/28/2016 at 5:31 AM, ColKlonk said:

Cooked controls are used throughout as it's easier, and would like to get the automated docking done first before venturing into PID loops.

I have made a numerical PID loop but needs more work to 'keep it calm'... this will be applied later - but there is always the problem with KOS's instruction rate wrt KSP. Will it be enough for effective control in the launch stages ?

The next phase will be posted when done . . might take a while as busy with RL

As the person who implemented much of the cooked steering, I don't think there's any shame in using it instead of your own PID ;-)

If you do try to do a PID solution (I highly recommend that any docking script you have uses PID anyways) you should consider using our PIDLoop structure.  It's better if you learn the basics of PID through your own system, but our structure will be substantially better for performance.  It took my docking script from 1970ish instructions per update to 190ish, not to mention the actual execution improvements by not running through the translated opcodes.  My loop may not have been highly optimized at the time, but I can tell you that the structure is pretty fast.

I have a script that does some very similar things to what you a shooting for.  If I find some time I may see if I can provide any help.  (All bets are off if KSPv1.1 drops this week, cause that will have to consume my non-working time).

Link to comment
Share on other sites

Please-Please! Looking forward to new release, compatibly with 1.1! I love your mod, thank you very much for it exist, and in active development.

And, feature request: does it possible to not drop program, in new kos version, if we switching to space center?

Link to comment
Share on other sites

Can't believe how well this works.. it's too good to be true !!

At north pole on start of first maneuver..

UZ3kzgH.jpg

 

Again north pole on final maneuver... Took one orbit to align - this depends on how far off you are at the start.

wgxN8Vw.jpg

Program ends at this point.

ZOtOtIZ.jpg

 

At this point the ship would be directly under the target plus/minus a maximum of 500m at rendezvous.

From here the Rendezvous phase would start - have the method already, just need to type it in

Will post this phase code once cleaned up.

 

PHASE 1+2 CODE:- https://www.dropbox.com/s/52zlh771s3e6jn0/Cols_KosMod_P2.zip?dl=0

Video LAN/INC locks :- https://www.dropbox.com/s/vbap5mpfrskp5uo/Phase-2.mp4?dl=0

Video fast forward sections.. from end of Stage-3 to final lock at 3/4 of an orbit.

Edited by ColKlonk
Link to comment
Share on other sites

28 minutes ago, Horman said:

Is it possible to save scripts for kOS in Clouds like google drive or the apple cloud?

 

I'm not a Apple user, I'm Linux user, but OS X is *nix system, and here this way probably works:

1) copy content of ${gamefolder}/Ships/Scripts in Apple cloud dir, for example:

/Users/${YourUserName}/Library/Mobile\ Documents/com\~apple\~CloudDocs/Documents/

2) create a symbol link to this doc, from your steam KSP folder, in my Linux system:

ln -s /home/***/.local/share/Steam/SteamApps/common/Kerbal\ Space\ Program/ /Users/${YourUserName}/Library/Mobile\ Documents/com\~apple\~CloudDocs/Documents/kOs

In your system path must be different. You can check path in Steam client (view local content button).

Please be  careful, and don't delete your files by mistake. Test it on new/test directories!

Edited by Polnoch
Link to comment
Share on other sites

Hello,

I need a bit of help with the steering manager. I have a little probe, controlled by a set of RCS thrusters on one end of it.

When it reaches a target attitude it keeps firing the thrusters to stay there. Its only small adjustments but it wastes a lot of fuel. How can I make it stop that? Is there a way to tell it to only correct if its off by a certain margin or a more elegant solution?

Also it would be great if it would only fire its thrusters once to get to the target attitude, coast  and then slow down again. Does cooked steering enable that or do I have to write a program for that myself?
Thank you!
PS: How do I insert images into the post?

Link to comment
Share on other sites

On 3/31/2016 at 6:25 AM, Warp11 said:

I need a bit of help with the steering manager. I have a little probe, controlled by a set of RCS thrusters on one end of it.

When it reaches a target attitude it keeps firing the thrusters to stay there. Its only small adjustments but it wastes a lot of fuel. How can I make it stop that? Is there a way to tell it to only correct if its off by a certain margin or a more elegant solution?

Also it would be great if it would only fire its thrusters once to get to the target attitude, coast  and then slow down again. Does cooked steering enable that or do I have to write a program for that myself?

You have two options to reduce RCS usage: turn off RCS and only use reaction wheels to adjust steering, or tune the steering manager to reduce the magnitude of oscillations.  See this page for information on tuning: http://ksp-kos.github.io/KOS_DOC/commands/flight/cooked.html#cooked-tuning

If you want to use the RCS for translation or speed control you'll need to do it using the raw steering code (i.e. `ship:control:fore`):  http://ksp-kos.github.io/KOS_DOC/commands/flight/raw.html

21 hours ago, jediminer543 said:

Anyone know the status of 1.1?

We are working on updates to be compatible with 1.1.  You should check the github page fore details on progress.  There are 1.1 specific issues identified there.  You can also download and compile the 1.1 testing branch if you desire.

We will be making one final KSPv1.0.5 compatible release (very shortly) and then we will begin making development builds available on the github page.  It won't be available on ckan, spacedock, or curse.  We will not be making a full release until after KSPv1.1 is officially released (no longer in pre-release).  That's just a function of the fact that Squad is continuing to update KSP during the pre-release period, and we will need to continue to test with each version.  When the first development build is available I will post here to alert those of you testing with v1.1.  It will be important to remember that just like the v1.1 pre-release is being used to test for bugs, our development builds will also be for identifying and fixing bugs.

Link to comment
Share on other sites

Quick question- is it possible, using a single copy of KSP with port forwarding set up, to run both a kOS Telnet Server and provide data for other devices using Telemachus?

Link to comment
Share on other sites

I've been trying today to log data I can use to vecdraw() a path to show where a rover traveled along the ground or how a rocket ascended to space. I never used vectors before in kOS and my understanding of vectors from a purely mathematical view is pretty limited as well, so I'm basically just stumbling around trying things. Anyways, here is my proof of concept:

KJfAZ6im.png

this was created with manual console commands:

vecdraw(v(0,0,0), v(-15,0,10), rgb(0,1,0), "", 1.0, true, 0.2).
vecdraw(v(0,0,0) + v(-15,0,10), v(-20,0,10), rgb(0,1,0), "", 1.0, true, 0.2).
vecdraw(v(0,0,0) + v(-15,0,10) + v(-20,0,10), v(-25,0,10), rgb(0,1,0), "", 1.0, true, 0.2).
vecdraw(v(0,0,0) + v(-15,0,10) + v(-20,0,10) + v(-25,0,10), v(-30,0,10), rgb(0,1,0), "", 1.0, true, 0.2).

Now I'm just trying to figure out what I need to log to get this information to apply. I tried ship:geoposition:position and stored them in a list as I ascended to 75km apoapsis and did this:

set currVec to vecList[0].
from { local index is 1. } until index = vecList:length step { set index to index + 1. } do {
  vecdraw(currVec, -vecList[index], rgb(0,1,0), "", 1.0, true, 20).
  set currVec to currVec - vecList[index].
}.

but that gave me this:

SlqQKmBm.png

so I made a much shallower arc that topped out at 15km and crashed back into the ocean and then modified the code to this:

from { local index is 1. } until index = vecList:length step { set index to index + 1. } do {
  vecdraw(vecList[0], -vecList[index], rgb(0,1,0), "", 1.0, true, 10).
}.

and that gave me this:

m85PVCWm.png

So the arc is definitely there but way too high and doesn't travel over the ground. I was expecting to see something like this

QFGciNnm.png

So I don't really even understand why the output looks the way it does. Completely lost right now. Anyone able to help me get back on track? Many thanks

Link to comment
Share on other sites

8 hours ago, Gaiiden said:

 


 

 

 

 

So I don't really even understand why the output looks the way it does. Completely lost right now. Anyone able to help me get back on track? Many thanks

Your code snippets don't show how you built the vecList in the first place, making it hard to verify if what you're seeing in the vecdraws is wrong or if the vecdraws are correctly reflecting wrong values in the vecList.

Link to comment
Share on other sites

13 hours ago, EmigrantD said:

kOS popular in many countries! Also in Eastern Europe.

Please add kOS support Unicode, so we can display Cyrillic in the terminal.

Do it please!
 
 

Currently it does the gui terminal's font by drawing texture patterns from this bitmap image file: 

https://github.com/KSP-KOS/KOS/blob/develop/Resources/GameData/kOS/GFX/font_sml.pnghttps://github.com/KSP-KOS/KOS/blob/develop/Resources/GameData/kOS/GFX/font_sml.png

We have to draw out all the pictures of the characters.  So supporting all of Unicode that way would be an enormous task.

One thing that KSP 1.1 may allow us to do is drop this technique entirely and instead actually use a truetype font file.  In Unity4 it was problematic but in Unity5 it might work.  (There's been some changes to Unity's rules about what you can and can't do with the non-pro freely downloadable version of their tool.)

Link to comment
Share on other sites

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