Jump to content

kOS Scriptable Autopilot System 0.9


KevinLaity

Recommended Posts

Did some more testing in regards to my issue. Original post is here: http://forum.kerbalspaceprogram.com/showthread.php/47399-kOS-Scriptable-Autopilot-System-0-35?p=621892&viewfull=1#post621892

I threw a couple print commands into the loop to see what would happen. This is my testing script.


until altitude > 10000 {
if vertical speed < 100 {
print "Throttling up".
set tVar to tVar + 0.02.
}.
if vertical speed > 100 {
print "Throttling down".
set tVar to tVar - 0.02.
}.
}.

This continuously prints 'throttling up' as soon as the program runs. The second i go over 100m/s it switches to printing "throttling down" (so i know it's recognizing the speed correctly). But it still won't actually move the throttle for another 5 seconds or so, and by that time i'm already over 150m/s. So it seems that i'm having an issue with throttle response. Are other people seeing the same thing or is this just on my end?

Try altering your code to match this and see what happens.


until altitude > 10000 {
if vertical speed < 100 {
print "Throttling up".
set tVar to tVar + 0.02.
lock throttle to tVar.
}.
if vertical speed > 100 {
print "Throttling down".
set tVar to tVar - 0.02.
lock throttle to tVar.
}.
}.

Link to comment
Share on other sites

After "set tVar to tVar - 0.02." try adding "print tVar." to make sure it's actually doing it.

You are a genius! I can't believe i didn't think of doing that, haha! I also can't believe i didn't think about having to limit tVar to 1. I immediately saw what was wrong as my tVar value continued to climb above 2 and then had to wait for it to come back down below 1 before the throttle moved. Looks like i owe you a beer :cool:

@JewelShisen: Thanks for the suggestion. I already had the throttle locked to tVar further up in the program though.

I would give my left arm for an 'AND' gate right about now..haha :sticktongue:

Edited by dave4002000
Link to comment
Share on other sites

It's quite difficult to make the autopilot hover something smoothly. Using a code like that it will just rubberband up and down, more and more, until it runs out of fuel. I had to deal with such issues while making my landing autopilot. I found that the best solution was to set "limits" on the throttle.

if verticalspeed > 0 {
set tvar to tvar - 0.02.
}.
if verticalspeed < 0 {
set tvar to tvar + 0.02.
}.
if tvar > 0.25 {
set tvar to tvar - 0.1.
}.
if tvar < 0.05 {
set tvar to tvar + 0.1.
}.

or something similar. It worked pretty well for me

Edited by mushroomman
Link to comment
Share on other sites

You are a genius! I can't believe i didn't think of doing that, haha! I also can't believe i didn't think about having to limit tVar to 1. I immediately saw what was wrong as my tVar value continued to climb above 2 and then had to wait for it to come back down below 1 before the throttle moved. Looks like i owe you a beer :cool: @JewelShisen: Thanks for the suggestion. I already had the throttle locked to tVar further up in the program though. I would give my left arm for an 'AND' gate right about now..haha :sticktongue:
I've debugged a lot of my own code with print statements and I always start by placing them after a variable is updated. Glad it's working for you.
Link to comment
Share on other sites

hello,

when typing in the console the game also registers the keys and starts with action.

e.g. typing "u" in console toogle my light / typing space.... staging

i tried version 0.3 .. 0.35... without success.

What can i do? is the bug known?

Link to comment
Share on other sites

Don’t suppose that we can get this to turn on/off parts of Mechjeb? Right now I got a pretty good ascent script using it to control the mechanical parts and Mechjeb to control guidance, but I have to manually turn on and off the Mechjeb ascent guidance for my vehicle to do what I want it to do. I prefer it more than trying to code that part right now, and it works wonderful. If it was not for that I could send a probe to Duna completely hands off! This mod is the best thing since sliced bread!

Link to comment
Share on other sites

Don’t suppose that we can get this to turn on/off parts of Mechjeb? Right now I got a pretty good ascent script using it to control the mechanical parts and Mechjeb to control guidance, but I have to manually turn on and off the Mechjeb ascent guidance for my vehicle to do what I want it to do. I prefer it more than trying to code that part right now, and it works wonderful. If it was not for that I could send a probe to Duna completely hands off! This mod is the best thing since sliced bread!

The only interoperability you get right now is via action groups. I don't believe MechJeb exposes any of its functions to action groups

Link to comment
Share on other sites

I wish the terminal could be run from a separate computer....... or at a minimum, not in the ksp screen.....

Maybe the ability to use an SSH client or something similar to control the terminal? That would certainly be interesting. Later in development, when we can fully automate entire flights, it would be cool to be able to open up a client while away from the computer and see how it's been going.

Link to comment
Share on other sites

Since I don't really understand the directions apart from UP I've been trying to create a hovering script. My first try was going up and down faster and faster to end crashed in the launch pad ^^

Here what I developped on the train this afternoon, what do you think? =)


set x to 0.
print "Running.".
print "Launch action group 8 to hover and 9 to cancel the hovering.".
until altitude > 10000 {
on AG9 set x to 1.
if x=1 {
set A to altitude.
print "Hovering at " + A.}.
until x=0 {
on AG9 set x to 0.
if x=0 {unlock all.}.
lock steering to UP.
set H to (Mass/Maxthrust).
lock throttle to H.
if altitude > A {lock throttle to H+0.5.}
if altitude < A {lock throttle to H-0.5.}
}.
on Abort BREAK.
}.
print "exiting Hovering.".

Link to comment
Share on other sites

hello,

when typing in the console the game also registers the keys and starts with action.

e.g. typing "u" in console toogle my light / typing space.... staging

i tried version 0.3 .. 0.35... without success.

What can i do? is the bug known?

This does seem to happen occasionally. Have you tried closing and re-opening the terminal? Is it happening 100% of the time?

Link to comment
Share on other sites

The bus part: I'd rather not if I can avoid it. At one point I tried automatically forcing new partmodules onto all the ship's parts at launch time and assigning them id's. It worked great except they wouldn't be reloaded with the ship.

No, you can't program in the VAB. I had thought about that and having people save their programs along with their vessel prototypes. I couldn't find a way. Vessel prototypes basically just keep track of the fact that a part is there, and can't save any configuration of that part.

I prefer not to overwrite behavior of someone else's part, including stock parts. However, we may see a kOS unit that also acts as a probe part.

I meant a bus part you can place on parts manually and are assigned an kOS ID number along with a part number.

Couldn't you save the program as a separate notepad file within the ship save?

And now someoe has to make an addon to make probes use kOS.

Link to comment
Share on other sites

I meant a bus part you can place on parts manually and are assigned an kOS ID number along with a part number.

Couldn't you save the program as a separate notepad file within the ship save?

And now someoe has to make an addon to make probes use kOS.

no they just have to make a cfg for module manager.

Link to comment
Share on other sites

I'm running these two, and haven't noticed such an issue.

I have mechjeb and all sorts of mods like firespitter and procedural everything. Etc... I haven't had too many problems other than realizing I need to move a whole section from the top to the bottom because my stupid brain wrote it out of order.

The whole loop at the bottom and one time trigger thing is a little strange to me. My brain wants to put everything in a main loop. Then I find out the operators I need just don't exist. I hear you guys about the "and" thing. As many times as my brain has said " if this and that are true." Oh.. there is no and!

Link to comment
Share on other sites

Hey, before you update, you should consider adding some sort of shortcut to open the kOS terminal. When you end up using it so much it starts to become a tiny bit tedious to rotate around to right click and open. Maybe an AG?

Link to comment
Share on other sites

okay, i have found the bug:-)

i removed the mod "RemoteTech" and everything is fine.

@Kevin: is it possible for you to find out what the problem with RemoteTech is? it's really a good mod with realistic feeling and i want to use both mods:-)

Link to comment
Share on other sites

Great idea, picked up this add-on a few days ago and was on the forums when you snuck in an update from .3 to .4 sofar i havn't used this in a save, oly in my test build version of KSP. like it so far.keep up the great work!

Link to comment
Share on other sites

What's new

Current Version: 0.4

- Bug fixes

- Interact with subelements of R()

- Targetting

- Radar altitude

- Plaintext editing

- Toggle terminal & power from action group

- Maximum thurst variable

- Surface speed variable

Sweet!!

Could you give some example of how you would keep a craft oriented to opposite the direction of travel? I tried retrograde but that seems to mean west. My landing auto pilot works just fine straight up and down. Maybe if I was in an obit inclined to 0. canceling horizontal velocity I haven't been able to wrap my head around aside from trying to track lat and long and horizontal speed in some meaningful way. I think that is a little beyond me at this point.

Link to comment
Share on other sites

Hey, before you update, you should consider adding some sort of shortcut to open the kOS terminal. When you end up using it so much it starts to become a tiny bit tedious to rotate around to right click and open. Maybe an AG?

Already taken care of, see the 0.4 release video:

Link to comment
Share on other sites

Sweet!!

Could you give some example of how you would keep a craft oriented to opposite the direction of travel? I tried retrograde but that seems to mean west. My landing auto pilot works just fine straight up and down. Maybe if I was in an obit inclined to 0. canceling horizontal velocity I haven't been able to wrap my head around aside from trying to track lat and long and horizontal speed in some meaningful way. I think that is a little beyond me at this point.

Cancelling horizontal velocity would be a tough one right now. Right now you can get the total surface speed but not lateral direction of travel. I need to think about how to solve this one.

Link to comment
Share on other sites

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