Space Engineers – Planetary Autopilot Manager Script Setup & Use

Space Engineers – Planetary Autopilot Manager Script Setup & Use 1 - steamlists.com
Space Engineers – Planetary Autopilot Manager Script Setup & Use 1 - steamlists.com

This guide describes how to setup and use my Planetary Autopilot Manager programmable block script.
 
 

Special Thanks

Special thanks to the following who helped make this script possible:
 

  • Whiplash141 – For numerous utility functions for gyroscope alignment and vector math, provided freely and even took out some of his own time to give assistance to me to help me through some issues I was having.
  • Malware – For the ingame scripting visual studio extension which makes it 100x easier to develop these scripts

 
 
 

Basic Setup / Ship Requirements

Ship Requirements
 

  • A remote control block facing the desired forward direction
  • Atleast 1 thruster in the forward, backward, and upward direction relative to the remote control block
  • Atleast 1 gyroscope (can be placed in any way)
  • Atleast 1 camera on the front of the ship and the top orientated upwards, relative to the remote control block. [Multiple cameras supported, recommend placing them close together]
  • Atleast 1 camera on the bottom of the ship and the top orientated forwards, relative to the remote control block [Multiple cameras supported, recommend placing them close together]

 
Name the following blocks
 

  • Name the remote control block to match the ‘nameOfRemoteControl’ variable, which is “Remote Control” by default.
  • Put all forward cameras into a group and make the group name match the ‘nameOfHorizontalCameraGroup’ variable, which is “PA Forward Cams” by default.
  • Put all downward cameras into a group and make the group name match the ‘nameOfVerticalCameraGroup’ variable, which is “PA Down Cams” by default.

 
These variables can be changed in code to match your preferences if you desire.
 
 
 

How To Use

Once setup is complete and you can compile with no errors, here are the commands you can perform.
 
 
All commands take the following format:
 
 
<COMMAND,PARAMETER#1,PARAMETER#2,etc…>
 
 
GOTO
 

  • Description – Tells the autopilot to move to the specified location
  • Command – GOTO
  • Parameter #1 – The waypoint info of the target destination
  • Example – “GOTO,GPS:KiwiNinja99 #1:55985.37:16475.92:17445.72:”
  • Note – When copying waypoint info from GPS menu, remove the color info at the end “#FFFFFFFF”, see example for working input.

 
STOP
 

  • Description – stops and resets the autopilot
  • Command – STOP

 
TARGET_ELEVATION
 

  • Description – sets the target elevation to maintain during flight.
  • Command – TARGET_ELEVATION
  • Parameter #1 – The elevation to maintain, in meters (m).
  • Example – “TARGET_ELEVATION,1000”
  • Note – Elevation measurement is determined by the ELEVATION_TYPE command.
  • Note – Higher is typically safer & less likely to crash

 
ELEVATION_TYPE
 

  • Description – Determines how the current elevation is measured (from either planet sealevel or planet surface)
  • Command – ELEVATION_TYPE
  • Parameter #1 – “SEALEVEL” or “SURFACE”
  • Example – “ELEVATION_TYPE,SEALEVEL”

 
MAX_SPEED
 

  • Description – Sets the max speed for the autopilot
  • Command – MAX_SPEED
  • Parameter #1 – the max speed to be set
  • Example – “MAX_SPEED,75”
  • Note – Slower is typically safer, but has been tested to be moderately safe at 100m/s if elevation is sufficient (500m+)

 
 
 

Configuration & Tips

Some variables within the PlanetaryAutopilotManager class can be changed. Some are interfaceable with their own getter/setter functions, others it would probably make sense to just go in and change them once and be done with. I’ll go other the pros and cons of the range of values for each variable here that I’ve discovered during testing.
 
 
I highly recommend testing your ships with the various configuration options in a creative world before using in a survival world.
 
 
maxSpeed
 

  • High Speeds are more dangerous as the autopilot can perform less scans over time, meaning its more likely to miss an obstacle it could be approaching. However if you insist on speed, I recommend putting multiple cameras in each camera group (forward and down) to compensate.
  • Recommended Range: For just 1 camera in each group, 50-75m/s. Add more cameras for more speed.

 
targetElevation
 

  • Recommended range (300m-1000m)
  • Higher values mean your ship is less likely to encounter a mountain or other obstruction, which means less chance of a crash.

 
targetElevationTolerance
 

  • Recommended Range (10m-50m)
  • How far you’ll accept a vertical displacement from the targetElevation, so that no correction takes place. Having a sizeable value for this means your ship won’t be trying to correct itself so often, and will just cruise along, saving power along the way (especially if elevationType is set to Surface).

 
scanningDistanceForwardModifier
 

  • The variable modifies the range the forward cameras will scan to look for obstacles, and will start flying upward (but still move forward) to avoid them.
  • Higher values mean longer heads up times, but will scan less often. And vise versa for lower values.
  • Must be higher than cruisingDistanceModifier
  • Recommended Range (1.5f-2.5f)

 
scanningDistanceDownwardModifier
 

  • The variable modifies the range the downward cameras will scan to look for obstacles, and will start flying upward (but still move forward) to avoid them.
  • Higher values mean longer heads up times, but will scan less often. And vise versa for lower values.
  • Must be higher than cruisingDistanceModifier
  • Recommended Range (1.5f-2.5f)

 
cruisingDistanceModifier
 

  • This variable modifies the range at which the ship will come to a complete stop horizontally and fly up if a detected obstacle is too close.
  • Higher values mean more safety, but too high may look a bit silly.
  • Should be at least 0.3f less than scanningDistanceForwardModifier and must be greater than 1.1f
  • Recommend range (1.2f-1.5f)

 
nameOfRemoteControl
 
nameOfHorizontalCameraGroup
 
nameOfVerticalCameraGroup

 

  • These are the names of the remote control and camera groups the program will search for, feel free to change these if you don’t like the default names.

 
elevationType
 

  • This variable determines whether the current elevation is measured from the planet’s sea-level or from the surface.
  • This can be changed through the “SetElevationType” function or through manually setting it like the other variables here.
  • Sea-level may provide a smoother, less bumpy flight (which will save power), but you will have to find a good value that works for you
  • Surface is probably better for working right off the bat if you’re to lazy to find a good value for sea-level.

 
Number of Cameras
 

  • The number of cameras in your forward and downward camera groups will increase the amount of scans and therefore safety of your ship.
  • However, the camera’s raycast that is uses to scan is quite computing resource intensive, and if you’re on a multiplayer server, your server admin may not like you very much. If this is a problem, I recommend using as little cameras as possible (some of my smaller ships work just fine with just 1 camera in each camera group)

 
 
 

Scripting Interface

This program was originally designed to go hand-in-hand with another script I had planned, but I decided it would be best to make this first to have a solid base to work from. Hence, maybe it will work good for some of the more creative bunch of you.
 
 
The default program (mostly in the main loop) should serve as a good example to show you how to interface with the program successfully.
 
 
In order to successfully work, the program requires
 

  • A ‘MyIni ini = new MyIni();’ declared as a field
  • The PlanetaryAutopilotManager.Init(GridTerminalSystem, this, ref ini) in the program’s constructor “Program() { }”.
  • The PlanetaryAutopilotManager.Save(ref ini) in the program’s save function “public void Save() { }”
  • The PlanetaryAutopilotManager.Update(this, updateSource) in the program’s main function “public void Main(string argument, UpdateType updateSource)”

 
As long as those requirements are met, the program should be working. From here you can interface with it by calling these functions:
 
 
*note* Anywhere parameters named “MyGridProgram gp” means you can just pass in program itself in by using “this”.
 
 
PlanetaryAutopilotManager.SetDestination(Vector3D coords, MyGridProgram gp)
 

  • Sets the target destination and starts travelling to the destination.

 
PlanetaryAutopilotManager.Stop(MyGridProgram gp)
 

  • Stops the ship, restores all thrusters and gyroscopes to manual control.

 
PlanetaryAutopilotManager.SetTargetElevation(float targetElevation)
 

  • Sets the target elevation the ship will try to match during its flight.

 
PlanetaryAutopilotManager.SetElevationType(MyPlanetElevation elevationType)
 

  • Sets how the current elevation is measured
  • MyPlanetElevation.Sealevel – measures from the planet’s sea-level
  • MyPlanetElevation.Surface – measures from the surface directly below the ship

 
PlanetaryAutopilotManager.SetMaxSpeed(float maxSpeed)
 

  • Sets the maximum speed the ship will travel
  • Don’t set higher than the server allows

 
How to check if the ship has completed it’s flight
 
There are two ways you can do this
 

  • Check if the PlanetaryAutopilotManager.destinationIsSet variable is False [if (!PlanetaryAutopilotManager.destinationIsSet)].
  • Subscribe to the PlanetaryAutopilotManager.FlightCompleted event (see the OnFlightCompletion() function as an example)

 
 
 

Miscellaneous

The guide was created by a slightly sleep deprived me, any typos or anything not clear, feel free to let me know in the comments below.
 
 
Link to script here: https://steamcommunity.com/sharedfiles/filedetails/?id=2782754267 – [steamcommunity.com] 
 
 

Written by KiwiNinja99

 
 
I hope you enjoy the Guide we share about Space Engineers – Planetary Autopilot Manager Script Setup & Use; if you think we forget to add or we should add more information, please let us know via commenting below! See you soon!
 
 


Be the first to comment

Leave a Reply

Your email address will not be published.


*