Space Engineers

Space Engineers

65 ratings
AI Mining Drone Script
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
13.426 KB
May 29, 2015 @ 3:06pm
Dec 21, 2016 @ 2:56pm
16 Change Notes ( view )

Subscribe to download
AI Mining Drone Script

Description
Automatic mining drone (using autopilot) (ENGLISH GAME VERSION ONLY - FOR NOW)
DerLaCroix && KaTsulChi
Version 1.4 (20.12.2016)

This code enables a mining drone to work (mostly) autonomous. (Or to grind a ship down - see the "manual" Discussion thread)

HOW DO I USE THIS:
1. Make sure you meet the hardware requirements (see "Full manual" discussion thread).
Ship will display error messages through the antenna if you lack something.
Make sure to #REINIT ship after an error message - it will not do anything until reinitialized.
2. Set AI_TIMER up to execute Run without parameters and then restart itself every second, don't start it, yet.
3. Go into the program editor - edit settings for ship size and thrust. Check code, Save and Exit.
4. Go into GPS tab and copy the target coords. (Make sure they are within 50m of the asteroid,
or the ship will simply return because it can't find it.)
4. Set up the command line. See commands below.
Good template: Example: #REINIT#TARGET GPS:Asteroid:-45.78:-71.36:0.38: #SMART#GARBAGEDUMPON#CARGOLIMIT:5
Ship is reinitialized for good measure, Initial mining place is set to "Asteroid", Smart mining activated,
Garbage dumping is on, Cargolimit set to 5%, which means the ship will return often.
If you want to drop cargo instead of docking, use the #THROWOUT parameter, as well.

5. Position ship so that it is in line with the docking port or at the position it should throw out cargo.
6. MAKE SURE THE REMOTE CONTROL IS SET TO "ONE WAY".
7. Start AI_TIMER (1 second interval).
8. Go do something else while it works, you can check on it via the antenna status displays from afar.

WHAT WILL IT DO?
After turning on, it will attempt to reverse into the home position and dock.
If docking fails, ship will display an error. (This means the docking was not possible or the ship wasn't lined up well.)

Once docked, it will unload all cargo, and recharge all batteries to at least 99% before moving out.
AI will then remember it's home dock for the future, undock from connector and move out for ~10 seconds at low speed.
It will remember some waypoints on the way out to be able to park correctly on returning.
Don't be alarmed if it doesn't immediately move out after declaring to do so - connectors "stick" sometimes. The drone AI will
increase forward thrust until it is let go, and only then start the departing countdown once it is moving.

(When using #THROWOUT to unload, it will simply remember the current position and orientation as home.)

After departing, it will use autopilot to fly to given #TARGET coordinates(Head out). Drone might fly strangely at first - this
is the Autopilot collision avoidance behaviour. Collision avoidance will be turned off at 100m from target, for it might not want
to get close to the target asteroid.

Once it arrived there, AI will attempt to find an asteroid there.(Within the 50m sensor range.)
It will then proceed to mine that asteroid - for a normal sized asteroid, it will go straight for the centre at first try, and then
mine around the edges at further passes. If the cargo is less than #CARGOLIMIT (default 50%) full after the asteroid is cleared,
it will turn around and make another pass.

Once it has contact to stone, it will steadily increase thrust to make sure it will push through the asteroid while weight increases.
Also, sometimes the drills "stick" to the asteroid. This will also be solved at some point by the steady thrust increase.
This has the side effect that the ship will occasionally stop while flying freely in mining mode (holes in asteroid of while
approching/after exiting) - speed limiting to soften impacts once we break through with high thrust cannot discern between these states.

Once the container is full enough, it will return to home coordinates. If #SMART mining is active, it will save the last exit point
as the next target to return after unloading.

AI will engage autopilot to return to the departing/arrival point, and then attempt to reverse into dock (or just arrive at throwout position.)
Don't be alarmed if the ship turns around during docking and heads 'back' - autopilot is a bit overzealous, sometimes.
It will get back on course, and if autopilot shuts of for some reason (it does that...) it will resume automatically.
If docking cannot be done for some reason (off course/connector off/damaged, etc), the drone will return to arrival point and
retry the docking approach.
You will notice that the drone is flying circles if that happens - just look what the issue is, pause timer, repair, restart timer.
Unless the damage makes a #reinit necessary, the drone will simply resume its work once the timer triggers, again.

After docking (or reaching throwout position) it will unload/charge (or dump cargo), and then head out again.

#RETURN command will cause the drone to return home and stay there (after clearing the asteroid, of course).
It will only head out again if given the #GO command.

If average battery charge drops below the #MINCHARGE threshold, it will also return to dock.

Status messages through the antenna will keep you informed.
Popular Discussions View All (2)
34
Jul 30, 2018 @ 10:22am
Bug reporting
Devlah
9
Oct 19, 2017 @ 8:08am
FULL DESCRIPTION/MANUAL
DerLaCroix
171 Comments
Omega1102 Apr 7, 2019 @ 1:53am 
I am working on a MiningDrone with Atmospheric Thrusters. The Script is showing some obsolet lines but they don't matter.
Now my problem is i have a Oxygen generator to fuel a Hydrogen Engine. The problem is that as long as ice is in the Oxygen generator the Drone Antenna shows "waiting for unloading cargo".
Dose someone know how to exclude the Oxygen generator from the Cargo?
Enigmus Sep 7, 2018 @ 12:05pm 
I would love to try out the updated version.
Devlah Aug 30, 2018 @ 10:19pm 
Thanks PirateRockabillyPunksInSpace! I remember spending hours at a time with DerLaCroix fine-tuning and working out bugs. It was a labor of love for me, as I really enjoy the automation aspect of this game. Please be sure to give us a link to the workshop when you eventually upload it. Meanwhile, I'll keep an eye out for any functional alternatives that pop up.
PirateRockabillyPunksInSpace Aug 29, 2018 @ 12:14am 
@Graywolf After a bit of poking I got this to work, I still need to ensure it returns, but I at least got it to go to an asteroid, mine it, and start returning. Follow the directions exactly (especially the front and rear bit; I used a control panel, and the rear connector for them) it seems to work fine; barring code adjustments that is.

Since it seems the original person is no longer maintaining this, I might upload it with my adjustments (that will likely also become unmaintained because I just wanted this to work, and dont want to do maintaining on it).

Things of note:
ITS EXTREMELY SLOW. It takes a while for it to take off and move forward during mining. Watch your thruster group, you'll see that its slowly increasing speed when it says 'heading out'. You can hackify this by bumping the thrust, after a bit it will finally decide to start moving on its own. Same goes for mining. I'm gonna see what I can do about that because 130N is too damn slow to mine reasonably
Graywolf Aug 25, 2018 @ 1:57am 
YEAH DOES NOT WORK :(
crafter360 Aug 1, 2018 @ 7:22pm 
Like is there a specific code that works best?
crafter360 Aug 1, 2018 @ 7:09pm 
What is the best set up of commands you have found?
Kam Solastor Jul 7, 2018 @ 12:59pm 
This seems to be broken at the moment. Throwing a few exceptions.
yankeevader Nov 29, 2017 @ 11:02pm 
Hmm. so I can get the ship to depart, it goes straight out for 2km stops, switches to heading out and slowly comes back to the ship. doesnt dock or anything just kinda floats lol.

any chance this will be getting updated or anyone know of a script that does what this one did?
supersquid2000 Oct 12, 2017 @ 5:26pm 
Man I wish this worked. It would be perfect for the world I'm playing right now.