Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

My apologies if this is asked and answered already. This forum doesn't work well on a phone. Will kOS scripts work on an inactive craft? Meaning, could I launch a rocket with an accent and rendezvous script, then go to the target craft in orbit and let kOS take care of it, or do I need to stay focused on the launch vehicle until the program finishes?
Link to comment
Share on other sites

[quote name='Steven Mading']For some idiotic reason, Unity decided to make the log output filenames differ per platform even though there's NO TECHNICAL OS-BASED REASON they have to do that, and the entire goal of Unity was to be a cross-platform engine, thus the name "unity".

On Linux, they put the log file here:

"/home/user/.config/unity3d/Squad/Kerbal Space Program/Player.log"

(Change /home/user to whatever your home dir is).

Disclaimer: I don't have the game on Linux so I can't verify this - this is from posts I've seen from others.[/QUOTE]

yes, and it was even a hidden file, but here it goes:

[url]http://www./download/opexfx33mapw1ml/Player.log[/url]

I deleted the old log and opened the game just to test this and closed it, so would be easier to you, I presume.

thanks! :D
Link to comment
Share on other sites

[quote name='kananesgi']Will kOS scripts work on an inactive craft? Meaning, could I launch a rocket with an accent and rendezvous script, then go to the target craft in orbit and let kOS take care of it, or do I need to stay focused on the launch vehicle until the program finishes?[/QUOTE]
The craft doesn't have to be focused (although some commands won't work on unfocussed vessel), but it has to be loaded (in physics range) for anything to work. So swithching to the second craft during docking is OK (mostly...), but if you switch to a target far away the autopilot won't work.
Link to comment
Share on other sites

Just want to thank you again and again for your amazing work. I was far of KSP scripting for some time because without functions the complex programs became a hell. I just look at KOS engine from time to time and few days ago I see there is it - we've got functions! Now I can return to programming of space programs. You're the best!
Link to comment
Share on other sites

Hi. Long story short:
KSP v: 1.0.5.1028
kOS v: 0.18.1
I'm unable to use the "change name tag" button while in VAB/SPH (in simulation it works fine). Is this an issue on my side or I just need to wait for a new kOS release?
Link to comment
Share on other sites

v0.18.2

Github
KerbalStuff

BREAKING CHANGES

  • As usual, you MUST recompile all KSM files before running them on the new version. Some of the changes have altered how the VM works.
  • Nothing else... we hope.

NEW FEATURES

BUG FIXES

  • The processor's mode (on/off/starved) is now saved and restored ( #1172 )
  • Fixed stage resources again to address a change in KSP 1.0.5 ( #1242 )
  • Fix occasional instances of flight controls getting disabled during a docking/undocking/staging event ( #1205 )
  • kOS can now trigger module events with RemoteTech installed and no KSC connection (RemoteTechnologiesGroup/RemoteTech#437 )
  • Fixed handling of multiple thrust/gimbal transforms and corrected some of their directions ( #1259 )
Edited by erendrake
reformatting for new forums
Link to comment
Share on other sites

  • 3 weeks later...

A quick little ( RSS/RO ) KOS video and example code.

Video :- https://www.dropbox.com/s/1df0y8076bplpx0/KosSat.mp4?dl=0  (95MB = 09:45))

Code :- https://www.dropbox.com/s/8lp55fs86705r17/SatKOS.zip?dl=0

 

Edt:

It seems consistent with another launch..  ( set it running.. went down the road on chores.. came back and all was fine )

Rh6hCUI.jpg

 

A slight change in the code in the final stages..

	UNTIL mPERI > 4999900
	{
		Set mTIME to ETA:APOAPSIS.
		Set mAPO to ALT:APOAPSIS.
		Set mPERI to ALT:PERIAPSIS.

		Set mT to (140 * ((5000000 - mPERI) / 5000000)).	// Apoapsis time for motor limit

//***********************************************************
		if mT < 10 {
			set mT to 10.			// Hold it at a minimum of 10 secs
			Toggle (AG9).			// Engines 1206 OFF to extend other Engines ON time
		}
//***********************************************************
		IF mTIME > mT 				// Motor toggle
		{
			Set myTrottle to 0.		// Engines OFF
		} ELSE
		{
			Set myTrottle to 1.		// Engines ON	
		}
		PRINT mTIME AT (16,4).
		PRINT mAPO AT (16,6).
		PRINT mPERI AT (16,8).
	}

 

Edited by ColKlonk
changes
Link to comment
Share on other sites

KOS ? or the example ?

KOS - as in any mod, install it... make sure you add a KOS part to your craft - program it.

The Example - It'll be hard to find a general program that works 'perfectly' for all rockets.

You have to study the methods used and modify them to suite your rocket.

The example makes extensive use of Action Groups, Stage design in the VAB and ..

with RSS/RO/RealFuel mods you have to be more precise with your DeltaV design as very few motors are throttleable.

(you should try not pancake the nauts)

 

Lots of toys for you to play with - good luck.

 

Link to comment
Share on other sites

A question mark... ??

Does KOS maintain it's code position on from the last physics freeze frame. ? ( I take this as yes)

I'm getting wierd results from this function... which loops until it's flagged to exit

Global variable CntEngs is an integer ranging from [0..12]

It controls the ON/OFF functions of 12 pairs of engines via Action Groups, which doesn't work as planned.

Could it just be too many IF statements.. as it certainly loses control as if it's lost track of the code !

HgtApo and HgtPeri are just altitude locks.

 

 

//************************************************
//					DO_STAGE3
//************************************************
Function DO_STAGE3
{ 
local Diff is 0.
local mT is 0.

	CLEARSCREEN.
	Set SASMODE to "Prograde".
	PRINT "STAGE 3" AT (14,0).
	PRINT "=======" AT (14,1).

	PRINT "APO TIME   :" AT (2,4).
	PRINT "APO HGT    :" AT (2,5).
	PRINT "PERI HGT   :" AT (2,6).

	Set myTrottle to 1.
	Set mBoolProc to TRUE.
	UNTIL mBoolProc = FALSE
	{
		IF HgtPERI < 0 
		{
			set mT to 120.
		}
		ELSE
		{
			set mT to (120 * ((HgtAPO - HgtPERI) / HgtAPO)).
		}
		IF mT < 6 { Set mT to 6.}
	
		Set myTime to ETA:APOAPSIS.
		IF myTime > mT
		{
			Set mT to CntENGs - 1.
			IF mT < 1 {Set mT to 0.}
		}
		ELSE
		{
			Set mT to CntENGs + 1.
			IF mT > 11 {Set mT to 12.}
		}
		Set CntENGs to mT.
	

		IF CntENGs > 0{
			Toggle (AG20).
		} ELSE {
			Toggle (AG32).
		}

		IF CntENGs > 1	{
			Toggle (AG21).
		} ELSE {
			Toggle (AG33).
		}

		IF CntENGs > 2	{
			Toggle (AG22).
		} ELSE {
			Toggle (AG34).
		}

		IF CntENGs > 3	{
			Toggle (AG23).
		} ELSE {
			Toggle (AG35).
		}

		IF CntENGs > 4	{
			Toggle (AG24).
		} ELSE {
			Toggle (AG36).
		}

		IF CntENGs > 5	{
			Toggle (AG25).
		} ELSE {
			Toggle (AG37).
		}

		IF CntENGs > 6	{
			Toggle (AG26).
		} ELSE {
			Toggle (AG38).
		}

		IF CntENGs > 7	{
			Toggle (AG27).
		} ELSE {
			Toggle (AG39).
		}

		IF CntENGs > 8	{
			Toggle (AG28).
		} ELSE {
			Toggle (AG40).
		}

		IF CntENGs > 9	{
			Toggle (AG29).
		} ELSE {
			Toggle (AG41).
		}

		IF CntENGs > 10	{
			Toggle (AG30).
		} ELSE {
			Toggle (AG42).
		}

		IF CntENGs > 11	{
			Toggle (AG31).
		} ELSE {
			Toggle (AG43).
		}

		Set Diff to HgtAPO - HgtPERI.
		if Diff < 5000 {
			Set myTrottle to 0.
			set mBoolProc to FALSE.
		}

		PRINT ETA:APOAPSIS AT (15,4).
		PRINT HgtAPO AT (15,5).
		PRINT HgtPERI AT (15,6).

		WAIT 0.001.
	}
}

 

Edited by ColKlonk
Link to comment
Share on other sites

Not to worry.. all fixed !

I placed a Wait 0.01 statement between the IFs and all works fine.

Next trick is to move the Bit-Bang control to discrete APO_Time differentials.

I recently read somewhere that this is indeed one of the methods used on some spacecraft - interesting!

18 metres difference isn't too bad...

https://www.dropbox.com/s/97jiv3prtugkfpt/ISS_delivery.mp4?dl=0  (9.2MB)

 

Link to comment
Share on other sites

Here's a further development of the Bit_Banging control, applied to a big rocket. (It's not perfect yet, so I must clean it up first, before publishing.)

It's based on matching the rate changes between ETA:PERIAPSIS and the difference between ALT:APOAPSIS and ALT:PERIAPSIS.

This brings the two points together at the same time, and in doing so matches the Apo and Peri heights in an almost perfect circular orbit.

At the moment you have to design your Delta-V to place the rocket, at last stage, approx 200 seconds behind Apoapsis, which is where this video begins.

I'll relax these restrictions in an improved version later.

The video is at 4x speed and KSP has noisy engine on/off sounds (I've turned the volume down).

https://www.dropbox.com/s/rz92i7lfvqje8e9/Kos_ISS.mp4?dl=0 (9 MB)

Edited by ColKlonk
Link to comment
Share on other sites

My calcs take 3 subtractions, 3 divisions, 1 multiplication plus 1 more subtraction or addition, to get the motor settings (no trig or vector operations involved).

I must still clean it up as I'm sure there's room for optimisation.

 

Edited by ColKlonk
Link to comment
Share on other sites

Hello my friend, at first i want to thank you for the great job you are doing. At last i have my brains loaded with smth interesting, including a lot of physics and math for compiling different functions for kOS. Thank you!

I've got one question - didn't find needed info in documentation. Are there some special suffixes for part's temperatures ("exposed skin", and "all skin" temp's especialy) and for part / ship drag? I would be very grateful for help!

Edited by AlexSilver
Link to comment
Share on other sites

The temperature model changed in the stock game and kOS hasn't caught up.  It doesn't report an "interior" and "exterior" heat for a part.  This is partly because we were hoping it would be possible to get the info thematically by having you have to place a thermometer and read the thermometer, thus being unable to get the heat reading of every part - just the ones you stuck a sensor onto.  The change of the stock game to have a separate interior temperature sort of mucked that plan up because you can't read that from a thermometer.   Chances are we'll fix this eventually but it's been super low priority compared to other things to work on.

 

As for drag, that's much harder to get magically from a sensor, and doesn't feel realistic to add to the autopilot's API directly.  What you can do, though, is calculate how much you *would have* changed velocity had you been in a vacuum, and then compare that to how much you actually *did*, and assume the difference is due to drag.

Link to comment
Share on other sites

Oh. great thanks!

As for me this is rather strange decision to get the heat reading only from thermometer as a part. I mean that in game scientifical devices are way too limited. But that's ok - cause you are the developers and you have your own vision of how should it works.

Quote

What you can do, though, is calculate how much you *would have* changed velocity had you been in a vacuum, and then compare that to how much you actually *did*, and assume the difference is due to drag.

Ehmm, that's not really what i was talking about. I agree with you, that doesn't feel realistic to get current drag from some sensor. But then we should be availiable to calculate it. That's not very hard when we have cylinder-shaped craft - so we know it's dimensional characteristics, heading vector, it's speed and acceleration (dV/dT = elementary. Yep, here. In every modern SAS-like system we have an accelerometers, that can measure acceleration. Do we have some suffix for it in kOS? At least located along the axes? I found smth. but not sure i'm right:  SHIP:SENSORS:ACC | SHIP:SENSORS:ACC:X | SHIP:SENSORS:ACC:Y | SHIP:SENSORS:ACC:Z | SHIP:SENSORS:ACC:MAG), G, C(x) and e.t.c. But what if our ship has a complicated shape, spaceplane for ex.? It's very complex to calculate it's projected area.

Link to comment
Share on other sites

Is it possible to set the max output of the torque PID controllers?  When I set a new steering, kOS maxes out the controls for a very short time.  That triggers any structural instability in the craft to cause wobbling (unless you add a bunch of struts).  I tried lowering the max stopping time, but it didn't help.  Or another way to avoid that initial jolt?

Link to comment
Share on other sites

I am assuming that the correct rocket and the correct script with KOS would allow you to launch and land on the mun.

If I am not a coder, but I understand "basic" - will I be able to grasp KOS?
Can someone point me to a simple sample launch from Kerbin KOS script?  I attempted to use one that i saw on the KOS wiki, but the KOS terminal didn't like anything that i typed in.

Yes, I am a total KOS nood.

Link to comment
Share on other sites

On 26/12/2015 at 4:09 AM, gamerscircle said:

I am assuming that the correct rocket and the correct script with KOS would allow you to launch and land on the mun.

If I am not a coder, but I understand "basic" - will I be able to grasp KOS?
Can someone point me to a simple sample launch from Kerbin KOS script?  I attempted to use one that i saw on the KOS wiki, but the KOS terminal didn't like anything that i typed in.

Yes, I am a total KOS nood.

'Basic' would be fine... this is not rocket science.... so no problem !!

Yes.. you can get a basic script, but you have to fine tune it to every custom rocket.

There's a good one on KOS Github, which funny enough ended was similar to what I 'thumbsucked'.

I only saw the example after my posting here :).
 

A suggestion for the KOS developer... How about data arrays ?.

an example use would be in averaging discrete differentials.. etc.

I'm looking at taking running averages over 8 (or 16) samples as KSP calcs tend to go wild when close to 'critical points'.

 

Edited by ColKlonk
Link to comment
Share on other sites

2 hours ago, Steven Mading said:

As something distinct from the existing List()? Can you explain further?

 

Ag!! sorry... Missed that one.. was thinking in pure hardcore arrays... ( I usually develop in asm)

Thanks..

Edited by ColKlonk
Link to comment
Share on other sites

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