ManuelSchmitz / SCAM

Simple Concurrent Adaptive Min3r (Space Engineers)
4 stars 2 forks source link

Getting Started

Here is a beginner's tutorial.

Updating from v0.9.68

  1. Recall all agents.
  2. Remove the following commands from your startup scripts (Custom Data of the PBs). They are not supported any more,
    • command:set-value:depth-limit - Now set on the LCD screen menu.
    • command:set-value:skip-depth - Now set on the LCD screen menu.
    • command:set-role - Now determined by the script. (Separate scripts for agent and dispatcher.)
    • command:set-value:max-generations - Now set on the LCD screen menu.
    • command:static-dock - Has been removed along with the Lone role.
    • command:static-dock-gps - Has been removed along with the Lone role.
    • command:set-value:getAbove-altitude (Agent) - Value now controlled centrally by the dispatcher, and distributed to the agents automatically.
    • command:set-value:getAbove-altitude (Dispatcher) - Now set on the LCD screen menu.
    • command:set-value:echelon-offset - Now set on the LCD screen menu.
  3. Copy the dispatcher script to the dispatcher and recompile.
  4. Copy the agent script to all agents and recompile.

Definitions

Task

A task is a collection of jobs (shafts), and is usually processed by a dispatcher.

Job

A job is shaft, processed by an individual agent. The dispatcher will usually assign a job to the individual agents.

Task Creation

  1. Recall all agents, if a task is being processed. Any existing task will be overwritten by the new one.
  2. Designate the location by one of the following methods:
    • TODO
  3. The dispatcher will create the task using the following parameters.
    • TODO: shaft radius, agent group, location & orientation, #generations, max. depth, adaptive, skip-depth
  4. The dispatcher will start dispatching jobs to the agents.

Job Processing

An agent will drill down in three phases:

  1. To the skip-depth, without taking on stone/ore/ice. (*)
  2. Further to least-depth, picking up stone/ore/ice.
  3. On to depth-limit, but only if there is ore or ice.

(*) The agent actually takes on a some stone/ore/ice, but only into the inventory of the drills. These are disconnected from the conveyor system.

shaft schematic

Note that depth-limit is stronger than least-depth, e.g. when the latter is greater than the former, the agent will stop at depth-limit.

The following subsections contain parameter sets for typical mining tasks.

Surface Ore

Mine ore that is on the surface. This is typical for asteroid deposits, or surface ice on planets.

  • Set skip-depth to 0.
  • Set least-depth to 0.
  • Set depth-limit to a high value, e.g. 50 m. The agent will finish the shaft when there is no more ore/ice being picked up by the drills.

Subsurface Ore

Mine ore that is below the surface, under a layer of dirt or rock.

First, drill a pilot shaft:

  • Set skip-depth to 0 to a high value, depending on whether you want to pick up material from the pilot shaft.
  • Set least-depth to the expected depth of the ore plus 5 m. The expected depth can be detected with an ore detector.
  • Set depth-limit to least-depth plus 30 m.
  • Use only 1 agent.

Observe at which depth the agent picks up useful ore. The value is displayed on the LCD GUI. Then:

  • Set skip-depth to a 5 m above the start of the ore.
  • Set least-depth to the start of the ore, or slightly deeper (round to full 5m).
  • Set depth-limit to the end of the ore, or slightly deeper.

Two-layer Ore

Typically, there is ore below ice, sometimes with a layer of rock in between.

Proceed as with subsurface ore, but make sure that least-depth and depth-limit values are sufficiently high. So that the agent will drill through the deepest ore layer.

Excavation

Sometimes you just want the mining drones to excavate a site.

Set skip-depth, least-depth and depth-limit to the same value.

Adaptive Mining

TBD

Task and Job Parameters

On the dispatcher, there are two groups of dispatching parameters:

  • Task Parameters are used when creating a new task. Parameters of the existing task cannot be changed.

  • Job Parameters are used whenever the dispatcher sends a new job to an agent. When the parameters are changed while a task is being processed, all planned jobs of that task are changed. This allows drilling a pilot shaft first, then adjusting the parameters for the remaining shafts.

Both types of parameters can be managed on the GUI LCD. (since v0.10.0)

job and task GUI

Recalling Agents

An agent can be called back to base with the force-finish command. The agent will return to base, unload, and assume the Disabled state.

The recall command can be issued in four different ways:

A recall flag R will show up on the GUI screen for the recalled agent.

TBD: Do agents abandon the current job (if they have one)?

Logging

Dispatcher

The dispatcher logs events to an LCD panel. The LCD panel should be a wide LCD, if possible. In order to connect an LCD screen to the dispatcher, execute the command command:add-logger:my_lcd_name, where my_lcd_name is the name of the LCD.

The verbosity of the log can be controlled by changing the logLevel variable at the beginning of the dispatcher script.

Agent

TBD

Adding Agents: Handshaking

Agents will broadcast a message on miners.handshake on startup. Any dispatcher in range can respond with a miners.handshake.reply message, and take the agent into its service. //TODO: Agents must confirm this with another message to avoid becoming the servant to multiple masters.

An agent will initiate a handshake when its PB is recompiled.

A dispatcher will broadcast miners/dispatcher-change when its PB is recompiled. All agents picking up that broadcast will forget about their master and start handshaking again!

The handshake will fail, if agent and dispatcher run different software versions. The version can be found in the info box of the programmable block, or at the beginning of the code in variable Ver.

Agent Commands

command:create-task

Starts a mining task:

  1. Position the agent slightly above the center of the desired mining area.
  2. On planets, the mining plane will start 5 m above the planet's surface. In space, the mining plane will start at the position of the agent.
  3. On planets, the mining direction will be along the gravitational acceleration. In space, the drone's orientation will define the mining direction.
  4. Run command:create-task.
  5. The agent will sent its circular-pattern-shaft-radius, the normal vector and the center point of the mining task to the dispatcher in a create-task message. This is only at task proposal at this point.
  6. The dispatcher may perform checks to validate the proposal.
  7. The dispatcher starts the task, and instruct other agents to commence work.
    1. Only agents of the same group as the designating agent will be used.
    2. The dispatcher will instruct all agents (even other groups!) to clear their storage state with a miners.command / command:clear-storage-state broadcast.
    3. The dispatcher will send the task's normal vector to all same-group agents with a miners.normal message.
    4. The dispatcher will send a command / mine message to all same-group agents.
  8. The same-group agents will start mining ...

A task can only be created when all agents are either Disabled or Idle.

command:init-airspace

Forcibly re-initialises the airspace geometry. This usually leads to undefined agent flight behaviour, including possible collisions.

This command exists for rare situations, and should only be called by experts. The airspace is automatically initialised when a new task is created.

Air Traffic Control (ATC)

ATC pevents collisions in mid-air. It grants permissions to the agents when it is safe for them to proceed into protected areas of the airspace.

Generally, agents move along horizontal planes, so called flight levels. Each agent has its own flight level. Flight levels are assigned when an agent requests any airspace lock.

Agents can also move vertically, accross the flight levels of other agents. This happens at the mining site, or near the base. Agents must aquire a local airspace lock for that:

Base and mining site must not overlap, or there will be undefined behaviour.

Airspace Geometry

The position and orientation of the flight levels w.r.t. world coordinates is fixed when a new task is created. This is because a task can only be created, when all agents are either docked or under manual control. (state Disabled or Idle) This step is called airspace initialization.

How exacly the airspace is initialized depends on the situation:

Setup Flight Level Orientation Flight Level Position
Planetary Base orthogonal to gravity getAbove-altitude above the highest docking port
Rover orthogonal to gravity getAbove-altitude above the highest docking port
Space (Carrier) orthogonal to docking port axis getAbove-altitude away from the most protuding docking port

A re-initialization of the airspace can be forced by executing command:init-airspace on the dispatcher. Doing this while agents are on the air may yield undefined behaviour!

It is important that mobile dispatchers are not moving during mining operations. However, a small deviation can be compensated.

Monitoring

Airspace locks can be monitored on the LCD GUI on the agent list.

For flight levels, there is a separate page on the GUI. (since v0.11.0)

flight levels GUI

Docking

Another specific task of ATC is the assignment of docking ports. Agents will request a docking port, and the dispatcher will assign a free port for landing.

TBD: What happens whan all docking ports are busy? TBD: Naming of ports

Protocol Messages

Unicast

apck.depart.approach (ATC)

apck.depart.complete (ATC)

apck.depart.request (ATC)

apck.docking.approach (ATC)

apck.docking.request (ATC)

apck.docking.approach (ATC)

apck.depart.approach (ATC)

apck.ntv.update (ATC/ILS)

miners (ATC)

miners.handshake.reply (Dispatching)

miners.normal (Dispatching)

miners.resume (Dispatching)

command

report.request (Dispatching)

Broadcast

common-airspace-ask-for-lock (ATC)

common-airspace-lock-released (ATC)

command:halt

command:clear-storage-state

command:dispatch (Dispatching)

command:force-finish (Dispatching)

miners.handshake (Dispatching)