diff --git a/.gitignore b/.gitignore index 6df689e..b891ef5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ Private .DS_Store tex/out/* -!tex/out/*.pdf \ No newline at end of file +!tex/out/*.pdf + +__pycache__/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 1641234..43e2f9e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,8 @@ "latex-workshop.formatting.latex": "latexindent", "latex-workshop.latex.outDir": "%DIR%/out", "files.autoSave": "afterDelay", - "latex-workshop.synctex.afterBuild.enabled": true + "latex-workshop.synctex.afterBuild.enabled": true, + "latex-workshop.view.outline.sync.viewer": true, + "editor.scrollbar.scrollByPage": true, + "editor.find.cursorMoveOnType": true } \ No newline at end of file diff --git a/3mf/base/Electronics_Cover_Short.3mf b/3mf/base/Electronics_Cover_Short.3mf new file mode 100644 index 0000000..20e3fb1 Binary files /dev/null and b/3mf/base/Electronics_Cover_Short.3mf differ diff --git a/3mf/base/Electronics_Cover_Top.3mf b/3mf/base/Electronics_Cover_Top.3mf new file mode 100644 index 0000000..cf7e2c2 Binary files /dev/null and b/3mf/base/Electronics_Cover_Top.3mf differ diff --git a/3mf/base/Frame_Plate_Side_Left.3mf b/3mf/base/Frame_Plate_Side_Left.3mf new file mode 100644 index 0000000..5d72869 Binary files /dev/null and b/3mf/base/Frame_Plate_Side_Left.3mf differ diff --git a/3mf/base/Frame_Plate_Side_Right.3mf b/3mf/base/Frame_Plate_Side_Right.3mf new file mode 100644 index 0000000..232c1fc Binary files /dev/null and b/3mf/base/Frame_Plate_Side_Right.3mf differ diff --git a/3mf/base/Frame_Tip.3mf b/3mf/base/Frame_Tip.3mf new file mode 100644 index 0000000..c80f2b7 Binary files /dev/null and b/3mf/base/Frame_Tip.3mf differ diff --git a/3mf/base/Frame_Tip_Bottom.3mf b/3mf/base/Frame_Tip_Bottom.3mf new file mode 100644 index 0000000..2a3efd9 Binary files /dev/null and b/3mf/base/Frame_Tip_Bottom.3mf differ diff --git a/README.md b/README.md index 828066e..6efaf01 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,10 @@ ```bash ├── .vscode # Konfigurace prostředí pro sazbu +├── 3mf # 3mf soubory vhodné ke slicování ├── cad # Zdrojové soubory CAD -├── step # STEP soubory vhodné ke slicování ├── README.md # Informace k projektu (tento soubor) +├── scripts # Skripty └── tex # Text práce ├── generated # Generované stránky BP ├── images # Obrázky použité v BP @@ -28,5 +29,16 @@ Práce je kompilovaná sázecím systémem Latex a modifikovaným balíčkem the ##### Závislosti +- texlive - texlive-langczechslovak - texlive-langgreek + +### Skripty + +#### Generování tiskových souborů + +Pro generování tiskových souborů slouží skript `generate_3mf_files.py` spouštěný následujícím příkazem: + +```sh +./generate_3mf_files.py +``` diff --git a/cad/Electronics_Cover_Short.FCStd b/cad/Electronics_Cover_Short.FCStd deleted file mode 100644 index 0f71ba4..0000000 Binary files a/cad/Electronics_Cover_Short.FCStd and /dev/null differ diff --git a/cad/Frame_Assembly.FCStd b/cad/Frame_Assembly.FCStd index 2e4054c..5bb7505 100644 Binary files a/cad/Frame_Assembly.FCStd and b/cad/Frame_Assembly.FCStd differ diff --git a/cad/Frame_Plate_Side_Left.FCStd b/cad/Frame_Plate_Side_Left.FCStd deleted file mode 100644 index cfee612..0000000 Binary files a/cad/Frame_Plate_Side_Left.FCStd and /dev/null differ diff --git a/cad/Frame_Plate_Side_Right.FCStd b/cad/Frame_Plate_Side_Right.FCStd deleted file mode 100644 index e2f1374..0000000 Binary files a/cad/Frame_Plate_Side_Right.FCStd and /dev/null differ diff --git a/cad/Frame_Tip.FCStd b/cad/Frame_Tip.FCStd deleted file mode 100644 index a68413b..0000000 Binary files a/cad/Frame_Tip.FCStd and /dev/null differ diff --git a/cad/Frame_Tip_Bottom.FCStd b/cad/Frame_Tip_Bottom.FCStd deleted file mode 100644 index 1d93005..0000000 Binary files a/cad/Frame_Tip_Bottom.FCStd and /dev/null differ diff --git a/cad/Profile-20x40-300.FCStd b/cad/Profile-20x40-300.FCStd deleted file mode 100644 index d728d42..0000000 Binary files a/cad/Profile-20x40-300.FCStd and /dev/null differ diff --git a/cad/printed/base/Electronics_Cover_Short.FCStd b/cad/printed/base/Electronics_Cover_Short.FCStd new file mode 100644 index 0000000..9b9e0e4 Binary files /dev/null and b/cad/printed/base/Electronics_Cover_Short.FCStd differ diff --git a/cad/Electronics_Cover_Top.FCStd b/cad/printed/base/Electronics_Cover_Top.FCStd similarity index 100% rename from cad/Electronics_Cover_Top.FCStd rename to cad/printed/base/Electronics_Cover_Top.FCStd diff --git a/cad/printed/base/Frame_Plate_Side_Left.FCStd b/cad/printed/base/Frame_Plate_Side_Left.FCStd new file mode 100644 index 0000000..81acad3 Binary files /dev/null and b/cad/printed/base/Frame_Plate_Side_Left.FCStd differ diff --git a/cad/printed/base/Frame_Plate_Side_Right.FCStd b/cad/printed/base/Frame_Plate_Side_Right.FCStd new file mode 100644 index 0000000..379d152 Binary files /dev/null and b/cad/printed/base/Frame_Plate_Side_Right.FCStd differ diff --git a/cad/printed/base/Frame_Tip.FCStd b/cad/printed/base/Frame_Tip.FCStd new file mode 100644 index 0000000..98b3ffc Binary files /dev/null and b/cad/printed/base/Frame_Tip.FCStd differ diff --git a/cad/printed/base/Frame_Tip_Bottom.FCStd b/cad/printed/base/Frame_Tip_Bottom.FCStd new file mode 100644 index 0000000..b0da16f Binary files /dev/null and b/cad/printed/base/Frame_Tip_Bottom.FCStd differ diff --git a/cad/DIN_Rail_130mm.FCStd b/cad/sourced/DIN_Rail_130mm.FCStd similarity index 100% rename from cad/DIN_Rail_130mm.FCStd rename to cad/sourced/DIN_Rail_130mm.FCStd diff --git a/cad/Electronics_Acrylic.FCStd b/cad/sourced/Electronics_Acrylic.FCStd similarity index 100% rename from cad/Electronics_Acrylic.FCStd rename to cad/sourced/Electronics_Acrylic.FCStd diff --git a/cad/Profile-20x20-130.FCStd b/cad/sourced/Profile-20x20-130.FCStd similarity index 100% rename from cad/Profile-20x20-130.FCStd rename to cad/sourced/Profile-20x20-130.FCStd diff --git a/cad/Profile-20x20-60.FCStd b/cad/sourced/Profile-20x20-60.FCStd similarity index 100% rename from cad/Profile-20x20-60.FCStd rename to cad/sourced/Profile-20x20-60.FCStd diff --git a/cad/Profile-20x20.FCStd b/cad/sourced/Profile-20x20.FCStd similarity index 100% rename from cad/Profile-20x20.FCStd rename to cad/sourced/Profile-20x20.FCStd diff --git a/cad/sourced/Profile-20x40-300.FCStd b/cad/sourced/Profile-20x40-300.FCStd new file mode 100644 index 0000000..781d6d9 Binary files /dev/null and b/cad/sourced/Profile-20x40-300.FCStd differ diff --git a/cad/Rod_8_300.FCStd b/cad/sourced/Rod_8_300.FCStd similarity index 100% rename from cad/Rod_8_300.FCStd rename to cad/sourced/Rod_8_300.FCStd diff --git a/scripts/generate_3mf_files.py b/scripts/generate_3mf_files.py new file mode 100755 index 0000000..c4425f3 --- /dev/null +++ b/scripts/generate_3mf_files.py @@ -0,0 +1,65 @@ +#!/usr/bin/freecadcmd + +import os +import FreeCAD +import Mesh + +# Define the project root directory +project_root = os.path.abspath( + os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir) +) + +# Define the directories for CAD files and 3MF export files +printed_cad_dir = os.path.join(project_root, "cad", "printed") +printed_3mf_dir = os.path.join(project_root, "3mf") + +# List to keep track of files that failed to export +failed_files = [] + +# Traverse the printed CAD directory and its subdirectories +for root, dirs, files in os.walk(printed_cad_dir): + for file in files: + if file.endswith(".FCStd"): + # Absolute path of the CAD file + file_path = os.path.join(root, file) + + # Abslute path for the exported 3MF file + output_path = os.path.join( + printed_3mf_dir, os.path.relpath(file_path, printed_cad_dir) + ).replace(".FCStd", ".3mf") + + # Create the output directory if it doesn't already exist + os.makedirs(os.path.dirname(output_path), exist_ok=True) + + FreeCAD.Console.PrintMessage(f"\nExporting {file_path}\n") + + # Open the FreeCAD document and recompute it + doc = FreeCAD.openDocument(file_path) + FreeCAD.setActiveDocument(doc.Name) + FreeCAD.ActiveDocument.recompute() + + # Get the body object from the document + body = doc.getObject("Body") + if body is None: + FreeCAD.Console.PrintError(f"No 'Body' found in {file}\n") + FreeCAD.closeDocument(doc.Name) + failed_files.append(file_path) + continue + + # Try to export the body to a 3MF file + try: + Mesh.export([body], output_path) + except Exception as e: + FreeCAD.Console.PrintError(f"Error exporting {file}: {e}\n") + failed_files.append(file_path) + + # Close the FreeCAD document + FreeCAD.closeDocument(doc.Name) + +# Print the result of the export and the files that failed +if failed_files: + FreeCAD.Console.PrintError("\nThe following files failed to export:\n") + for file in failed_files: + FreeCAD.Console.PrintError(f" - {file}\n") +else: + FreeCAD.Console.PrintMessage("\nAll files have been exported successfully.\n") diff --git a/tex/literatura.bib b/tex/literatura.bib index b6cd640..e7a21fc 100644 --- a/tex/literatura.bib +++ b/tex/literatura.bib @@ -37,4 +37,12 @@ title = {x-scara}, year = {2023}, note = {GitHub repository} +} + +@misc{klipper_code_overview, + title = {Klipper Code Overview}, + author = {{Klipper 3D}}, + year = {2023}, + url = {https://www.klipper3d.org/Code_Overview.html}, + note = {Accessed: 2023-10-10} } \ No newline at end of file diff --git a/tex/out/prace.pdf b/tex/out/prace.pdf index 8f382df..49fb0f8 100644 Binary files a/tex/out/prace.pdf and b/tex/out/prace.pdf differ diff --git a/tex/text/4_prakticka_cast.tex b/tex/text/4_prakticka_cast.tex index 8424e52..7624c20 100644 --- a/tex/text/4_prakticka_cast.tex +++ b/tex/text/4_prakticka_cast.tex @@ -10,25 +10,74 @@ Mnou vytvářené modely vychází z projektu x-scara. \cite{x-scara} Model je r \subsection{Základna} Základna je složena ze hliníkových profilů 20x20mm a 20x40mm. Na základnu je upevněno rameno, které se díky lineárně valivým ložiskům pohybuje po vodící tyči o průměru 8mm. Základna je složena ze hliníkových profilů 20x20mm a 20x40mm. Na základnu je upevněno rameno, které se díky lineárně valivým ložiskům pohybuje po třech vodících tyčích o průměru 8mm. V horní části základny je upevněn krokový motor, který pomocí trapézové tyče o průměru 8mm pohybuje ramenem v ose Z. -V zadní části zakladny je též prostor pro upevnění elektroniky. Za PMMA panelem jsou přimontovány dvě DIN lišty, na které jsou pomocí adaptérů upevněny jednotlivé elektronické prvky. +Pro spojení hliníkových profilů jsem zvolil techniku "Blind Joint", která umožňuje pevné a levné spojení dvou hliníkových profilů. Tuto techniku jsem zvolil i z důvodů snadnější montáže akrylové desky a možnosti zapuštění elektroniky do rámu tiskárny. + +V zadní části zakladny je též prostor pro upevnění elektroniky. Za akrylovým panelem jsou přimontovány dvě DIN lišty, na které jsou pomocí adaptérů upevněny jednotlivé elektronické prvky. \section{Implementace kinematiky scara do Klippy} -Pro další výpočty je potřebné znát Elbow Crosstalk Ratio (převodový poměr ozubených řemenic v ose ramene vůči řemenici v ose kloubu). +Klippy je část firmwaru Klipper, která běží na počítači uvnitř 3D tiskárny, ke kterému je připojena řídící deska. Kód je napsán převážne v jazyce Python, přičemž některé funkce jsou implementovány v jazyce C. Volání těchto funkcí je realizováno použitím rozraní CFFI (C Foreign Function Interface). \cite{klipper_code_overview} + +\subsection{Přímá a inverzní kinematika} +Kinematické transformace se používají k převodu natočení kloubů na souřadnice koncového bodu (přímá transformace) a naopak (inverzní transformace). Pro výpočet transformace je třeba znát délky ramen \(L_1\) a \(L_2\), offsety ramen \(x_{offset}\) a \(y_{offset}\) a Elbow Crosstalk Ratio (ECR). + +Pro další výpočty je potřebné znát Elbow Crosstalk Ratio (převodový poměr řemenice v ose ramene vůči řemenici v ose kloubu). \begin{equation} ECR = \frac { n_S } { n_E } \end{equation} -\section{Přímá kinematika} +\subsubsection{Přímá kinematika} + +\begin{equation} + \phi_S = a +\end{equation} + +\begin{equation} + \phi_E = b - \frac{a}{ECR} +\end{equation} + +\begin{equation} + a\_sin = - \sin(\phi_S) \cdot L_1 +\end{equation} + +\begin{equation} + a\_cos = \cos(\phi_S) \cdot L_1 +\end{equation} + +\begin{equation} + b\_sin = - \sin(\phi_S + \phi_E) \cdot L_2 +\end{equation} + +\begin{equation} + b\_cos = \cos(\phi_S + \phi_E) \cdot L_2 +\end{equation} + +Nakonec je potřeba přičíst odsazení souřadného systému nástroje vůči souřadnému systému báze (konkrétně odsazení kloubu ramene vůči počátku tiskové podložky). + +\begin{equation} + x = a\_sin + b\_sin + x_{offset} +\end{equation} + +\begin{equation} + y = a\_cos + b\_cos + y_{offset} +\end{equation} -\subsection{Inverzní kinematika} +\subsubsection{Inverzní kinematika} Nejprve je třeba kompenzovat offset polohy TCP v osách x a y. +\begin{equation} + x = - (raw_x - x_{offset}) +\end{equation} + +\begin{equation} + y = (raw_y - y_{offset}) +\end{equation} + Dalším krokem je výpočet vzdálenosti od počátku. \begin{equation} - hypot = \sqrt{x^2 y^2} + hypot = \sqrt{x^2 + y^2} \end{equation} Dále se vypočítají úhly ramen \(\phi_S\) (shoulder) a \(\phi_E\) (elbow).