Another approach to assembly solver (A2plus)

Discussion about the development of the Assembly workbench.
project4
Posts: 153
Joined: Fri Jul 12, 2013 12:53 pm

Re: Another approach to assembly solver (A2plus)

Postby project4 » 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.
kbwbe
Posts: 879
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: Another approach to assembly solver (A2plus)

Postby kbwbe » 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 ?
KBWBE

https://github.com/kbwbe/A2plus
latest release: v0.4.29, installable via FreeCAD's addon manager
Tutorials:
Paul Randall: https://youtu.be/mnkecA9S7kc
anisim (deutsch): https://www.youtube.com/watch?v=vDcaFq6IEJM
project4
Posts: 153
Joined: Fri Jul 12, 2013 12:53 pm

Re: Another approach to assembly solver (A2plus)

Postby project4 » Thu Jul 26, 2018 5:02 pm

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
Posts: 879
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: Another approach to assembly solver (A2plus)

Postby kbwbe » Thu Jul 26, 2018 5:12 pm

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 7 times
KBWBE

https://github.com/kbwbe/A2plus
latest release: v0.4.29, installable via FreeCAD's addon manager
Tutorials:
Paul Randall: https://youtu.be/mnkecA9S7kc
anisim (deutsch): https://www.youtube.com/watch?v=vDcaFq6IEJM
kbwbe
Posts: 879
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: Another approach to assembly solver (A2plus)

Postby kbwbe » Thu Jul 26, 2018 9:58 pm

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.29, installable via FreeCAD's addon manager
Tutorials:
Paul Randall: https://youtu.be/mnkecA9S7kc
anisim (deutsch): https://www.youtube.com/watch?v=vDcaFq6IEJM
User avatar
manuelkrause
Posts: 442
Joined: Thu Jul 05, 2018 7:16 pm

Re: Another approach to assembly solver (A2plus)

Postby manuelkrause » Thu Jul 26, 2018 11:02 pm

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 165 times
A2plus-Man.Screenshot_20180727.png
A2plus-Man.Screenshot_20180727.png (46.86 KiB) Viewed 165 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: 153
Joined: Fri Jul 12, 2013 12:53 pm

Re: Another approach to assembly solver (A2plus)

Postby project4 » Fri Jul 27, 2018 5:30 am

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
Posts: 879
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: Another approach to assembly solver (A2plus)

Postby kbwbe » Fri Jul 27, 2018 6:30 am

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.29, installable via FreeCAD's addon manager
Tutorials:
Paul Randall: https://youtu.be/mnkecA9S7kc
anisim (deutsch): https://www.youtube.com/watch?v=vDcaFq6IEJM
project4
Posts: 153
Joined: Fri Jul 12, 2013 12:53 pm

Re: Another approach to assembly solver (A2plus)

Postby project4 » 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.
kbwbe
Posts: 879
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: Another approach to assembly solver (A2plus)

Postby kbwbe » Fri Jul 27, 2018 2:51 pm

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.29, installable via FreeCAD's addon manager
Tutorials:
Paul Randall: https://youtu.be/mnkecA9S7kc
anisim (deutsch): https://www.youtube.com/watch?v=vDcaFq6IEJM