Jump to content

[1.12.x] Kramax Autopilot Continued: Course guidance and auto-land for spaceplanes


linuxgurugamer

Recommended Posts

  • 2 months later...
  • 1 month later...

I have some questions about PID tuning.. some of my craft seem to have a lot of low-speed pitch oscillation when on initial/final approach; I've been solving this by increasing the scalar value for the vertical speed PID but that doesn't always work; is there a smarter way to tune the PIDs?  The craft in question all fly in a stable fashion when using fly-by-wire or pure manual control, so i don't think it's a design problem per se, but I'd like some advice on how to tune out the pitch oscillation better than just ramping the scalar up..?

Also if there were a way to integrate with FAR such that I could specify approach speeds in KIAS instead of m/s ground speed, that'd also be good, since.. that's how approach speeds work in the real world :)

Link to comment
Share on other sites

  • 3 weeks later...
On 11/4/2021 at 12:09 PM, ss8913 said:

I have some questions about PID tuning.. some of my craft seem to have a lot of low-speed pitch oscillation when on initial/final approach; I've been solving this by increasing the scalar value for the vertical speed PID but that doesn't always work; is there a smarter way to tune the PIDs?  The craft in question all fly in a stable fashion when using fly-by-wire or pure manual control, so i don't think it's a design problem per se, but I'd like some advice on how to tune out the pitch oscillation better than just ramping the scalar up..?

Also if there were a way to integrate with FAR such that I could specify approach speeds in KIAS instead of m/s ground speed, that'd also be good, since.. that's how approach speeds work in the real world :)

I'm not an expert, but scalar is probably not want you want to fiddle with. There should be seperate Kp, Ki, and Kd values - each of these are set specific to the plane (I don't think Kramax Autopilot has auto-tuning which is where the PID controller learns quickly and settles on suitable values). They all combine and affect each other, but I believe Kp may be too large (if it overshoots too much), or more likely Kd not large enough (if it doesn't, but keeps oscillating).

This dude knows more than I do, and has some advice. PID controllers are pretty much everywhere, so there's plenty of Youtube videos that describe how they work.

Personally, I always use Atmosphere Autopilot, because it's magical in it's ability to make planes fly really smoothly. For "fixing" any plane under manual control you just turn it on with "P" and it magically works (after a few seconds of slight oscillations).  It also does what's called "Moderation" which basically means your movements won't kill your Kerbal with high G maneauvers (you can turn that off if you need to do acrobatics or for drones). Under the hood it's more complex, because it's got PID auto-tuner swhich works for any aircraft in any situation (if it's possible to stabalize). It has similar autopilot features to Kramax:

 

Link to comment
Share on other sites

  • 2 months later...
On 11/19/2021 at 5:16 PM, 610yesnolovely said:

I'm not an expert, but scalar is probably not want you want to fiddle with.

Scalar is the first thing to fiddle with if an oscillation is occuring due to aggressive control inputs - think of it like moderation. 

I've been building various vehicles in Stormworks over the last couple years, which utilizes PIDs heavily in more advanced builds.  I've gotten okay at fiddling with the values.   Armed with this knowledge - I was delighted to find PIDs everywhere, including KSP!  KRAMAX and Atmosphere Autopilot are the two prime examples I am familiar with.

When I dig into the PID values in KRAMAX, some are a little aggressive by default.  I tend to reduce the integral and differential on the outer loop down close to zero, if not zero, and it often tunes out pesky oscillations.  

I will agree that Atmosphere Autopilot is a much better program in terms of "set it and forget it" flying - in most cases it tunes itself - rather brilliantly.  I almost never leave a runway before tapping "P".  As a current keyboard pilot - its the best way to simulate a steady, analog stick rotation, so the plane leaves the runway poised and not flapping around from keyboard or SAS control.

My current solution for ILS flights - use BOTH.  When flying long airliner routes: I have AA Fly-By-Wire active, I use KRAMAX for ILS and most of the time I have warp set to 4x.  AA seems to be able to moderate the KRAMAX inputs, in most cases.

(For the autopilots to work well at warp, I use BetterTimeWarp to enable hyper warp and lossless physics warp - and set the CPU value to 1.  Most modern gaming PCs can ignore the warning about CPU lag, it was written when even the best processors on the market would have choked.  I am running an i9-10900K and have zero lag issues when using lossless physics warp, in or out of atmosphere.)

I will say this... KRAMAX seems to have a tendency to oscillate along the pitch axis more so than yaw or roll.  I have no logged data to back this up - its purely subjective right now.  I planned on spending the day messing with my airliners (I'm on a Kerbinside GAP Remastered Kick :D).  Perhaps I'll do some logging and map the interactions between KRAMAX and AA FBW.  I notice that a good PID setting for KRAMAX at 1x warp may become an oscillation at 4x warp too - I'll see if I can get any data on that as well.  No promises but maybe I can shine a light somewhere helpful. 

Edited by Bearfight
More Info/Correction
Link to comment
Share on other sites

  • 2 weeks later...

Quick update to my last post - I fired up git and vs - looked into the PID module's code and learned that I have much more to learn.   No quick fixes coming from PID controller source code tweaks, of course.  Now that I'm a bit more educated - just enough to be dangerous I think - I don't have much trouble tuning out an oscillation. 

Still,  I wanted to know more so I looked into the Atmosphere Autopilot (AA) source & docs and learned about its modular "autopilots" concept.  Fly-By-Wire, Cruise, Controller and Mouse Director are the three "autopilots" provided out of the box with AA but it's designed; intended I think actually- to take on additional modules.  My ultimate goal would be to port Kramax's waypoint-based ILS functions into an Atmosphere Autopilot module.  If I understand the concepts correctly, that should give us the best of all worlds.  The realtime waypoint-based ILS nav data of Kramax being acted on by the variable, self-tuning, flight controller suite that underpins AA.   

No idea what that would take, logistically, just yet - more learning ahead.   Having a clear goal makes learning things easier - or at least more fun, IMHO. 

Link to comment
Share on other sites

  • 2 months later...
On 2/20/2022 at 9:14 AM, Bearfight said:

Quick update to my last post - I fired up git and vs - looked into the PID module's code and learned that I have much more to learn.   No quick fixes coming from PID controller source code tweaks, of course.  Now that I'm a bit more educated - just enough to be dangerous I think - I don't have much trouble tuning out an oscillation. 

Still,  I wanted to know more so I looked into the Atmosphere Autopilot (AA) source & docs and learned about its modular "autopilots" concept.  Fly-By-Wire, Cruise, Controller and Mouse Director are the three "autopilots" provided out of the box with AA but it's designed; intended I think actually- to take on additional modules.  My ultimate goal would be to port Kramax's waypoint-based ILS functions into an Atmosphere Autopilot module.  If I understand the concepts correctly, that should give us the best of all worlds.  The realtime waypoint-based ILS nav data of Kramax being acted on by the variable, self-tuning, flight controller suite that underpins AA.   

No idea what that would take, logistically, just yet - more learning ahead.   Having a clear goal makes learning things easier - or at least more fun, IMHO. 

I too use both AA and KRAMAX but it seems like AA does nothing when Kramax is engaged.. I can't notice any difference between AA on/off when kramax is on, at least.  I have lately been having a lot of trouble with pitch and sometimes yaw oscillations with kramax - it's gotten worse in the last 12-18 months it seems like - the only designs that are stable in kramax are twin tail (V tail) delta wing designs.. anything with separate wings and elevators seems to be very prone to oscillation, sometimes extreme inputs to the vertical speed PID's scalar value fixes it (like over 4.00) sometimes not.  What I cannot find is any QR guide on what the PID tunable values actually do, ie what effect does scalar have (you mentioned it's like a damper, is that it?)  what about Kd and Ki and the others?  I'm not sure how to figure out what I need to tune and in which direction to stabilize flight.  All of the designs in which the oscillations occur, if I turn off KRAMAX and use AA, they fly in a very stable fashion, so I don't think it's a problem with my designs per se, but rather that they require different PID values that I have yet to find.

Can one see the AA PID values from anywhere in AA?  does copying those PID values into kramax work, by any chance?

Link to comment
Share on other sites

  • 2 months later...

kramax autopilot have a lot of problems controlling big aircraft which causes them to move up/down and it is caused by high expect response rate of autopilot which should be lowered for heavier aircraft

Edited by tonimark
Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...
On 2/20/2022 at 11:14 AM, Bearfight said:

Quick update to my last post - I fired up git and vs - looked into the PID module's code and learned that I have much more to learn.   No quick fixes coming from PID controller source code tweaks, of course.  Now that I'm a bit more educated - just enough to be dangerous I think - I don't have much trouble tuning out an oscillation. 

Still,  I wanted to know more so I looked into the Atmosphere Autopilot (AA) source & docs and learned about its modular "autopilots" concept.  Fly-By-Wire, Cruise, Controller and Mouse Director are the three "autopilots" provided out of the box with AA but it's designed; intended I think actually- to take on additional modules.  My ultimate goal would be to port Kramax's waypoint-based ILS functions into an Atmosphere Autopilot module.  If I understand the concepts correctly, that should give us the best of all worlds.  The realtime waypoint-based ILS nav data of Kramax being acted on by the variable, self-tuning, flight controller suite that underpins AA.   

No idea what that would take, logistically, just yet - more learning ahead.   Having a clear goal makes learning things easier - or at least more fun, IMHO. 

Did this ever go anywhere?

 

Link to comment
Share on other sites

  • 8 months later...

@Caerfinon @ss8913 I realize that the last post was 2 years ago but I was hoping you could help me use the flight plan script properly.  The environment is Modular RSS 1/4 sized real solar system. Earth is 600000 meters in diameter.

python kramax.py -p="Earth" -g="3" -r="600000" --name="KSC27" --description="KSC Runway 27" --latitude="4.99730396296269" --longitude="-52.791191178751" --heading="270" --altitude="21"

It returns waypoints with their respective altitudes at MAXKY, HIKEY, LOKEY, etc but they are all at the same coordinates as input via the command line. My results are not generating distance as they are in Caerfinon's posts. I am trying to plot a 3 degree glide slope from MAXKY to FLARE/STOP, assuming that STOP is the position I parked on the runway to gather the coordinates, if that helps.

EDIT: DUH! I think I fixed it. Radius is in km and not m for one... There is distance, it's just 1000 times compressed. Using --debug returns distance. Without it, it's a vertical descent.

 

Edited by AuddieD2015
USER ERROR
Link to comment
Share on other sites

11 hours ago, AuddieD2015 said:

I think I fixed it. Radius is in km and not m for one

This is the secret sauce for the script to work accurately.  I always take my runway readings from the center of the runway ends just to get some extra landing room. Some argue that taking it from the target markers is better and more realistic, but its all personal preference. 

If you are coordinating the flight plans with the Nav Utilis mod it's important to take the runway measurements from the same location, other with the landing indicators are slightly off.  

Link to comment
Share on other sites

17 minutes ago, Caerfinon said:

If you are coordinating the flight plans with the Nav Utilis mod it's important to take the runway measurements from the same location, other with the landing indicators are slightly off.  

I am. I will make sure to keep that in mind. This is my first time playing Modular RSS and I have not opened any other bases yet so this info will come in handy! One thing is certain, I am glad I found this script because I was pulling my hair out trying to plot a glideslope like you would your algebra homework and it was not working.

Link to comment
Share on other sites

3 minutes ago, AuddieD2015 said:

I am glad I found this script

I was glad I found it too! Without it I never would have have written the Flight Contract mods for Kerbin Side Remastered. Best of luck on your project. 

Link to comment
Share on other sites

  • 4 weeks later...

I've noticed that the option for auto-throttle doesn't seem to work until you toggle on the PID option at the top left atleast once during flight. Otherwise it just throttles down your plane to 0% until you click it, no matter what velocity you try to set.

Link to comment
Share on other sites

  • 2 months later...

Rss main runway with canaveral hd/canavral pads 09/27 approcah might need some fine tuning from some one 09 came out better, 27s ok just lands on runway a little late, long as you dont need the whole runway to slow down other wise fine tune them a bit.

P.s I dont know how to put hte file in the collaspeable feild so ill just post a new coment

Link to comment
Share on other sites

KramaxAutoPilotPlans
{
}

KramaxAutoPilotPlansDefault
{
    Earth
    {
        FlightPlan
        {
            planet = Earth
            name = Ksc Runway
            description = SPACE COAST RGNL RNAV RWY 09 (NORTH)
            WayPoints
        }
        FlightPlan
        {
            planet = Earth
            name = R09 Cape Caneveral
            description = Cape Caneveral
            WayPoints
            {
                WayPoint
                {
                        Vertical = true
                        lat = 28.5535480819622 
                        lon = -80.654483101065
                        alt = 100
                        name = R09 Dep
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.5536691681812 
                        lon = -80.5597841504006
                        alt = 200
                        name = R09 Climb
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.5535480819622
                        lon = -80.2099399970557
                        alt = 1000
                        name = R09 Ascent
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.5839329412693
                        lon = -80.6867476554833
                        alt = 1000
                        name = R09 Localiser
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.5807426433006
                        lon = -80.8594632872108
                        alt = 900
                        name = R09 Donut
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.6447567144193
                        lon = -80.9328527470692
                        alt = 800
                        name = R09 Donut 2
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.6590994802035
                        lon = -81.0771904479993
                        alt = 700
                        name = R09 Donut 3
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.6143845392291
                        lon = -81.0912811686739
                        alt = 600
                        name = R09 Donut 4
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.5535294223846
                        lon = -81.0462926516392
                        alt = 500
                        name = R09 Lineup
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.5535294223846
                        lon = -80.8674048007813
                        alt = 400
                        name = R09 Approach
                }
                WayPoint
                {
                        Vertical = true
                        IAF = true
                        lat = 28.5535294223846
                        lon = -80.7633929030822
                        alt = 300
                        name = IAF
                }
                WayPoint
                {
                        Vertical = true
                        FAF = true
                        lat = 28.5535294223846
                        lon = -80.7537525999965
                        alt = 200
                        name = FAF
                }
                WayPoint
                {        
                        Vertical = true
                        RW = true
                        lat = 28.5535294223846
                        lon = -80.707525999965
                        alt = 100
                        name = Flare rw
                }
                WayPoint
                {
                        Vertical = true
                        STOP = true
                        lat = 28.5535294223846
                        lon = -80.6724494560567
                        alt = 21
                        name = Touchdown Stop
                    }
                }
        }
        FlightPlan
        {
            planet = Earth
            name = R27 Cape Caneveral
            description = Cape Caneveral
            WayPoints
            {
                WayPoint
                {
                        Vertical = true
                        lat = 28.7918641659757 
                        lon = -80.2273972401085
                        alt = 1000
                        name = R27 Intercept
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.8573429833046 
                        lon = -80.0631285821229
                        alt = 800
                        name = R27 Donut 1
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.8161351622206
                        lon = -80.0499096603379
                        alt = 700
                        name = R27 Donut 2
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.8036173003367
                        lon = -80.0656174953415
                        alt = 600
                        name = R27 Donut 3
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.7811261246653
                        lon = -80.1470518408905
                        alt = 500
                        name = R27 Donut 4
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.6104194001694 
                        lon = -80.4109857715712
                        alt = 450
                        name = R27 localizer
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.5535452361263
                        lon = -80.4586142154309
                        alt = 400
                        name = Approach 1
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.5535452361263
                        lon = -80.5312463358264
                        alt = 300
                        name = Approach 2
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.5535452361263
                        lon = -80.5536929033009
                        alt = 200
                        name = Approach 3
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.5535452361263
                        lon = -80.594794931099
                        alt = 100
                        name = Approach 4
                }
                WayPoint
                {
                        Vertical = true
                        lat = 28.5535452361263
                        lon = -80.6168308818209
                        alt = 81
                        name = Approach 5
                }
                WayPoint
                {
                        Vertical = true
                        IAF = true
                        lat = 28.5535452361263
                        lon = -80.6306580102335
                        alt = 61
                        name = IAF
                }
                WayPoint
                {
                        Vertical = true
                        FAF = true
                        lat = 28.5535452361263
                        lon = -80.6403175194006
                        alt = 41
                        name = FAF
                }
                WayPoint
                {        
                        Vertical = true
                        RW = true
                        lat = 28.5535452361263
                        lon = -80.6503175194006
                        alt = 21
                        name = Flare rw
                }
                WayPoint
                {
                        Vertical = true
                        STOP = true
                        lat = 28.5535452361263
                        lon = -80.6703175194006
                        alt = 21
                        name = Touchdown Stop
                    }                
        }
    }
}    

 

Edited by falcon470
Runway 27 Works much better now, figured id share the refined flightplan
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...