Another approach to assembly solver (A2plus)

Discussion about the development of the Assembly workbench.
kbwbe
Posts: 551
Joined: Tue Apr 10, 2018 3:12 pm

Re: Another approach to assembly solver (A2plus)

Postby kbwbe » Thu Jul 12, 2018 8:18 pm

kbwbe wrote:
Thu Jul 12, 2018 8:17 pm
Hi Manuel,

you seem to have a lot of difficulties with my proposed workflow. It is hard to understand, but necessary, you have to delete constraints and reconstraint them for parts which you want to update (in mostly all use cases).

Disabling such constraints combined with later enabling of them will usually not work, as constraints are already broken when reimporting a part.. So your problems will only happen to later point of time.

The proposals of @Turro75 aim at some other thematics. His "tempfixing" of parts shall optimize the solver algorithm. It has nothing to do with reimporting / updating parts. This is another topic.

Sorry but no better news...
KBWBE

find recent version of A2plus here: https://github.com/kbwbe/A2plus
latest release: v0.1.6, installable via FreeCAD's addon manager
Paul Randall's tutorial on Youtube: https://youtu.be/mnkecA9S7kc
User avatar
jpg87
Posts: 244
Joined: Thu Mar 16, 2017 7:16 am
Location: Limoges - France
Contact:

Re: Another approach to assembly solver (A2plus)

Postby jpg87 » Fri Jul 13, 2018 1:21 pm

kbwbe wrote:
Tue Jul 10, 2018 8:21 pm
@jpg87
thank you for testing...
Answers to your questions:
- test remaining movements after constraining: ATM nothing special implemented, just move/rotate part manual away and solve again. You will see what is missing.
This is not what I wanted to say: when several solids are in chain, it is interesting to move the last to see if others follow in accordance with the predefined constraints, in fact test the validity of the mechanism.
kbwbe wrote:
Tue Jul 10, 2018 8:21 pm
- reference part:
Same as in Assembly 2. The first imported part is automatically fixed (Fixed Position = True in object tree)
You always can edit this property to False. But in this case you should fix another one instantly. Otherwise your whole assembly will move free
in coordinate system. As the solver will move each part which is constrained and not fixed.
OK perfect.
Thank you.
My website : http://help-freecad-jpg87.fr updated 2018/10/17
manuelkrause
Posts: 326
Joined: Thu Jul 05, 2018 7:16 pm

Re: Another approach to assembly solver (A2plus)

Postby manuelkrause » Fri Jul 13, 2018 1:55 pm

Hi @kbwbe,
no, no, I apparently used the wrong words or too few, so you got me wrong.
In praxis I don't have any problems with your proposed workflow as it obviously makes sense doing so. This also means, that it's absolutely clear to me that a logically broken constraint can only be deleted to keep the assembly sane. This especially applies for updating parts where topologies have changed. In fact I haven't yet begun to fix my miscalculated distances in the sub-assemblies. Instead I kept trying to get closer to the basic final shape of the engine's assembly and stumbled over several constraints that haven't been easily solvable, so I made use of intermediate constraints to come to the final one, or fixed subassemblies and deleted earlier constraints. These are the only little difficulties I face ATM and so I came to my proposal.
Sometimes I had found it useful to be able to re-activate such deleted or deactivated intermediate constraint. Of course this is also inspired by the way how solidworks does and by @Turro75's ideas, but I quite understood that the latter only dealt with the solver's algorithms (so I didn't mean to mix these things).

I hope this clarifies my earlier posting a bit better.

BTW, would you consider your most recent commit "modified solutionToParts()" useful in my case?

Manuel
kbwbe
Posts: 551
Joined: Tue Apr 10, 2018 3:12 pm

Re: Another approach to assembly solver (A2plus)

Postby kbwbe » Fri Jul 13, 2018 2:55 pm

jpg87 wrote:
Fri Jul 13, 2018 1:21 pm
kbwbe wrote:
Tue Jul 10, 2018 8:21 pm
@jpg87
thank you for testing...
Answers to your questions:
- test remaining movements after constraining: ATM nothing special implemented, just move/rotate part manual away and solve again. You will see what is missing.
This is not what I wanted to say: when several solids are in chain, it is interesting to move the last to see if others follow in accordance with the predefined constraints, in fact test the validity of the mechanism.
@jpg87
Now i understand your question. You want to move last part in chain, intermediate parts should follow.
Perhaps you can work with some workarounds.

1)
- Import a dummy part. Perhaps a box or cylinder, what ever you need.
- Fix the endpart of chain. Move the dummy part by some helper constraints to the endpart.
- Fix the dummy part, unfix the endpart.
- Modify the helper constraints (e.g. offset, angle) and your chain should begin to move.
- If you do not like to see the dummy, make it invisible. Constraints will still be working.

So you can move your endpart relative to the dummy part in a definite way and you can check the behaviour of your chained objects..

2)
Perhaps it also possible, only to fix your endpart and then move it by placement. You have to solve then manually.

P.S. Look at my movable platform example some posts before. if i would replace the circularedge constraints in cylinders by axis constraints, fix the platform, then i can move the platform by placement and have a look what the cylinders are doing.
Last edited by kbwbe on Fri Jul 13, 2018 3:16 pm, edited 1 time in total.
KBWBE

find recent version of A2plus here: https://github.com/kbwbe/A2plus
latest release: v0.1.6, installable via FreeCAD's addon manager
Paul Randall's tutorial on Youtube: https://youtu.be/mnkecA9S7kc
kbwbe
Posts: 551
Joined: Tue Apr 10, 2018 3:12 pm

Re: Another approach to assembly solver (A2plus)

Postby kbwbe » Fri Jul 13, 2018 3:09 pm

manuelkrause wrote:
Fri Jul 13, 2018 1:55 pm

BTW, would you consider your most recent commit "modified solutionToParts()" useful in my case?

Manuel
It is not important in your usecase ATM. You can stay with previous version...
For the rest of your suggestions i will have a look what can be done.
KBWBE

find recent version of A2plus here: https://github.com/kbwbe/A2plus
latest release: v0.1.6, installable via FreeCAD's addon manager
Paul Randall's tutorial on Youtube: https://youtu.be/mnkecA9S7kc
manuelkrause
Posts: 326
Joined: Thu Jul 05, 2018 7:16 pm

Re: Another approach to assembly solver (A2plus)

Postby manuelkrause » Fri Jul 13, 2018 4:45 pm

At least for a part of the noise I've made around my assemblies I want to express honest apologies.
It looks like I've underestimated my ability to miscalculate some distances in my sub-assemblies (mainly crankshaft vs. main housings) and one is advised to listen to FreeCAD's Report view, regarding A2plus' solver messages, indicating that 'Max positionerror' and 'Max spinerror' reach really high values, to consider a constraint "braindead" IOW logically wrong.

But on the other hand, it was the easiest way to find it out with this working A2plus to inspect the overlapping parts.
After doing this I was able to add the correct constraints, several previous ones wouldn't have been able to be solved by any solver on the world (except for one that can handle "curvature of space"). ;-)
Now I'd go at fixing the values and refining parts.

In the attached assembly you'd see quite obvious wrong distances and not the critical ones. I've only made the housings and the crankshaft 'fixed' here, and fortunately haven't needed any dummy parts, it just went straightforward in the order you see in 'Tree view'.

BTW, I've added the "modified solutionToParts()" commit anyways, can be that it helped with manual pre-placement via the Properties (just a subjective impression). I don't get errors since adding and maximum was "Total steps used: 4100" for this assembly.

Screenshot_20180713_174829.png
Screenshot_20180713_174829.png (529.79 KiB) Viewed 144 times

Thank you for your great work,
Manuel
kbwbe
Posts: 551
Joined: Tue Apr 10, 2018 3:12 pm

Re: Another approach to assembly solver (A2plus)

Postby kbwbe » Fri Jul 13, 2018 5:38 pm

Hi @manuelkrause,

i was sure that A2Plus should work in your usecase. Thank you for sharing.
You fixed the position of the crankshaft. So it is easy to rotate it by placement and let your engine be "running". ;)
KBWBE

find recent version of A2plus here: https://github.com/kbwbe/A2plus
latest release: v0.1.6, installable via FreeCAD's addon manager
Paul Randall's tutorial on Youtube: https://youtu.be/mnkecA9S7kc
manuelkrause
Posts: 326
Joined: Thu Jul 05, 2018 7:16 pm

Re: Another approach to assembly solver (A2plus)

Postby manuelkrause » Fri Jul 13, 2018 6:24 pm

ATM, I'm just only glad that it worked finally (and having found the culprits) after so many trials. I really admit, that I can't leave my eyes from the result, although it's quite simple, but just like a child with it's first toy.

I'd better "free" the crankshaft and add the correct A2plus constraints to only leave the housings 'fixed'. Then I can rotate with A2plus constraints. ;-)

BTW, hasn't there been an animation feature in "assembly2" (over degrees-of-freedom) or was it in another addon workbench?

Manuel
triplus
Posts: 7452
Joined: Mon Dec 12, 2011 4:45 pm

Re: Another approach to assembly solver (A2plus)

Postby triplus » Fri Jul 13, 2018 9:35 pm

kbwbe wrote:
Thu Jul 12, 2018 10:42 am
Change the circularEdgeConstraints/offset in small steps and look
what happens. ;)
Impressive.
Turro75
Posts: 162
Joined: Mon Aug 15, 2016 10:23 pm

Re: Another approach to assembly solver (A2plus)

Postby Turro75 » Sat Jul 14, 2018 9:30 am

Hello Kbwbe,

I reworked the logic of the solver in order to handle priorities and referenced objs.
I attached the solversystem.py feel free to test it.

how it works:

1) it checks for every constraints where the obj2 depends on other (a "father")
if all fathers of an object are already calculated solve it together to all other constraints which are in the same condition of fathers fully defined
after this temporary lock the position of the involved objs.

2) it repeats the above until there are no more constraints that fit that rule, of course the previos step will lock more objs and the solver workflow goes naturally from locked objs to free objs.

3) if there are constraints which don't fit that rule, it simply puts them together and tries to solve (which is exactly the behavior of the old logic).

for instance the "funny test" You shared it's fully working with old logic as there are no constraints that match the 1st check.

I attached a simple test that use a simple piping structure:
test RAW.PNG
test RAW.PNG (25.11 KiB) Viewed 76 times
continue...
Attachments
testa2plus_Reference to moveable.FCStd
(31.98 KiB) Downloaded 2 times
testa2plus_RAW.FCStd
(27.8 KiB) Downloaded 3 times
testa2plus_Moveable to reference.FCStd
(32.31 KiB) Downloaded 2 times
solversystem.py
(37.31 KiB) Downloaded 6 times