Space Engineers

Space Engineers

275 ratings
Gravity Aligner
3
2
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
60.782 KB
2 Dec, 2015 @ 9:38pm
29 Apr, 2019 @ 10:28am
25 Change Notes ( view )

Subscribe to download
Gravity Aligner

In 1 collection by p3st|cIdE
Scripts
13 items
Description
A stripped down version of Hover Altitude Aligner!

or a bells-and-whistles version of Leveller?! lol

Are you tired of crashing ships on planets because you weren't paying attention to the alignment as you cruised around and slewed into the ground? This is the script for you! It automatically aligns a ship with the local gravity using gyro overrides. When it detects it's going out of alignment, brings it back into alignment, and shuts off the overrides. It can effectively make a ship yaw-only, or just limit the angle of how much roll and pitch is allowed relative to flat orientation. It effectively turns a spacecraft into an imprecise orbiter. Folks have even been abusing it to keep mechs from falling over!

The main thing it does is prevent a vehicle from flipping over or even tilting too much. I made it because some of my ships were never designed to fly sideways or upside down and will definitely crash when put into those alignments, I got tired of having to manually orient the ship constantly to correct accumulated roll and REALLY got tired of crashing expensive space ships due to negligent piloting.

All it needs is a programmable block (for the script), a remote control or cockpit (to discover gravity vector and vehicle orientation), some gyros (any orientation), and optional text panel(s) for diagnostic info. Ensure all blocks have access to each other/same owner. Then make a new group in the terminal called "Aligner" and include ALL those blocks. Then Run the programmable block with argument "go" and watch it line up. Just try to flip the ship over, I dare you!

To disable the aligner, just run it with an argument of "stop" (case insensitive). It will ignore further runs for .1 seconds just in case and turn off the text display. I like using the Up Arrow and OffLine textures!

The text panel diagnostics will tell you if you're missing a block or some other critical setup error. So far it outputs to the public text the present ship pitch and roll angle in degrees, blinks red when it's aligning, has pretty angle graphs.
Angle graphs go best on corner panels, put into LCD public title "pitch", "yaw", "roll", "steer", "logo", "gravity", "update", a few others slip my mind...

I find it easiest to steer with the keyboard arrow keys. Hey, it even supports the new player input access for true gravity-relative yaw control!

You will definitely want to tune the parameters in the CustomData for your ship, but do be careful and make a backup copy of your ship first, I can take no responsibility if you manage to make the thing freak out and crash by tweaking wrong parameters, but the defaults should do ok for most uses. If you need help tuning the parameters, let me know. Often the settings will get cleared or reset mysteriously, so once you find settings you like, it's best to edit the script to make those the new defaults.

It only uses blocks in the group, so you can exclude some gyros for other purposes.

If you would like to see this script working in-game without having to build a ship and set it up, I have some ship blueprints uploaded that already have it installed. Try VixS. Can find more by browsing my recent Workshop submissions. Some old versions are Drilldown, or Flitter, both good examples without mods. Also Overlook scout ship. Some may be using old versions of the script though; my earliest attempts aren't as nice with the response at the limits and did block setup differently, can't handle arbitrary remote orientations. Some include airlock logic!

It's a fairly cpu-friendly script since even though it gets run every frame, most of the script can be skipped if enough time hasn't elapsed and the block searching initialization only runs every 5 seconds and main control logic presently only runs 30x per second by default which is plenty good enough for most ships. Try reducing updatefrequency and disable the text panel to reduce server load on multiplayer.

NOTE: it still depends on inertial dampeners and upward thrusters to keep the vehicle in the air. AND you can totally still crash the ship! It merely assists maintaining alignment.

TROUBLESHOOTING

There's no shortage of problems with a script like this which basically remote-controls the ship.

Ensure block ownership. Permission issues can prevent scripts from manipulating blocks etc. It does check for this now. This is the most common source of error.

If it doesn't seem to be doing anything, did you give it the "go" command? Check the programmable block to see if it threw an exception.. If there's no text panel more exceptions might happen. Try with lcd first, you can remove when it works.

If it won't correct at all, make sure you can actually steer the ship manually (have enough active gyros to move it?)
If you see no debug output on your text panel, make sure you own it and then set to show public text. Is it in the group?

If it seems too stiff and jerky and won't let you steer, try loosening up the angle limits or speed factor in the script parameters.

If it takes too long to correct, turn up the AlignAngularResponseP or increase the OrientPredict time.

If it never actually gets to the limit and keeps correcting forever, preventing you from steering, try increasing AlignAngularResponseP.

If it overcorrects too far past the boundary limit, or oscillates a lot, won't settle into a small limit window, try increasing OrientPredict time or decreasing AlignAngularResponseP, or increasing AlignAngularResponseD.

Try turning up AlignAngularResponseD especially if it's a huge ship, to prevent gaining excessive velocity.

If you get CLR Detected Invalid Program errors, try installing the latest .NET runtime (4.6.1 reportedly works!) I still haven't figured out the cause.

KNOWN BUGS

Can reset CustomData config settings to defaults sometimes, on some ship designs, on server load - make a backup!

LCD panels often show the wrong chart; chart configuration doesn't work right anymore.
929 Comments
p3st|cIdE  [author] 28 Aug @ 8:25pm 
@bigb3321 you can try, but it's designed to prevent roll. Try loosening the roll and pitch angle limits in custom data, can use it as an anti-flip failsafe.
bigb3321 28 Aug @ 5:52pm 
i was wondering if this could work with a vtol I've been working on a vtol that uses a tilt rotor and I've been trying to find something to help it roll and not over roll it's self but just enough to keep a angle to go on one side or the other for like a minute or something like that?
p3st|cIdE  [author] 23 Jun @ 9:28pm 
@Nikodga there's separate limits for pitch and roll in the custom data
[PTH] Nikodga 23 Jun @ 7:44pm 
any way to choose which axises it aligns? Like make it only control roll but not pitch
p3st|cIdE  [author] 14 Jun @ 2:57pm 
@Blacky Watchy, be sure to check gyrolimitrpm, gyrostoppability, steeringsensitivity, and all the alignangularresponse* variables in custom data. Maybe try higher updatefrequency.
@Gat glad you sorted it. why didn't I get a notification for this until now?
Gat 26 May @ 4:49am 
Never mind I fixed it. When I set it up originally I used all my gyros which didn't work too well so I used a smaller group of gyros. Anyways I didn't reset the settings on the no longer used gyros so they ended up having "Override controls" enabled and I just needed to disable that.

Cheers for the amazing script :D
Gat 26 May @ 4:44am 
P.S Works great with the real orbits mod
Gat 26 May @ 4:44am 
When I disable the aligner with the "stop" command it just seems to disable all my gyros, is this a feature or did I mess something up?
Blacky Watchy 22 May @ 2:36am 
aligner works for me, dunno what has vinik so angry... now... it would be great if gyros were used up to their 100% they really turn quite slow and have more problems than ksh's AI to keep things stable
p3st|cIdE  [author] 21 May @ 1:25pm 
@Mad_Hat try editing customdata then using "load" command

@Vinik did Keen break things again? I'll try to get some playtime on Signals soon and check my scripts