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!
project4
Posts: 237
Joined: Fri Jul 12, 2013 12:53 pm

Re: Another approach to assembly solver (A2plus)

Post by project4 »

kbwbe wrote: Thu Jul 26, 2018 2:08 pm
project4 wrote: Thu Jul 26, 2018 1:21 pm Are you sure you saw the duplicates on latest version?
I've added the list(set()) to getCandidates in the last change you took from me...
Yes. But only 1 duplicate in 1 testcase. It was the motor of the pump. Therefore i could not solve the pump assembly. After my changes, it worked. !?
Ohh... I see how that happens.
Please take my PR, better leave python libraries to eliminate the duplicates, it will probably be faster than looping on the entries.
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 »

project4 wrote: Thu Jul 26, 2018 4:43 pm
kbwbe wrote: Thu Jul 26, 2018 2:08 pm
project4 wrote: Thu Jul 26, 2018 1:21 pm Are you sure you saw the duplicates on latest version?
I've added the list(set()) to getCandidates in the last change you took from me...
Yes. But only 1 duplicate in 1 testcase. It was the motor of the pump. Therefore i could not solve the pump assembly. After my changes, it worked. !?
Ohh... I see how that happens.
Please take my PR, better leave python libraries to eliminate the duplicates, it will probably be faster than looping on the entries.
Thank you, PR merged.
After doing some tests today, IMHO the solver mode "partial solving" is the better one for most use-cases. I intend to set it as default mode. Also i think that the branch "solver-stabilization" is the better one than "master". It should be merged.

Suggestions ?
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 »

kbwbe wrote: Thu Jul 26, 2018 4:55 pm
project4 wrote: Thu Jul 26, 2018 4:43 pm
kbwbe wrote: Thu Jul 26, 2018 2:08 pm
project4 wrote: Thu Jul 26, 2018 1:21 pm Are you sure you saw the duplicates on latest version?
I've added the list(set()) to getCandidates in the last change you took from me...
Yes. But only 1 duplicate in 1 testcase. It was the motor of the pump. Therefore i could not solve the pump assembly. After my changes, it worked. !?
Ohh... I see how that happens.
Please take my PR, better leave python libraries to eliminate the duplicates, it will probably be faster than looping on the entries.
Thank you, PR merged.
After doing some tests today, IMHO the solver mode "partial solving" is the better one for most use-cases. I intend to set it as default mode. Also i think that the branch "solver-stabilization" is the better one than "master". It should be merged.

Suggestions ?
The DOF can't get to the 3'rd stage accuracy... It does resolve 2 accuracies and than report that it can't resolve.
I feel confident with the changes. It shouldn't have much worse results even in the worst case scenarios.
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 »

project4 wrote: Thu Jul 26, 2018 5:02 pm The DOF can't get to the 3'rd stage accuracy... It does resolve 2 accuracies and than report that it can't resolve.
I feel confident with the changes. It shouldn't have much worse results even in the worst case scenarios.
Do you mean 6DOF-example platform ? It works for me, but i did not apply latest PR local on my machine.
I attach my file.

Edit1
Just tested with latest PR. My 6DOF is still working...
/Edit1
Attachments
Assembly-Platform-6DOF-Fix-to-Move-Constrained.fcstd
(34.31 KiB) Downloaded 25 times
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
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 »

project4 wrote: Thu Jul 26, 2018 5:02 pm
Hi @project4,
branch "solver-stabilization" again updated. Rigid.move() does move+rotation now within only one placement step, no more separately.
It should be more fast.
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 »

Hi guys,

you're a really brave team, having made so much progress during the last few days!
That's the real spirit of the "opensource" thought taken to it's best! Thank you for that additional proof!

Just want to share some results with this afternoon's version of A2plus/solver-stabilization: (Completely made with "partial processing"!)
A2plus-Man-Hierachy.Screenshot_20180727.png
A2plus-Man-Hierachy.Screenshot_20180727.png (19.75 KiB) Viewed 955 times
A2plus-Man.Screenshot_20180727.png
A2plus-Man.Screenshot_20180727.png (46.86 KiB) Viewed 955 times

I may need to add that I had problems with circularEdge with a saved assembly of this from two days ago, but when completely recreating the constraints this afternoon, I was not able to reproduce it. So, hopefully "false alarm".

And yes, I know A2plus-Man isn't ready ATM and some proportions aren't ideal. ;-)

Best regards,
Manuel
project4
Posts: 237
Joined: Fri Jul 12, 2013 12:53 pm

Re: Another approach to assembly solver (A2plus)

Post by project4 »

kbwbe wrote: Thu Jul 26, 2018 4:55 pm
project4 wrote: Thu Jul 26, 2018 4:43 pm
kbwbe wrote: Thu Jul 26, 2018 2:08 pm
project4 wrote: Thu Jul 26, 2018 1:21 pm Are you sure you saw the duplicates on latest version?
I've added the list(set()) to getCandidates in the last change you took from me...
Yes. But only 1 duplicate in 1 testcase. It was the motor of the pump. Therefore i could not solve the pump assembly. After my changes, it worked. !?
Ohh... I see how that happens.
Please take my PR, better leave python libraries to eliminate the duplicates, it will probably be faster than looping on the entries.
Thank you, PR merged.
After doing some tests today, IMHO the solver mode "partial solving" is the better one for most use-cases. I intend to set it as default mode. Also i think that the branch "solver-stabilization" is the better one than "master". It should be merged.

Suggestions ?
Thinking about it a bit more, to have a better code organization, I would move the Rigid and the Dependency classes to its own files...
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 »

manuelkrause wrote: Thu Jul 26, 2018 11:02 pm And yes, I know A2plus-Man isn't ready ATM and some proportions aren't ideal. ;-)
Funny ! :mrgreen:
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 »

@kbwbe

I'm playing with the rotations to see how it works and it looks like the spinCenter calculations doesn't work...
What's wrong with that code?

Code: Select all

    def calcSpinCenter(self):
        newSpinCenter = Base.Vector(0,0,0)
        countRefPoints = 0
        for dep in self.dependencies:
            if dep.refPoint != None:
                newSpinCenter.add(dep.refPoint)
                FreeCAD.Console.PrintMessage("Ref point: {}, new center {}\n".format(dep.refPoint, newSpinCenter))
                countRefPoints += 1
        if countRefPoints > 0:
            newSpinCenter.multiply(1.0/countRefPoints)
            self.spinCenter = newSpinCenter
            FreeCAD.Console.PrintMessage("Spin center: {} num of points: {}\n".format(self.spinCenter, countRefPoints))
The output is:

Code: Select all

Ref point: Vector (49.99999999999983, 149.99999999999994, 20.0), new center Vector (0.0, 0.0, 0.0)
Spin center: Vector (0.0, 0.0, 0.0) num of points: 1
Ref point: Vector (50.0, 150.0, 20.0), new center Vector (0.0, 0.0, 0.0)
Spin center: Vector (0.0, 0.0, 0.0) num of points: 1
Should be:

Code: Select all

                newSpinCenter = newSpinCenter.add(dep.refPoint)
and
            self.spinCenter = newSpinCenter.multiply(1.0/countRefPoints)                
I hate when the APIs are not consistent... The WIKI says that multiply doesn't return anything, but in fact it does!
So based on the APIs some functions do change the object's data and some do not... Go figure.

I'm still playing with the code, so I won't PR a fix yet. I want to try my concepts first.
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 »

project4 wrote: Fri Jul 27, 2018 2:36 pm @kbwbe

I'm playing with the rotations to see how it works and it looks like the spinCenter calculations doesn't work...
What's wrong with that code?

Code: Select all

    def calcSpinCenter(self):
        newSpinCenter = Base.Vector(0,0,0)
        countRefPoints = 0
        for dep in self.dependencies:
            if dep.refPoint != None:
                newSpinCenter.add(dep.refPoint)
                FreeCAD.Console.PrintMessage("Ref point: {}, new center {}\n".format(dep.refPoint, newSpinCenter))
                countRefPoints += 1
        if countRefPoints > 0:
            newSpinCenter.multiply(1.0/countRefPoints)
            self.spinCenter = newSpinCenter
            FreeCAD.Console.PrintMessage("Spin center: {} num of points: {}\n".format(self.spinCenter, countRefPoints))
The output is:

Code: Select all

Ref point: Vector (49.99999999999983, 149.99999999999994, 20.0), new center Vector (0.0, 0.0, 0.0)
Spin center: Vector (0.0, 0.0, 0.0) num of points: 1
Ref point: Vector (50.0, 150.0, 20.0), new center Vector (0.0, 0.0, 0.0)
Spin center: Vector (0.0, 0.0, 0.0) num of points: 1
Should be:

Code: Select all

                newSpinCenter = newSpinCenter.add(dep.refPoint)
and
            self.spinCenter = newSpinCenter.multiply(1.0/countRefPoints)                
I hate when the APIs are not consistent... The WIKI says that multiply doesn't return anything, but in fact it does!
So based on the APIs some functions do change the object's data and some do not... Go figure.

I'm still playing with the code, so I won't PR a fix yet. I want to try my concepts first.
Hi @project4,

vector.multiply(value) modifies the vector itself. I usually do not use the return value.
vector1.add(vector2) returns a vector3, but does not modify vector1 and vector2.
All this is not really consistent.
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
Post Reply