Space Engineers

Space Engineers

301 vurderinger
Gravity Aligner
3
2
   
Pris
Føj til foretrukne
Gjort til foretrukken
Fjern som foretrukken
Filstørrelse:
Offentliggjort:
Opdateret:
432.288 KB
2. dec. 2015 kl. 21:38
29. apr. kl. 20:50
27 ændringsbemærkninger ( vis )

Abonner for at downloade
Gravity Aligner

I 1 samling af p3st|cIdE
Scripts
13 genstande
Beskrivelse
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 cockpit (to discover gravity vector and vehicle orientation; a remote control block will work if manual steering isn't required), 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. "toggle" is convenient for toolbar binding.

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 (RollAngleClipDegrees, PitchAngleClipDegrees etc..) in the CustomData for your ship, then run the "load" command to reload your changes. 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.

parameters may be set by Run with e.g. "PitchOffsetDegrees=90" or commands combined using pipe ch, for convenient toolbar access!

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. Group a cockpit, not a RC.

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.

Dislike cockpit LCD? comment out // line of code: Surfs.Add(ctrl.GetSurface(1));
or is it: chart.Show(ctrlb.GetSurface(1));

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.
1.031 kommentarer
p3st|cIdE  [ophavsmand] 24. sep. kl. 9:32 
right on. fork away. lmk if you have specific questions.
Destormizer 23. sep. kl. 14:33 
@p3st|cIdE It definitely is :D, I'm a budding programmer and I appreciated the structural finesse. It's just a shame that I get lost with the formulas and would need to study everything when I have time... I'll keep your code aside for future inspiration!
p3st|cIdE  [ophavsmand] 23. sep. kl. 9:11 
@Destormer that code architecture is what I came up with to allow me to keep each part in its own C# code file, verify them in Visual Studio, then drop them all in together to make the final composited script for the in-game PB, and re-use code between scripts. It worked out fairly ok, all things considered. Seems like over-engineering at times. :steamfacepalm:
p3st|cIdE  [ophavsmand] 23. sep. kl. 9:08 
@Apologies, @Walter tyvm
@Destormer I considered a script that matched,maintained at given position/orientation, it wouldn't be that hard to adapt my framework to do such a thing, I just have no time for it. Try my Full Control script, it might be closer to what you desire.
[BRE] Walter "Blanc" 22. sep. kl. 1:19 
Ping is around 100, i actually made it more stable with only using one gyro on the ship, its very usefull now and makes my large grid miner not tilt over! Great work on the script :)
Destormizer 20. sep. kl. 4:48 
Hi, I think your script is one of the best out there, and it’s structured like it was written by a true professional! I was trying to implement a couple of things, but unfortunately, I don’t have the necessary skills. In theory, I need a simple function that aligns the ship to a specific Yaw/Pitch/Roll that I provide (for example, I approach another ship and align with it, obviously after getting the correct Yaw/Pitch/Roll of that ship). If you ever have time to work on this implementation, I’d also love to ask if you could make the ship move to a specific x,y,z point, as the autopilot’s navigation isn’t very precise at all! It would be amazing if you could manage even just one of these functions :). Either way, thanks so much for the script!
Apologies 16. sep. kl. 15:29 
Ah thank you, I'm trying to nail down why my player made missiles are turning to the ground and this at least rules out your script, an amazing script, ty!
p3st|cIdE  [ophavsmand] 16. sep. kl. 13:40 
@Apologies that's what the Aligner terminal group is for
Apologies 15. sep. kl. 20:44 
Is there a way to ignore certain gyros?
p3st|cIdE  [ophavsmand] 15. sep. kl. 16:18 
oh, that's probably just lag related then. Yeah, that makes sense. your inputs have lag, and the response when the ship stops turning also gets lagged before your client sees it. The actual driving is happening on the server, where the script is running. What's the ping, out of curiousity?