Kartoffelkuchen Posted February 24, 2020 Share Posted February 24, 2020 (edited) Features Speed control Maintain altitude Maintain heading Maintain climbrate Autonomous takeoff Autonomous landing Fly a pre-programmed route Fly to a pre-programmed waypoint Also works in FAR What it is This is a project I've been working on forever. Programming an atmospheric autopilot can be very, very hard, but I've came up with an acceptable result, at least in my eyes, and wanted to let you guys be able to check it out! There is much to be optimized which I will do in the future as well as add new features, but for now, the results were quite good in my opinion, which is why I'm releasing it now. Installation Install kOS https://github.com/KSP-KOS/KOS/releases Download the script https://spacedock.info/mod/2346/KK's Airplane Autopilot Put all the files inside your KSP Main/Ships/Script folder How to use Attach a kOS unit to your aircraft If your craft has thrust reversers, put them on action group 4 Launch the craft Open the kOS terminal Enter the following: switch to 0. run auto307. Once the gui is built, you can hop into the settings menu and adjust all your parameters there. For some more detailed information, you can also hop into the script, I've added some comments there explaining the different variables, but it should be pretty much self-explanatory. You can also choose to add a new "airplane" to the database, simply copy an existing one (do not copy the last aircraft, copy one of the first) and adjust the parameters. Enjoy! To create new waypoints, simply copy an existing one (best if you copy the first one), give it a new name and enter it's latlng position. You can do this two ways: log the current geoposition of your craft to a file and then copy the logged coordinates into the waypoint OR enter the coordinates from the cheat menu "Set position". The same procedure for navigation / flyroute mode. Copy an existing one, add the waypoints and end with a runway. This script could be extremely handy for career mode where you have to fly to certain waypoints, gather some data etc. Now you can just enter the heading you need to fly to, select the speed and altitude and lean back! Bus / Known issues: You might see some severe wobble / oscillation of the craft shortly after you activate a mode for the first time. The script will automatically try to reduce the oscillation but this might take a few seconds. If the oscillation is really bad, try to reduce control authority on the rudders in the beginning and steadily increase it. Some more action: @Mods, I hope this is considered to be an Addon and thus is in the right subforum! Edited July 10, 2020 by Kartoffelkuchen Quote Link to comment Share on other sites More sharing options...
Beetlecat Posted February 24, 2020 Share Posted February 24, 2020 Holy doodles! This looks great! Quote Link to comment Share on other sites More sharing options...
Cataclism Posted February 26, 2020 Share Posted February 26, 2020 Great, great work! I´ve become fairly happy after I saw it on Kottabos! Quote Link to comment Share on other sites More sharing options...
Stone Blue Posted February 26, 2020 Share Posted February 26, 2020 (edited) Wow... this looks kewl... A nice way for peeps to dip a toe into kOS, without having to use the kOS terminal and scripting for *everything*? vOv Hmmm... I imagine this could be adapted easily for use with ground vehicles/rovers, as well as naval craft? Could this also be easily adapted for use with waypoint addons? ie Waypoint Manager, NavUtilities, etc...??@Kartoffelkuchen Edited February 27, 2020 by Stone Blue Quote Link to comment Share on other sites More sharing options...
shdwlrd Posted February 29, 2020 Share Posted February 29, 2020 One way to get me to actually use K-os. Real cool work, may I suggest looking at PA to see how the PIDs were implemented. Quote Link to comment Share on other sites More sharing options...
Kartoffelkuchen Posted February 29, 2020 Author Share Posted February 29, 2020 @Cataclism Wow that review from @Kottabos is awesome, never expected that! :O @Stone Blue It's fairly easy, just open your standard editor and start coding away. Language isn't too hard since it's based on english. Yes, this can be easily adapted for ground use. I actually have already made a ground based mode for taxiing and stuff, I'll include that later. As far as integration with other mods is concerned, I think this would actually need to be a real plugin, but I have no experiences with such so far. @shdwlrd What do you mean with PA? Quote Link to comment Share on other sites More sharing options...
Stone Blue Posted February 29, 2020 Share Posted February 29, 2020 17 minutes ago, Kartoffelkuchen said: What do you mean with PA? Most likely this: vOv Quote Link to comment Share on other sites More sharing options...
shdwlrd Posted February 29, 2020 Share Posted February 29, 2020 8 hours ago, Kartoffelkuchen said: What do you mean with PA? @Stone Blue is correct. I did mean Pilot Assistant. Crzyrndm did an excellent job explaining what the different values for PID do and how they work with each other. Quote Link to comment Share on other sites More sharing options...
Noir Posted March 1, 2020 Share Posted March 1, 2020 This is easily the best autopilot I've used. Been using it with a compound helicopter (of all things!) in FAR and it works near perfectly. Thank you! Quote Link to comment Share on other sites More sharing options...
rottielover Posted March 2, 2020 Share Posted March 2, 2020 This is great, got me to actually use kOS since it first came out. Could you explain a few of the settings? Height? for thr rev. I assume 1 means true and 0 for false (ie On and Off) Most are self explanatory but I'm probably over-thinking the rest of them. Quote Link to comment Share on other sites More sharing options...
Kartoffelkuchen Posted March 2, 2020 Author Share Posted March 2, 2020 On 2/28/2020 at 9:02 PM, shdwlrd said: One way to get me to actually use K-os. Real cool work, may I suggest looking at PA to see how the PIDs were implemented. Sure I can have a look at it, though I think my PIDs are well tuned now. And as far as I understand PA also has trouble with over- and undercorrecting due to control authority on the aircraft. @Noir Thank You so much, I love to hear that! @rottielover Height means the altitude above ground the kOs unit is reading in the takeoff / landing configuration (so with gear extended, it's the altitude from the command module). You can get a good value by typing "print alt:radar." in the console and just add 0.5-3m to that numer, depending on your aircrafts size. Just keep in mind, too high value means that the plane will come in higher than it should (because the ap thinks it's lower than it actually is) while too low means that if you have a certain pitch angle at landing you might actually crash into the ground because the cockpit is higher up than the landinh gear. Yes, for thr reverse and landingabort, this is correct. Should probably make them switch-like. I will write up a more in depth-guide on how to use and how it works but that will take some time. I'm looking forward to further feedback! Quote Link to comment Share on other sites More sharing options...
shdwlrd Posted March 2, 2020 Share Posted March 2, 2020 3 hours ago, Kartoffelkuchen said: And as far as I understand PA also has trouble with over- and undercorrecting due to control authority on the aircraft. Nah, I use it all the time. The only times I've seen it flake out is when your plane is stalling and can't recover. (Which at that point, you shouldn't be using an auto-pilot anyways.) I do admit you do have to do some tuning for various conditions and craft though. BTW, can you tune the script to various different crafts? Quote Link to comment Share on other sites More sharing options...
aisored224 Posted March 16, 2020 Share Posted March 16, 2020 I'm super excited to use this mod, but when I enter the "run auto260.", it says it could not find that file. Did I install it incorrectly or something? Quote Link to comment Share on other sites More sharing options...
Cheesecake Posted March 16, 2020 Share Posted March 16, 2020 17 hours ago, aisored224 said: I'm super excited to use this mod, but when I enter the "run auto260.", it says it could not find that file. Did I install it incorrectly or something? Did you enter "switch to 0." first? Quote Link to comment Share on other sites More sharing options...
aisored224 Posted March 16, 2020 Share Posted March 16, 2020 4 hours ago, Cheesecake said: Did you enter "switch to 0." first? Yes, and that appears to work. Or, at least, it doesn't give me an error message. Quote Link to comment Share on other sites More sharing options...
Kartoffelkuchen Posted March 17, 2020 Author Share Posted March 17, 2020 (edited) 13 hours ago, aisored224 said: Yes, and that appears to work. Or, at least, it doesn't give me an error message. Is the file located inside your "KSP Main/Ships/Script" folder? You could also try to delete kOS and the script folder, reinstall kOS, fire up KSP once and then copy auto260.ks into the Script folder. Edited March 17, 2020 by Kartoffelkuchen Quote Link to comment Share on other sites More sharing options...
Kartoffelkuchen Posted March 19, 2020 Author Share Posted March 19, 2020 @shdwlrd The main difference between Pilot Assistant and this is that I made a kOS script, not an external plugin. This means that the script, due to kOS limitations, will run at a significantly lower rate than PA would do, due to kOS limited "processor speed". It can o be increased, but I didn't want to make that step for now. This runtime difference means that it is much harder for the script to compensate, from the time it sees that the aircraft is exceeding it's target pitch rate (for example) until it does something to correct for it, up to 0.2seconds pass by. That makes it quite complicated to properly tune a PID, since a LOT can happen between each "run" in .2s, especially with very sensitive aircrafts. I think I've done a fairly good job at implementing this for now, there's much to be streamlined and optimized, but I think results are good enough. For a real step-up, I will have to look at properly implementing this as a plugin though and my experiences with coding a plugin are marginal for now, so that will take some time. Quote Link to comment Share on other sites More sharing options...
shdwlrd Posted March 19, 2020 Share Posted March 19, 2020 47 minutes ago, Kartoffelkuchen said: @shdwlrd The main difference between Pilot Assistant and this is that I made a kOS script, not an external plugin. This means that the script, due to kOS limitations, will run at a significantly lower rate than PA would do, due to kOS limited "processor speed". It can o be increased, but I didn't want to make that step for now. This runtime difference means that it is much harder for the script to compensate, from the time it sees that the aircraft is exceeding it's target pitch rate (for example) until it does something to correct for it, up to 0.2seconds pass by. That makes it quite complicated to properly tune a PID, since a LOT can happen between each "run" in .2s, especially with very sensitive aircrafts. I think I've done a fairly good job at implementing this for now, there's much to be streamlined and optimized, but I think results are good enough. For a real step-up, I will have to look at properly implementing this as a plugin though and my experiences with coding a plugin are marginal for now, so that will take some time. I wasn't trying to compare a Kos script to a .DLL plugin. I was just curious if the could tune the PID's and max limits to different crafts. The planes I make are stable, but some are underpowered. They can't do high amounts of positive pitch for very long before stalling. I was planning to using it to send planes to a set of coordinates and have it land near by. That is kind of moot at the moment, I'm getting errors left and right with Kos. I haven't had time to scour the Kos threads for the wiki to see if it's a bad install or just user error. Quote Link to comment Share on other sites More sharing options...
Kartoffelkuchen Posted March 19, 2020 Author Share Posted March 19, 2020 (edited) 8 hours ago, shdwlrd said: I wasn't trying to compare a Kos script to a .DLL plugin. I was just curious if the could tune the PID's and max limits to different crafts. The planes I make are stable, but some are underpowered. They can't do high amounts of positive pitch for very long before stalling. I was planning to using it to send planes to a set of coordinates and have it land near by. That is kind of moot at the moment, I'm getting errors left and right with Kos. I haven't had time to scour the Kos threads for the wiki to see if it's a bad install or just user error. Yeah sure if you open the "Settings" Tab of the gui, you can adjust things like "max pitch, roll angle, min speed, max speed" there when in flight OR you can create a profile for your own plane in the database.ks script so you don't have to adjust things every time (see step 6 of how to use). Edited March 19, 2020 by Kartoffelkuchen Quote Link to comment Share on other sites More sharing options...
shdwlrd Posted March 22, 2020 Share Posted March 22, 2020 (edited) After reviewing how to use Kos, I actually got to test it. It works pretty good, but there are some oddities. I'll need to run the scenarios over again to see if it will preform the same. But I do have a couple suggestions. Add in holding patterns near the KSC and desert runway. That way you can guide planes into the pattern from anywhere and then do the landing approaches from there. Also, if there is missed landing, the ap can directly fly you back to the pattern to try again. Add a check see if the SAS is on and turn it off. If the SAS is on, the ap won't take control of the plane. Edited March 22, 2020 by shdwlrd adding info Quote Link to comment Share on other sites More sharing options...
Demcrew Posted April 14, 2020 Share Posted April 14, 2020 Great mod indeed! However, little planes and some others are usually failing to take off. Used a full stock setup, and 9 times on 10, it's just wobling on the launchway. Instead, I've ended up using this one : https://github.com/ozin370/Script maybe merging some features, could provide a great baby ? Quote Link to comment Share on other sites More sharing options...
HB Stratos Posted April 14, 2020 Share Posted April 14, 2020 (edited) Hey! I've been testing this 'mod' with FAR for a while now, and while it works for the basic features (I'm damm impressed by that, even havign a custom UI with kOS is crazy!) it does have a few problems: - While the oszilation dampening for the pitch control works I'm experienceing low frequency oszilations when using the autoland function. These oszialtions are so bad that the plane slams into the ocean or the landing lights before even reaching the runway. This seems to happen with planes of any size. - Landing speeds aren't customizable leading to stalls on most planes since FAR requires higher speeds. - the custom UI stays visible when switching to another vessel which leads to screen clutter when using multiple vessels. - Waypoint mode leads to my plane just diving into the ground - This is a kOS problem, the pilot doesn't work with SAS enabled, so it would be useful if SAS was automatically disabled when the pilot is on - This is just a suggestion but maybe add a boot scrip that can be selected in the hangar so the autopilot is ready to go when the vessel loads -Another suggestion, add a bank angle mode. I frequently need a plane to just fly in large circles and this would be really helpful Keep up the great work! -HB Edit: It would also be really cool to have a feature where the plane is placed at the intended touch-down spot with the right heading and then this info can be put into the autopilot to generate an approach path that can be later used to automatically land at this destination. Edit 2: I'm also facing a problem where the autopilot aborts every landing attempt at Island 09 Edit 3: It would be really nice if we could save plane profiles from in game. Edited April 18, 2020 by HB Stratos Quote Link to comment Share on other sites More sharing options...
SiRCrashaLot Posted June 16, 2020 Share Posted June 16, 2020 I've been noodling around with this.. It has a list of planes with parameters and you can add to it and it will save a planeparm file.. I will post the spaghetti code later.. Quote Link to comment Share on other sites More sharing options...
viscidpaladin Posted June 18, 2020 Share Posted June 18, 2020 @Kartoffelkuchen This has made career mode so much easier when do hose low atmosphere missions.... Many Thanks for writing this @Stone Blue Out of interest did you get this to work with waypoint manager? and how Quote Link to comment Share on other sites More sharing options...
viscidpaladin Posted June 18, 2020 Share Posted June 18, 2020 @Kartoffelkuchen What would cause this error to occur? I've created my own plane ...finally. When I launch the place I open the terminal and after typing switch to 0. this error occurs. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.