machine module¶
-
class
machine.Machine(shared_cfg, machine_cfg)¶ Bases:
objectReads the raw sensory data outputted by the aconity machine, processes it into a low-dimensional state vector and uploads it a remote server for parameter optimisation.
Parameters: - shared_cfg (dotmap) –
- n_ignore (int): Number of additional parts to be built on top of env.n_parts (pyrometer may not record data for the first few parts).
- env.nS (int): Dimensionality of the state vector.
- comms (dotmap): Configuration parameters for server communication.
- machine_cfg (dotmap) –
- aconity.layers (array of int): Layer range to be built, as [layer_min, layer_max].
- aconity.open_loop (np.array): Parameters used to build the parts built using fixed parameters, np.array with shape (n_fixed_parts, 2).
- aconity.n_parts (int): Number of parts to be built, excluding ignored parts.
- process.sess_dir (str): Folder where pyrometer data is stored by the Aconity machine.
- process.sleep_t (float): Time between a sensor data file being first detected and attempting to read it. Prevents errors emerging from opening the file while it is still being written.
-
getActions()¶ Download locally the action file outputted by the remote server.
-
getFileName(layer, piece)¶ Returns the pyrometer data file path for a given layer and part number.
This function accounts for the parts being ignored. The layer thickness is 0.03 mm.
Parameters: - layer (int) – Layer number.
- piece (int) – Part number.
Returns: File path.
Return type: str
-
getStates()¶ Read the raw data outputted from the pyrometer and processes it into low-dimensional state vectors.
For every part that must be observed, the raw data is red from the file outputted by the Aconity machine, cold lines are removed, the data pertaining to the object manufactured is kept, and it is discretised into a number of discrete regions in which the mean sensor value is computed.
Returns: State vectors with shape (n_parts, nS) Return type: np.array
-
initProcessing()¶ Obtains the folder in which data will be written by the pyrometer sensor.
This function automatically detects the latest session and job folders.
-
log(states)¶
-
loop()¶ Iteratively obtain next layer’s parameters from the remote server, read and process raw pyrometer data, and upload the low-dimensional states to the remote server to compute the next set of optimal parameters.
Allows the class functionality to be conveniently used as follows:
machine = Machine(s_cfg, m_cfg) machine.loop()
-
pieceNumber(piece_indx, buffer)¶ Returns the index given by AconityStudio to each individual part.
For instance, if the first part should be ignored, and part numbers increase three by three, then return int((piece_indx+1)*3+1) should be used, thus 0 -> 4, 1 -> 7, 2 -> 10, etc.
On the other hand, if the first three parts should be ignored, and part numbers increase one by one, then return int((piece_indx+3)+1) should be used, thus 0 -> 4, 1 -> 5, 2 -> 6, etc.
Parameters: - piece_indx (int) – Input index, starting from 0.
- n_ignore (int) – Number of initial parts that should be ignored.
Returns: Output index as used by AconityStudio.
Return type: int
-
sendStates(states)¶ Uploads to the the remote server the input state vector.
Parameters: states (np.array) – Processed state vector.
- shared_cfg (dotmap) –