Skip to content

Open Source Planar Linkage Mechanism Simulation and Mechanical Synthesis System.

License

Notifications You must be signed in to change notification settings

se-forex/Pyslvs-PyQt5

 
 

Repository files navigation

Version Build status Build status PyQt Downloads GitHub license

Blog sourceforge

title

  1. Introduction

  2. Modules Requirement

  3. Kernels Requirement

  4. Stand-alone Executable File

  5. Powered By

Introduction

A GUI-based tool use to design 2D linkage mechanism.

  • Planar Linkages Simulation:

  • Mechanical Synthesis:

    • Number and Type Synthesis: Cython algorithm use to find out structure possibilities of the mechanism.
    • Dimensional Synthesis: Kernel from three Cython algorithm API (rewrite).

Previews in Ubuntu with KDE Plasma desktop:

main

Previews in Windows 10 theme:

main

Previews in macOS Sierra with fusion theme:

main

Design Method

computer_aid_design_method

Three-steps design flow:

  • Structure Synthesis
  • Dimensional Synthesis
  • Kinematic Simulation

Including sequential processes and inverse analysis.

How to Startup

Here's some command line options for Pyslvs.

# Download / update submodule:
git submodule update --init --recursive

# After following compile steps:
make build-kernel

# Open GUI by Python:
python launch_pyslvs.py

# Open GUI with Fusion style:
python launch_pyslvs.py --fusion

# Or see the help:
python launch_pyslvs.py --help

# Pack into stand-alone executable file:
make

Symbolic

Referring symbolic from PMKS.

The PMKS expression is using a name label to present a link bar.

A joint between two links will get two name labels, and so on.

The "ground" label is a default name, this link will be the absolute coordinate in the system, might be a frame of your mechanism.

PMKS example

Pyslvs was translate the PMKS expression as a string, likes below:

# Single line annotation.
M[
    J[R, color[Green], P[0.0, 0.0], L[ground, link_0]],
    J[R, color[Green], P[12.92, 32.53], L[link_0, link_1]],
    J[R, color[Green], P[73.28, 67.97], L[link_1, link_2]],
    J[R, color[Green], P[33.3, 66.95], L[link_1]],
    J[R, color[Green], P[90.0, 0.0], L[ground, link_2]],
]

Then the expression can be parse in Pyslvs to create the mechanism.

The grammar is defined with Extended Backus–Naur Form (EBNF), you can checkout the source code of parser.

Kinematics Simulation

Pyslvs has a simple simulation function driving with revolute joints.

There is a planar constraint solving mechanism done with three CAD kernels:

  • Pyslvs and Sketch Solve.
  • Python-Solvespace.
  • Sketch Solve.

Choose a base point and a driver point for the shaft, then add this dependent into variables list.

Using QDial widget (it just like a turntable) to adjust the angle value of variable.

Path data will start append coordinates (between a certain of distance) after press the "record" button. Press "record" button again to stop recording.

Path data can be copy or switch visibility by right-click menu.

Some exceptions are not support:

  • Other type of joints.
  • Degree of freedom was lower than 1 but still can moving.

Number and Type Synthesis

Analysis a type of mechanism that exists, and find out other possibilities.

We have a topological algorithm to combine atlas with:

  • Same degree of freedom.
  • Same number of link.
  • Same number of joint.

And use a type of mechanism to do grounding combine.

Grounding combine can merge the structure diagram immediately to canvas.

But in the common ways, you can give it to dimensional synthesis to make it more useful.

Triangular iteration

Before doing dimensional synthesis, a structure diagram has to configure it's verification formula.

PLAP function is using two known points, a length variable and an angle variable to find out the position of third point.

PLLP function is using two known points and two length variables to find out the position of third point.

When the structure profile is complete, is time to doing dimensional synthesis!

Dimensional Synthesis

Generate a mechanism with path requirement by random variables.

  • The structure settings is get from triangular iteration.
  • There also have algorithm options, such like constraints or probability.

Contains three algorithms:

  • Real-coded Genetic Algorithm
  • Firefly Algorithm
  • Differential Evolution

Specify a path and options to generate a crank rocker.

Three kinds of task target:

  • Stop at the maximum generation.
  • Get the minimum fitness value.
  • Stop at the maximum time.

IO Support

Pyslvs can support for following format.

Output formats:

  • Pyslvs workbook database (*.pyslvs).
  • Expression (just a string).
  • Solvespace format (*.slvs).
  • DXF format (*.dxf).
  • Image capture (all of Qt supports).

Input formats:

  • Pyslvs workbook database (*.pyslvs).
  • Expression (just a string).
  • Solvespace format (*.slvs, only supports very few of constraints).

The workbook mechanism will generate the sketch frame as *.slvs format like follow:

A part file will split the sketch and boundary with two groups.

The part files can be import to assemble with main sketch file. However, the 3D features still can not be generated from external program yet, so user need to do it by self.

For the IO method of Solvespace format, you can also refer to two Python scripts 'read' and 'write' in Pyslvs IO module.

Modules Requirement

Actual testing platforms:

  • w3.6
  • w3.7
  • mac3.6
  • mac3.7
  • u3.6
  • u3.7

Please note that the other platforms may be available but I have not tested before.

Mac OS and Ubuntu:

# Local Python
pip3 install -r requirements.txt

# Global Python
sudo pip3 install -r requirements.txt

Windows:

Python 3: Official Python for Windows 64 bit.

Makefile tool: MinGW or Msys 2.

pip install -r requirements.txt

PyQt Stuff (Development)

PyQt5 and QtChart are now pack into the wheel file that Windows and Ubuntu can install them directly.

Qt tools can use to design the *.ui files, they are not the requirement if you just want to run Pyslvs.

Mac OS and Ubuntu:

Download and install Qt5 to get the tools.

Windows:

Windows user can get Qt tools by pip (maybe not newest version), without to install Qt package.

pip install pyqt5-tools

Kernels Requirement

About the development tools, please see Modules Requirement.

Make command:

make build-kernel

This project including two kernels should build.

Pyslvs Kernel

Pyslvs: Core libraries of this project.

Make command:

make build-pyslvs

Mac OS and Ubuntu:

User can compile the kernel by Cython directly.

Windows:

There's two options to choose SDK:

  1. Using Microsoft Visual Studio. You can get it from here, then startup the Visual Studio Community and install Windows SDK.
  2. Using Msys 2. It is based on MinGW 64-bit version.
  3. Just using MinGW 64-bit.

When using MinGW for Python compiler, following command might be helpful:

# Where %PYTHON_DIR% is the directory of your Python installation.
# In Pyslvs project.

# Create "distutils.cfg"
echo [build]>> %PYTHON_DIR%\Lib\distutils\distutils.cfg
echo compiler = mingw32>> %PYTHON_DIR%\Lib\distutils\distutils.cfg

# Apply the patch of "cygwinccompiler.py".
# Unix "patch" command of Msys.
patch %PYTHON_DIR%\lib\distutils\cygwinccompiler.py platform\patch.diff
# Also can use "git apply".
copy platform\patch.diff %PYTHON_DIR%\lib\distutils
cd %PYTHON_DIR%\lib\distutils
git apply patch.diff
rd apply patch.diff /s /q

# Copy "vcruntime140.dll" to "libs".
copy %PYTHON_DIR%\vcruntime140.dll %PYTHON_DIR%\libs

And it will be useful if Make tool in Msys cannot find Windows command (such like copy, rd or del):

# Rewrite "SHELL" variable.
mingw32-make SHELL=cmd [target]

Python-Solvespace Kernel

Python-Solvespace: Python bundle of Solvespace library.

Make command:

make build-solvespace

Mac OS and Ubuntu:

Install SWIG and Python development kit. This tool kit can make a Python bundle with C/C++ library.

# Using Homebrew
brew install swig

# Using APT
sudo apt install swig python3-dev

Windows:

Download and install SWIG.

Stand-alone Executable File

As your wish, it can be renamed or moved out and operate independently in no-Python environment.

Ubuntu:

Use shell command to build as AppImage.

After following operation, the executable file is in out folder.

Make command:

sudo pip3 install virtualenv
make

Mac OS and Windows:

Use PyInstaller to build.

After following operation, the executable file is in dist folder.

Make command:

pip install pyinstaller
make

On Mac OS, PyInstaller will generate two executable files (refer here).

# Run Unix-like executable file.
# Cannot run it directly in Finder.
./executable --use-arguments-here

# Run Mac app file. (Cannot use any arguments)
# Same as double click it in Finder.
open ./executable.app

Powered By

Made by Qt5 and Python IDE Eric 6.

If there is no special reason, please install the newest version of the kits.

Including Python modules:

Pyslvs is under GNU Affero General Public License v3.

Kernel repository:

About

Open Source Planar Linkage Mechanism Simulation and Mechanical Synthesis System.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.8%
  • Other 0.2%