s.ayadi 7a8c25f3b9 Add DXF registration with a provable coordinate transform
The CSV export and the BricsCAD drawing sit in different coordinate systems. A
silent offset here puts every annotation in the wrong place while still looking
plausible, so this module derives the transform, proves it, and refuses when it
cannot.

Approach: vote for the translation over point pairs, refine the best candidates
by Procrustes fit (rotation included), pick the one with the most exact matches,
then report the residuals.

Two things the naive version got wrong, both fixed here:

Matching is constrained by role. The plant is built from regular grids - the
store lines, their infeeds and their outfeeds each form a row of 20 points at
800 mm pitch. Voting over all points is therefore ambiguous: a wrong offset hits
the infeed row exactly as well as the right one hits the separator row, and it
won by a single vote (21 to 20), producing an offset 8.6 m out with a spurious
0.52 degree rotation. Separators are now matched only against separator blocks
(S-SP, S-LP) and scanners only against SCAN, which makes the result unique.

The fit uses exact matches only (50 mm). For extended objects the CSV reports the
bounding-box centre while the block reports its insertion point; such pairs are
100-500 mm apart and would tilt the fit if they were included. They still count
towards the reported residuals.

For the Mubea plant this yields dx +50905.7 mm, dy +8414.5 mm, rotation exactly
0, from 20 exact matches - the same values a hand analysis produced.

A verified transform is stored in SKEL_CFG/dxf_registration.json per CSV/DXF
pair, so later runs are reproducible; a stored transform is still re-checked
against the drawing on every run.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 15:39:54 +02:00
2026-07-20 16:28:31 +02:00

sps_skel

Das Programm erhält ein mechanische Layout von der Projektierung oder Angebotswesen zusammen mit dem elektronischen Layout mit der Liste aller Sensoren, Stopper, etc. Daraus erstellt es dann ein Skelett für die SPS Programmierung, welches direkt ins TIA Portal importiert werden kann.

Projektstruktur

sps_skel/
  bin/                      Skripte zur Umgebungsverwaltung
    setenv.bat/.sh          Umgebungsvariablen setzen
    install_py.bat/.sh      venv erstellen + pip install
    activate_venv.bat/.sh   venv aktivieren
    get_cmd.bat/.sh         Shell mit Umgebung oeffnen
  cfg/                      Konfigurationsdateien (INI/JSON)
  data/                     Eingabedaten (nicht im Git)
  doc/                      Dokumentation
  examples/                 Beispieldateien
  lib/                      Python-Quellcode / Bibliothek
  log/                      Log-Dateien (nicht im Git)
  results/                  Ergebnisse / Ausgaben (nicht im Git)
  tests/                    Unit Tests
  .gitignore
  LICENSE
  README.md
  requirements.txt

Umgebungsvariablen

Variable Beschreibung
SPS_SKEL Wurzelverzeichnis
SKEL_BIN Skriptverzeichnis
SKEL_LIB Python-Quellcode
SKEL_CFG Konfigurationsdateien
SKEL_DATA Eingabedaten
SKEL_LOG Log-Dateien
SKEL_RESULTS Ergebnisse
SKEL_EXAMPLES Beispieldateien
PYTHONPATH Erweitert um SKEL_LIB

Installation

Voraussetzungen

  • Python 3.10 oder hoeher

Setup (Windows)

bin\install_py.bat

Setup (Linux / macOS)

bash bin/install_py.sh

Nutzung

Umgebung setzen

bin\setenv.bat              # Windows
source bin/setenv.sh        # Linux / macOS

Shell mit gesetzten Variablen oeffnen

bin\get_cmd.bat             # Windows
source bin/get_cmd.sh       # Linux / macOS

venv aktivieren

bin\activate_venv.bat       # Windows
source bin/activate_venv.sh # Linux / macOS

Lizenz

MIT License - siehe LICENSE

Autor

Michael Stangl (GitHub: mistamichael)

S
Description
No description provided
Readme MIT 25 MiB
Languages
Python 92%
Shell 4%
Batchfile 3.9%
Common Lisp 0.1%