Another approach to assembly solver (A2plus)

Discussion about the development of the Assembly workbench.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
kbwbe
Veteran
Posts: 1052
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: Another approach to assembly solver (A2plus)

Post by kbwbe »

Turro75 wrote: Sun Jul 15, 2018 8:47 pm
1) the solver is effective but slow (actually python on my laptop is slow), since it is pure math it would make sense rewriting calcmovedata and moverigids in c++ or freepascal and use them as external dll overriding the overhead due to python's slowness, I'm confident it will boost a lot the solving timing allowing a better precision and increasing the number of max steps.
I agree. Speeding up factor 50..100 using low level programming language is always possible. It would be much faster. But we should improve
solver logic first with python, as prototyping and testing is possible in shorter time. When new logic is perfect, we should think about further steps.
I had some applications in other projects, where pure python solution was kept alive as it was finally fast enough. (With a lot of tricks)
Turro75 wrote: Sun Jul 15, 2018 8:47 pm
2) the idea to split the assembly in several sub assemblies to lower the load on solver isn't so bad, I'm thinking about determine if an obj is fully constrained to its father (all 6 DOF locked to the father)so creating a part container of both and use the container as boundbox reference. after the system is fully solved, simply delete the part container keeping globalplacement of sub objects. In theory it would work but I'm not so confident on future of part containers.
Your code regarding solving partial systems is good and understandable. I think, the simple father/son relation is not enough. The "tempfixing" requirements are at some higher level. The constraints relations between rigids/parts have to be analyzed in a more sophistical way, as looking for
for constraint loops which are feeding back to fixed parts. So subsystems to solve will become some bigger, but there will be still an effect speeding up the system and increasing accuracy. I think the solution will be a mix of your approach and my old one.
KBWBE

https://github.com/kbwbe/A2plus
latest release: v0.4.56, installable via FreeCAD's addon manager
Tutorial: gripper assembly https://www.youtube.com/watch?v=QMxcQ5tssWk
Documentation: https://www.freecadweb.org/wiki/A2plus_Workbench
User avatar
manuelkrause
Posts: 442
Joined: Thu Jul 05, 2018 7:16 pm

Re: Another approach to assembly solver (A2plus)

Post by manuelkrause »

O.k., then you get something to play with. It's the last scrambled state by @Turro75's solver from last evening.
Be aware, that the housings length measurements don't match the crankshaft's, so use reasonable constraints. ATM, I'm still at fixing the wrong distances throughout all the sub-assemblies.

ZB-Kurbeltrieb+Gehäuse.5-A2p.fcstd
(221.28 KiB) Downloaded 37 times

Have fun, and keep up your spirit and good work!

Manuel
User avatar
manuelkrause
Posts: 442
Joined: Thu Jul 05, 2018 7:16 pm

Re: Another approach to assembly solver (A2plus)

Post by manuelkrause »

Just in case you want to fully assemble it, you may need another 2 pistons and another 2 piston-rod sub-assemblies.

Here they are:
Kolben-7.fcstd
(972.79 KiB) Downloaded 37 times
ZB-Pleuel+Lager+Bolzen.2-A2p.fcstd
(14.87 KiB) Downloaded 44 times

For some unknown reason the A2plus "duplicate part" button doesn't work on here. Report view says:
...
Running the Python command 'a2p_duplicatePart' failed:
Traceback (most recent call last):
File "/home/manuel/.FreeCAD/Mod/A2plus/a2p_importpart.py", line 348, in Activated
PartMover( FreeCADGui.activeDocument().activeView(), duplicateImportedPart( selection[0].Object ) )
File "/home/manuel/.FreeCAD/Mod/A2plus/a2p_importpart.py", line 335, in duplicateImportedPart
if hasattr(newObj.ViewObject, p) and p not in ['DiffuseColor','Proxy','MappedColors']:

The enum is empty
...

Manuel
User avatar
manuelkrause
Posts: 442
Joined: Thu Jul 05, 2018 7:16 pm

Re: Another approach to assembly solver (A2plus)

Post by manuelkrause »

The final assembly should come up in front view somehow like this here, done with original latest A2plus:

Screenshot_20180716_073113.png
Screenshot_20180716_073113.png (236.96 KiB) Viewed 1253 times

Happy testing and best regards,
Manuel
project4
Posts: 237
Joined: Fri Jul 12, 2013 12:53 pm

Re: Another approach to assembly solver (A2plus)

Post by project4 »

Turro75 wrote: 2) when creating a constraint always select as first the reference object and then the object that must be moved.

Everytime You ignore the point n.2 You break the optimized calculation chain, after that the solver comes back to previous "all together" behavior.
Hello Turro,
Didn't read to the end of the thread yet, but had to comment so I won't forget it...

I understand the logic of the 2'nd rule, but if the calculations are prioritized from the fixed object down the chain, I think the algorithm could check what linked object is tempfixed already and use it as the first reference, instead of forcing the user to remember the click sequence.

In practice, users generally select the first visible face, than the second one after moving the view.
If you are assembling something repeating, you'll find yourself rotating the view back and forth, so to save the time you'll select first the currently visible face instead of rotating the view again.
kbwbe
Veteran
Posts: 1052
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: Another approach to assembly solver (A2plus)

Post by kbwbe »

Sorry, edited this post as it was nonsense due to false click...

@project4,

i have the same opinion regarding 2'nd rule. Algorithm should do this, not user. As algorithm has to be changed anyway in bigger parts, i think this will be possible.
KBWBE

https://github.com/kbwbe/A2plus
latest release: v0.4.56, installable via FreeCAD's addon manager
Tutorial: gripper assembly https://www.youtube.com/watch?v=QMxcQ5tssWk
Documentation: https://www.freecadweb.org/wiki/A2plus_Workbench
Turro75
Posts: 179
Joined: Mon Aug 15, 2016 10:23 pm

Re: Another approach to assembly solver (A2plus)

Post by Turro75 »

kbwbe wrote: Mon Jul 16, 2018 7:48 am Sorry, edited this post as it was nonsense due to false click...

@project4,

i have the same opinion regarding 2'nd rule. Algorithm should do this, not user. As algorithm has to be changed anyway in bigger parts, i think this will be possible.
in SW I had to manually take care of that, mixing reference and moveable objects generates assemblies which easily get broken when edited.
The user must know how the items have to be assembled, the software would guess it but it will fail.

In any case on some small assemblies that rule would be easy to insert, let's see what turns out
kbwbe
Veteran
Posts: 1052
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: Another approach to assembly solver (A2plus)

Post by kbwbe »

Turro75 wrote: Mon Jul 16, 2018 9:34 am
kbwbe wrote: Mon Jul 16, 2018 7:48 am Sorry, edited this post as it was nonsense due to false click...

@project4,

i have the same opinion regarding 2'nd rule. Algorithm should do this, not user. As algorithm has to be changed anyway in bigger parts, i think this will be possible.
in SW I had to manually take care of that, mixing reference and moveable objects generates assemblies which easily get broken when edited.
The user must know how the items have to be assembled, the software would guess it but it will fail.

In any case on some small assemblies that rule would be easy to insert, let's see what turns out
Hi Turro,
i am working with AD-Inventor for a lot of years. I never recognized a problem, complete ignoring rule 2. Perhaps SW and Inventor behave differently or my assemblies are not complex enough. As you say: Let's see..
KBWBE

https://github.com/kbwbe/A2plus
latest release: v0.4.56, installable via FreeCAD's addon manager
Tutorial: gripper assembly https://www.youtube.com/watch?v=QMxcQ5tssWk
Documentation: https://www.freecadweb.org/wiki/A2plus_Workbench
project4
Posts: 237
Joined: Fri Jul 12, 2013 12:53 pm

Re: Another approach to assembly solver (A2plus)

Post by project4 »

I think I'm missing something very trivial...
I've created a simple rectangular part, copy&paste it to have a second one.
Moved the second part aside and want to connect them.
Selected 2 planes that face each other, press the planeCoincident button and get the "Constraints inconsistent. Cannot solve System." error.

Attaching the simple file. What am I missing?
Attachments
test_a2p.fcstd
(14.91 KiB) Downloaded 38 times
project4
Posts: 237
Joined: Fri Jul 12, 2013 12:53 pm

Re: Another approach to assembly solver (A2plus)

Post by project4 »

Since I can't assemble anything yet, started playing around with the Assembly-Platform-6DOF file you attached a while ago.
I see the resolver doesn't really resolve automatically for every change, but only when I press the rubics-cube button, regardless if I change the auto-resolve mode. Should it be so?
When the solver is actually executed?

I was trying to see if I can move a part and see that all the others are aligned accordingly, but the structure comes back to the same shape when I recalculate manually.

EDIT:
While typing, tried to change the offset in one of the pistons constraint and saw the part recalculated when I press enter.

Ok. Now I get that the assembly might be all constrained and that's the reason I can't really move something to see other parts follow it.
But when I'll solve the problem on my side (probably don't understand something), will it be possible to recalculate on every move of a part to see something move?

I understand that the calculations might be too slow, but still, I would expect to see something...
Post Reply