Space Engineers

Space Engineers

Not enough ratings
Flight Controller - Basic
   
Award
Favorite
Favorited
Unfavorite
Tags: autopilot
File Size
Posted
Updated
453.580 KB
6 Jan, 2022 @ 9:14am
30 Jan, 2022 @ 5:39pm
27 Change Notes ( view )

Subscribe to download
Flight Controller - Basic

Description
This script is now "stable". The controllers will operate basically as they currently do. I may add some tweaks as necessary or requested and fix bugs. I may add additional commands using the current thrust and gyro controls.

A few things you should know:

Gravity Enables Dampeners [General]:

By default, when in gravity, this script keeps inertial dampeners on unless altitude, hold, or undamp mode are on. This can be annoying in certain cases, and you can either turn this off by changing it in the config (run any argument for the change to take effect), or pause it by turning off the programming block. Undamp mode will try to detect whether it is locked to a static grid, and will put thrust to idle if it is. See the next paragraph for more info.

Landing Gear Check [Undamp]

By default, when undamp mode is running, it will check for any locked magnetic plates or landing gear on the grids within its scope. The landing gear of another ship locked to the grid won't count. If it detects any it will set thrust to idle if the speed is absolute zero. This means a ship that is carrying something with a magnetic plate or landing gear never truly stops, since as soon as it does the thrust goes to idle and it starts falling. However, my 100,000 KG test ship barely moved with this check on, and I'm rarely carrying anything where I'm not paying full attention to what's going on. However, if this is a problem, you can change it in the config, and then restart undamp mode.

Hold Takes Precedent [Hold]

By default, turning on altitude mode will turn off and disable hold mode to prevent them from conflicting or the pilot forgetting and having accidents. Roller mode continues accepting inputs, including countering direction of travel, but does not add turn inputs from the mouse, since hold mode immediately turns it back.

Setting "Hold Takes Precedent=true" will cause altitude mode to be turned off and disabled when hold mode is on, and roller mode to pause.

Reset On Load [General]

By default, the programmable block will reset the thrusters and gyros to enabled and not overriden immediately after being compiled. This helps catch ships that are falling because the programmable block somehow stopped working, since you only need to hit recompile to turn off the overrides. However, if you don't like this feature, you can turn it off in the config.

Trailing content in CustomData

This script uses MyIni, so any lines following a line with three dashes (exactly three and no spaces) is preserved. You can use this to add Automatic LCD info to the programmable block screens.

Overview

This is best for heavy ships which rely on their bottom thrusters. It uses the thrusters in both directions and adjusts them according to the needed change in speed. It does not go to full thrust immediately like the in-game autopilot, but scales according to the speed difference.This makes the response both quick and accurate, while saving fuel. In addition, the distance modes use the quadratic equation to calculate how far away to start slowing down.

cruise - Drive the ship forward at a set speed using the minimum required thrust to maintain speed. As it uses weight and thrust calculations it can hold a speed very accurately, down to 0.1 m/s.

altitude - Hold a specific altitude using thrust override. Also calculates rate of ascent based on available thrust so it doesn't overshoot. Can turn off inertial damper if desired.

roller - Basically hover mode from flight assist, but I added the ability to turn the ship when there are yaw inputs. If altitude module is active and not in its holding state it will also freeglide. I also added several modes for movement inputs.

hold - uses thrust and gyros to keep the ship pointed in one direction and only moving along that axis. Speed can be set with the cruise command or manually controlled with movement keys, and inertial damper can be turned off.

undamp - The "Better (lack of) Dampeners" script, with a few minor improvements, such as configuring rates (so you don't bump your head), restricting the scope of control (so your entire base or mother ship doesn't get overridden). I also fixed the idle thrust bug. The undamp command will only affect axis that are not in use by another command, similar to how the stock dampeners work. I did not use all cockpits as the original script did but rather stuck with my reference controller concept.

In case you're not familiar with that script, it makes it so when you hit Z to turn off dampeners, you just coast instead of dropping like a rock. The vector math in this script is amazing and took me a couple weeks to figure out. Just make sure this mode is actually on before you turn off your dampeners.

There are additional commands listed in the readme comment at the top of the script which are used to do things like reset the saved controller or estop the script.

This script didn't come from nowhere. It's based on other scripts that did one thing very well or got part of the way to a solution but needed some improvement.

Kudos to "Blarg's Ascent Cruise Control" for showing me the anatomy of a script and for giving me an initial problem to solve to get me into the code. It's not very accurate with its speed control and doesn't do braking thrust so I dived into the code to make it better, and this is the result.

Blarg's script: https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/1316048908

Also thanks to "Flight Assist" for the very accurate and steady gyro roll calculation. I added this one in first and spent a couple weeks breaking it down to understand the roll calculations. It got me started on the basics of vector math and was simple enough that I was able to quickly add additional features to it.

Flight Assist: https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/557293234

The "Better (lack of) Dampeners" is simple and elegant and has some very interesting concepts related to thrust control. It taught me a lot about vector math, and gave me a few ideas for improving the other parts of this script. I hope to use this concept of thrust control with future projects.

Better Dampeners: https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/1229238908
1 Comments
GEEKA 17 May, 2023 @ 2:05am 
turning on altitude mode causes ESTOP exception, any guesses?