This a coursework in 2021 when I was an undergraduate student at Shanghai Jiao Tong University. It implements two dimensional computation of kinematics and dynamics of mechanical systems, including two-link mechanism, crank-slider mechanism, and others. I implemented some matrix calculations and classes of constraints in C++ myself.
C++ is used for computation and Python is used for visualization. I used Visual Studio 2019 and Pycharm 2020.2 as IDEs (so you can find .sln files in the repository). For python, I used Python 3.7.6 with an Anaconda environment (But I cannot find exact versions of packages I used since it was five years ago).
Some code files may be encoded by GB2312 because of some Chinese contents.
I assume that users of the repository have basic knowledge about computational kinematics/dynamics so are familiar with constraint equations and solutions.
One can find two examples (INP0 and INP2 in KinematicsExer
) of questions, their descriptions of constraints, detailed velocity and accelaration equations, flow chart, and results in Kinematics/Report.docx
.
- Use
create_INPfile.py
to generate a input file (such asINP*.txt
in the repository) for rigid bodies and constraints. See the .docx file,INP0.txt
, andINP2.txt
for descriptions of constraints. - Use
create_bodyshape.py
to generate a file for geometries of objects (such asINP*_shape.txt
in the repository). - Run
plot.py
to select the input file and geometry file. plot.py
then callsKinematics.exe
complied fromKinematicsC++
that generates outputs, and plot the outputs, including positions, velocities, and accelarations of objects, charts, and a mp4 file.
No space is allowed in filepaths.
Two examples (INP4 and INP5 in DynamicsExer
) are reported in Dynamics/Report.docx
containing descriptions of equations and results.
-
Write an input file (such as
INP*.txt
in the repository) for rigid bodies, constraints, and forces. SeeDynamics/Report.docx
,INP4.txt
, andINP5.txt
for examples. -
Use
create_bodyshape.py
to generate a file for geometries of objects (such asINP*_shape.txt
in the repository). -
Run
main.py
to select the input file and geometry file. -
main.py
then callsDynamics.exe
complied fromDynamicsC++
that generates outputs, and plot the outputs, including positions, velocities, accelerations, and Lagrangian multipliers of objects, charts, and a mp4 file.
INP1_output.mp4
INP2_output.mp4
INP2_output.mp4
(With a spring)