Jump to content

[kOS] Plane PID Controller?


Xyphos

Recommended Posts

I'm having difficulty writing an autopilot script for normal air planes. I want my plane to take off from KSC then roll/bank turn to a parameter heading then hold altitude until program is terminated.

I can do the (crude) takeoff procedure just fine, and I know how to lock the steering after the turn, but I have no clue how to make a PID controller do a rolling bank maneuver to the desired heading.

Link to comment
Share on other sites

I have done this by locking the steering to the heading of the plane, plus a roll angle proportional to the heading error. So a simple p-controller, leaving the PID stuff to the kOS steering.

Edit: if it helps, the code is here (functions atmoLandingPlane or atmoAscentPlane, not well commented unfortunately):
https://github.com/pellinor0/kOS-MissionFramework/blob/master/Script/libatmo.ks

Edited by pellinor
Link to comment
Share on other sites

23 minutes ago, pellinor said:

not well commented unfortunately

thanks a ton and no worries; I used to do software engineering (C/C++ & C#) before changing careers, so I'm quite used to picking through other people's code, though a bit rusty.
 now I have an example to work with and learn from. thanks!

Link to comment
Share on other sites

I did this in my auto-landing pilot scripts from some older twitch episodes:

https://drive.google.com/folderview?id=0Bxkeai7oN35ffmFzZzZXTXZXWG9kUm5ERjhjR1pLcTBCZVJDX0FtVGltT2QtaUF1TTJqQVk&usp=sharing

(There's a lot in there besides just the "follow a heading" but the "follow a heading" stuff is there.)

It's basically a pair of nested PID controllers, like so:

PID 1 chooses a desired bank angle based on how far off the compass is from the desired heading.  The further off the compass is, the steeper  it wants to bank, up to a max bank of 45 degrees.

PID 2 starts from the output of PID 1, being given the desired bank angle, and chooses the roll control input based on how far off it is from the desired bank.

 

Link to comment
Share on other sites

10 hours ago, Steven Mading said:

(There's a lot in there besides just the "follow a heading" but the "follow a heading" stuff is there.)

yeah, that's beyond my level of expertise. I understand (most of) the code but I don't see anything in there that would point my plane to a heading.

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...