Space Engineers

Space Engineers

91 ratings
[PAM]-E.L.A. - Path Auto Miner Exclusive Local Area
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
8.812 KB
8 Nov, 2019 @ 3:04pm
8 Nov, 2019 @ 3:53pm
2 Change Notes ( view )

Subscribe to download
[PAM]-E.L.A. - Path Auto Miner Exclusive Local Area

Description
Version
1.0.0 (2019-11-08)
- Initial release
- Fully functional as intended

Motivation
Having found the great [PAM] script by Keks, you'll probably end up controlling a lot of drones and let them do all the dirty mining work. But a growing fleet needs more and more planning. The drone paths must not cross, otherwise they will crash into each other. Although this is pretty unlikely, with greater fleet and having them running in the background all the time, this will eventually happen. In open space crossings can be avoided, but you have to remember all the paths and plan well ahead. In a narrow hangar situation crossing can probably not be avoided and an additional solution is needed. This is why the idea of an additional utility script was born.

Idea
The basic idea for this utility script is using already existing PAM functionality to do some more automated drone management. There already is a PAM-Controller that can send commands to multiple drones from a central control station or via programmable block (PB) arguments. Now PAM-ELA will send commands to PAM-Controller via it's PB, the controller then sends those commands via antenna to the drones.
The hangar is considered as an exlusive resource, where only one drone is allowed to move in and all other drones have to stop and wait for the first to leave. Leaving can either mean flying away or dock to a connector. The area itself is defined by sensors, that can deliver the information who is inside.

Requiremens
- You need the PAM script
- One PAM-Controller is needed to command drones (see PAM guide for setup).
- All drones must use PAM and broadcast to that controller.
- Drones' broadcast-name must equal the grid-name.
- A sensor is needed to detect drones entering the exclusive area.

Setup
Get the [PAM]-E.L.A. script and install it to a PB on your station (or where your hangar is).

You need a PAM-Controller running in its own PB on the same station.
If your PAM-Controller has the default tag [PAM-Controller], PAM-ELA will find it. Otherwise (if you have multiple PAM-Controllers managing separate fleets) set your custom tag in the head section of the PAM-ELA script:
> const string controllerTag = "[PAM-Controller]";

If you have multiple PAM-Controllers for separate fleets and each has its own hangar you will need one PAM-ELA per PAM-Controller and use unique tags so they can be assigned.
If you just have multiple hangars for one large fleet, you'll need one PAM-Controller only, but one PAM-ELA per hangar.

Set up a sensor in your hangar. The area should cover the hangar and some outside area. If your hangar has doors, you probably have such a sensor already which can be used for PAM-ELA. Tag this sensor with [PAM-ELA] or a custom tag defined in the script:
> const string sensorTag = "[PAM-ELA]";

If your hangar is larger than a sensor can cover, you just can add more sensors. The logic combines them to one large exclusive area. The additional ones probably don't run the hangar door.
The sensor must be configured to detect ships (size depends on your drones) but NOT detect subgrids. A drone will be considered a subgrid after connection, and the sensor should consider the area to be free then.

The list of requests to enter the area can be shown on any LCD panel tagged with [PAM-ELA].
Using indexed text sufaces like on the PB or in a cockpit is also possible, the tag therefor has to look like [PAM-ELA:#] with # being the text surface index starting at 1.
For a custom tag change this line in the script header:
> const string panelTag = "[PAM-ELA]";

There is always only one active drone allowed to move in the exclusive area. Other drones will be sent the STOP command via the PAM-Controller. When a stopped drone becomes top of the reuqest list, it will be activated via the CONT command. If it does not react and free the area (maybe because the job was done), after <resendContAfter> minutes it will be sent CONT again every minute. After <sendHomeAfter> minutes however, it will be sent the HOMEPOS command, finally clearing the area. You can confugure this in these lines:
> const int resendContAfter = 1; // minutes
> const int sendHomeAfter = 3; // minutes

PAM-ELA will keep the script usage at a minimum. This includes not scanning the grid for new tagged blocks every now and then. If you change anything PAM-ELA related just recompile the script in its PB.

Please check if your drones are correctly configured. Check your PAM-Controller's PB for its custom data settings and note the <Broadcast_Channel> name. Now check every drone's PB (running PAM) for its custom data. Make sure broadcasting is enabled and the channel name is the same (basic PAM-Controller setup so far, for any help on this refer to the PAM guide). Now additionally for PAM-ELA to run properly, in the drone's PB custom data, you also have to check that the <Ship_Name> setting matches the drone's grid name. The sensor only detects the grid name, but the PAM-Controller only sends commands to this custom name, so they have to match.
> Enable_Broadcast=true
> Ship_Name=<please match this to the drone grid name>
> Broadcast_Channel=#<please match this to the PAM-Controller channel>

When you record the paths for your drones keep in mind that PAM-ELA now allows for crossings inside the exlusive area. But still every drone needs its own space where it enters or leaves the area. If the area is occupied it will stop and wait there and you don't want other approaching drones to run into it.

Limitations
PAM offers the commands STOP to halt and CONT to resume drones. But CONT does not exactly mean to continue what the drone was just doing at STOP. If the drone was sent home having its job not completed, it may get stopped by PAM-ELA and then send the CONT command to resume. Instead of the expected moving home CONT does tell the drone to go to job area and resume mining.
If the drone did move home because its job was done, it has nothing to do on CONT and so will just hang around. To handle this, PAM-ELA notices when a drone takes too long to free the area and send CONT again and after 3 minutes send HOMEPOS. So this situation is solved eventually but it may take some time.
It does work if the drone came home for a reason like being full or having low energy, it will notice that condition on CONT and temporarily move home then.
Popular Discussions View All (1)
2
20 Sep, 2020 @ 8:13am
Ship Slamming in to ship With [PAM]-E.L.A.
Allucination
49 Comments
MrFox 22 Mar, 2022 @ 12:33am 
The first issue just kinda fixed its self, we let them do there thing vs. tring to fix it. after about 5 tires its all good. Se issues i guess?
As for the 2nd one, the sensors (2) have sub grids turned off. We did setup a drone replacer on a large grid rotor with a small grid head. For some reason the small rotor head when a ship is built on it is seen as a detached grid and not a sub-grid. even if its attached. SE issue im guessing? it took us some time to figure it out.
As for the Whitelist, We have a parking lot thats on the other side of the zone some of them are a bit long and keep it triggered, so he have to park them outside our safe zone
Mythos  [author] 21 Mar, 2022 @ 1:22pm 
@Woodzy I don't know if I fully understand your problem and the need for a whitelist. Are there grids within the sensor area, that aren't controlled by PAM? And you can't exclude them via sensor settings like small ships only, no subgrids? Don't make the area too big, should just cover the hangar and just enough space to enter and exit.
Mythos  [author] 21 Mar, 2022 @ 1:17pm 
@Woodzy Your description about drones going back to mining site is a well known issue and mentioned in the description. This only happens when you manually called back the drones. When PAM then gets the CONT command, they don't continue coming home, they continue their mining job instead. This doesn't happen if PAm had a reason to come back, being full or without fuel. To change that we'd need a different command in PAM, but changing PAM is out of scope here.
MrFox 21 Mar, 2022 @ 10:14am 
Can you add an option to have a whitelist in the custom data?
We have some grids we cant find in the zone
MrFox 20 Mar, 2022 @ 4:42pm 
Minor issue. When drones are waiting and one dock. when that docks, and it tells the next one to keep going they go back to the mining sight vs. the home dock
Mythos  [author] 4 Mar, 2022 @ 11:18am 
@el nap0ne: Your suggestion of a script running on each drone seems to be independent of PAM, so not in focus of this script and a different use case. I don't know if you really need a script for this. You might try to set up a done-sensor, so that it discovers other drones (small ships) only. Set up actions so that on entering the sensor you put the drone's PAM PB with argument STOP, and on leaving the sensor you put the PAM PB with argument CONT... That might almost do the trick.
Mythos  [author] 4 Mar, 2022 @ 11:18am 
Hi @el nap0ne, my old friend :se:

Yes you are right, there still is the possibility that drones crash into each other on the border of the "exclusive area". This script is meant as an extension to PAM for users who already use PAM alot and are quite familiar with it.

When you have a whole fleet managed by PAM already, then you must plan all their paths to avoid intersections as much as possible. PAM-ELA only helps at that narrow hangar situation, where intersections are not avoidable. The idea is, that the sensor area covers all the intersections and your planning covers the border so that there each drone has an individual spot to transit.
el nap0ne 4 Mar, 2022 @ 7:24am 
what i wonder: - the drones could still crash into eachother right? - if they come from same direction and stop at the sensor field - so wouldnt it be possible to reverse this mechanic? - like ur giving the drones the sensor field? so they detect closeby ships / structures aswell? - and then the docking scripts are related to this? - or will this be to much "scriptload" - would love a drone acting like real or in this case fake KI ;D
el nap0ne 4 Mar, 2022 @ 7:15am 
hey Mythos - this is so sick - i watched the video a couple times allready - like a real space movie ;)
Mythos  [author] 10 Feb, 2021 @ 2:15pm 
@The Lapis Fox There is no chance for the code to know if a detected subgrid is a ship or a part of a multigrid base. That is technically the same thing.