Competition: kinematic simulation of a coupling gear

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
kwahoo
Posts: 680
Joined: Fri Nov 29, 2013 3:09 pm
Contact:

Re: Competition: kinematic simulation of a coupling gear

Post by kwahoo »

NewJoker wrote: Fri May 20, 2022 2:05 pm
Yes, the sketcher with its constraints, DOF handling and mouse dragging can be very useful for simple geometric analysis of a mechanism but won't provide you the data needed in most cases - positions, velocities and accelerations (not to even mention forces and moments) of points and links belonging to the mechanism throughout its whole range of motion under applied velocity, for example.

That's possible with proper sketches in commercial software: https://www.youtube.com/watch?v=pBczBrM7uq0
You can add "drive" to a sketch and read position of every vertex, with a simple script. To show things as simple as possible, I made an example with 3 lines:
kinem.FCStd
(4.9 KiB) Downloaded 18 times
This script will move angle constraint from 10 deg to 40 deg with 1 deg step, and print position of Vertex3:

Code: Select all

import FreeCAD as App, FreeCADGui as Gui, Part, time
from PySide2 import QtGui,QtCore

class Animation(object):
    def __init__(self):
        App.Console.PrintMessage('init')
        App.ActiveDocument.recompute()
        self.timer = QtCore.QTimer()
        QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.my_update)
        self.timer.start(500) #500ms for step, adjust to performance of the PC
        self.an = 10
        self.end = 40

    def my_update(self):
        self.an = self.an + 1
        App.ActiveDocument.getObjectsByLabel("Sketch")[0].setDatum(6,App.Units.Quantity(str(self.an)+' deg')) #angle Constraint7 (6+1, because Sketcher starts counting from 1 not 0)
        App.ActiveDocument.recompute()
        p1 = App.ActiveDocument.getObjectsByLabel("Sketch")[0].Shape.Vertexes[2].Point #Sketch.Vertex3
        print(str(self.an), str(p1))
        if self.an > self.end:
            self.stop()

    def stop(self):
        self.timer.stop()


animation = Animation()
Console output:

Code: Select all

...
18:14:40  21 Vector (-24.33471798228596, 37.3432170597076, 0.0)
18:14:41  22 Vector (-24.984263737107035, 37.08735418248287, 0.0)
18:14:41  23 Vector (-25.629245140037973, 36.820194137900906, 0.0)
...
Then you can easily calculate velocity, since it is the first derivative of displacement and acceleration (second derivative). Finally you can create some graphs with FreeCAD.plot() https://wiki.freecadweb.org/Plot_MultiAxes_tutorial

Also there is another more fancy tool: Assembly3 skeleton sketch https://github.com/realthunder/FreeCAD_ ... ton-Sketch
It works in 3D, and has dedicated tool for tracing vertices.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Competition: kinematic simulation of a coupling gear

Post by adrianinsaval »

wasn't there a recent announcement of a 2D kinematics workbench?
User avatar
NewJoker
Veteran
Posts: 3017
Joined: Sun Oct 11, 2020 7:49 pm

Re: Competition: kinematic simulation of a coupling gear

Post by NewJoker »

kwahoo wrote: Sat May 21, 2022 4:21 pm You can add "drive" to a sketch and read position of every vertex, with a simple script.
Thank you for sharing this. I think that it would be great to implement a workbench or tool that could do this automatically. Especially that there are no FOSS alternatives for that at the moment. For now, I created a GitHub feature request to document this idea:

https://github.com/FreeCAD/FreeCAD/issues/6908

By the way, do you know if this approach could be extended to obtain also the forces and moments ?

adrianinsaval wrote: Sat May 21, 2022 11:33 pm wasn't there a recent announcement of a 2D kinematics workbench?
Do you mean this ?

https://forum.freecadweb.org/viewtopic.php?f=9&t=66567
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Competition: kinematic simulation of a coupling gear

Post by adrianinsaval »

NewJoker wrote: Sun May 22, 2022 10:31 am For now, I created a GitHub feature request to document this idea:

https://github.com/FreeCAD/FreeCAD/issues/6908
Isn't it out of scope for the main repo?
yes, does it not satisfy your needs?
User avatar
NewJoker
Veteran
Posts: 3017
Joined: Sun Oct 11, 2020 7:49 pm

Re: Competition: kinematic simulation of a coupling gear

Post by NewJoker »

adrianinsaval wrote: Sun May 22, 2022 2:42 pm Isn't it out of scope for the main repo?
I don't think so, suggestions for new workbenches are also placed there. For example: https://github.com/FreeCAD/FreeCAD/issues/6439

I added it there in the fond hope that it may become a built-in feature. But even if it's created as another add-on, I think that the report still fits there until someone creates a separate repository for a new workbench to develop it.

adrianinsaval wrote: Sun May 22, 2022 2:42 pm yes, does it not satisfy your needs?
It looks very promising (even though it's still in development and can't plot accelerations and forces, for example) but it doesn't operate on sketches and requires assemblies of 3D bodies so it's more like this workbench: https://forum.freecadweb.org/viewtopic.php?f=18&t=39165

than a simple tool to animate sketches and do some calculations on them (which is the focus of my GitHub report).
User avatar
kwahoo
Posts: 680
Joined: Fri Nov 29, 2013 3:09 pm
Contact:

Re: Competition: kinematic simulation of a coupling gear

Post by kwahoo »

NewJoker wrote: Sun May 22, 2022 10:31 am
By the way, do you know if this approach could be extended to obtain also the forces and moments ?
Well, yes. If you know masses and where they are placed, the rest is Newton's 2nd law.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Competition: kinematic simulation of a coupling gear

Post by Kunda1 »

Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
NewJoker
Veteran
Posts: 3017
Joined: Sun Oct 11, 2020 7:49 pm

Re: Competition: kinematic simulation of a coupling gear

Post by NewJoker »

NewJoker wrote: Sun May 22, 2022 10:31 am For now, I created a GitHub feature request to document this idea:

https://github.com/FreeCAD/FreeCAD/issues/6908
This FR was closed because it was too wide. I created a new one, limited to just a small tool for kinematic analysis on sketches: issue #7248
Post Reply