Jump to content

[kOS] Level-out SpacePlane?


Xyphos

Recommended Posts

@Xyphos

Use a P(I)D  controller (pd controller is good enough too). I'm writing this on a mobile so, ...

 

First, you wanna get the proportional value, or better, the distance between you and your target altitude.

Let's call it "error". As the name suggests, this simply measures the error in altitude. 

 

"set error to <targetAltitude> - altitude."

 

Now, we multiply that with a factor, to get bigger numbers out. This factor is called proportional factor. Let's set it to..well I have no idea, maybe 2. 

So then the program looks like this:

 

"Set error to <targetAltitude> - altitude.

Set P to error * 2."

The new variable <P> simply represents the whole proprtional part of it. Theoretically, this is already enough for your plane to try to keep its altitude @20. BUT, and you can try this, it will always overshoot, overcorrect, undershoot and will eventually spin out of control. So we need another variable, the "derivative". This basicallychecks how fast you are moving relative to your target (in this case your verticalspeed).

you add this to thecode:

"set D to verticalspeed * 1.5."

Again, same as above, just that <D> is now your errorvaluee, multiploed by a derivativegain. 

 

Now, you simply add these two variables <P> and <D> together and there you have it, your pitch value! 

 

Then; you need to have the program run constantky, so just add this:

 

set running to 1.

until running = 0

{

set error targetAltitude - altitude.

set P to error * 2.

set -D to verticalspeed * 1.5.

set putput to P + D.

lock steering to up + R (output,0,180).

 

ON abort 

set running to 0.

}

}

 

EDIT: "D"must be a negative number if you ascend, because it needs to counteract the proprtional value which tries to pull up really hard! FIXED! :)

 

I really hope this helps you...it was quite a hard job writing this out of my mind on mobilehahaa! :)

Edited by Kartoffelkuchen
Link to comment
Share on other sites

Thankyou for replying but I think your math is incorrect because I tried your formula and it's not working. the spaceplane is wobbling all over the place and stalls out.
perhaps you can reply later when you're in front of a computer?

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...