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!
User avatar
manuelkrause
Posts: 442
Joined: Thu Jul 05, 2018 7:16 pm

Re: Another approach to assembly solver (A2plus)

Post by manuelkrause »

@kbwbe & @Turro75:
I also like this night's code. Rotational placement accuracy looks very good now!
I'd further observe while continuing assembling. Maybe we'd find the constraints introducing the convergency problems.

BTW, is the "lockRotation" functional now?

Very good work, guys!
Manuel
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 »

wandererfan wrote: Sat Aug 11, 2018 12:55 pm Not perfect, but good enough to show concept. Global placement needs to be applied to get import file components in right geometric relationship with each other. Crawler algo is brute force - could be smarter.
Hi wandererfan,
just tested your new file importer. It imported most of my files correctly.

I attach a file of an uggly plate, done with fc 0.17 and a combination of Draft-Array and PDN Boolean.
If importing this plate, there is a difference in imported shape to original shape.
Perhaps it is due to the combination Draft-WB/PDN...
Attachments
big-fc17-plate.fcstd
(16.57 KiB) Downloaded 42 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
User avatar
manuelkrause
Posts: 442
Joined: Thu Jul 05, 2018 7:16 pm

Re: Another approach to assembly solver (A2plus)

Post by manuelkrause »

@Turro75 & @kbwbe:

asm_hierarchy.Screenshot_20180812.png
asm_hierarchy.Screenshot_20180812.png (21.3 KiB) Viewed 1155 times

O.k., I've found some weird behaviour: In the given assembly attached, adding the angledPlanes between LowerBody and ArmLeft the PartialSolver fails and so skips to MagneticSolver which then complains with "System not solvable, convergency is incorrect!" but at the end says "===== System solved ! ======" (and in fact the ArmLeft rotates in place). Then manually invoking MagneticSolver solves it. And another PartialSolver invokation afterwards also doesn't complain.

And... all of this doesn't happen, when the angledPlanes is applied between Torso and ArmLeft.

I hope this gives you a clue. :-)
Attachments
ZB.A2plus-Man.7.fcstd
(97.58 KiB) Downloaded 32 times
Turro75
Posts: 179
Joined: Mon Aug 15, 2016 10:23 pm

Re: Another approach to assembly solver (A2plus)

Post by Turro75 »

Thanks, now it works

i use eclipse+pydev

I inserted the pydevd line (as reported in pydev remotedebugging page) in a function within the code I'm editing, starting debug server and by pressing the button that execute the code containing pydedv. and booom I'm in the eclipse debugging exactly where I need. :D
Turro75
Posts: 179
Joined: Mon Aug 15, 2016 10:23 pm

Re: Another approach to assembly solver (A2plus)

Post by Turro75 »

kbwbe wrote: Sun Aug 12, 2018 10:27 am
Turro75 wrote: Sat Aug 11, 2018 11:15 pm ok now everything should work as expected, not optimized yet but it start to be useable.
Hi Turro,
your new version seems to be better. Now it solves the last two small test-assemblies. :D

Now i did tests with 3 bigger assemblies (attached):
"pump-2018-07-26.fcstd" ==>> solved :D
"16081-frame..." ==>> not solved (convergency problems) :(
"ZSB-KBWBE-...." ==>> not solved (convergency problems) :(

Turro75 wrote: Sat Aug 11, 2018 11:15 pm @kwbwe may be the partial solving make sense only on first accuracy level, afterwards the advantage of partial against whole isn't clear to me.
BTW if You like, do refactoring as You want. then we can try profiling.
Partial solving makes sense even on higher accuracy levels, as it is stabilising calculations.

What was the problem why we had to hit the "solve" button multiple ? The problem is away now. Please give the code-snippet how it was fixed.

/Edit1: Find new branch "turro-dof-2", based on actual master, completed with your changes...
Hi Kbwbe,

there were 2 main issues in the code:

in prepare_restart I forgot to reset self.partialSolverCurrentStage to stage1 so after first accuracy level solving process it wasn't able to restart so explained the bad accuracy on placing objs.

the multiple hit solve button has been solved by forcing recalculating of dependencies refpoint and refaxisend before each calculate worklist.
I took profit on this by moving the specific code of each dependency within their own subclasses in a2p_dependencies.
I thought those values were updated within rigid.move() but actually it doesn't.
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,

i am reworking the devel branch with your changes.

I found this code, which is definitely bad:

Code: Select all

    def applyPlacementStep(self, pl):
        self.placement = pl.multiply(self.placement)
        self.spinCenter = pl.multVec(self.spinCenter)
        # Update dependencies
        for dep in self.dependencies:
            if dep.Enabled:  #handle only enable constraints
                #print dep.refPoint
                dep.applyPlacement(pl)
                #print dep.refPoint
If doing this way, dependencies get inconsistent after each placement step and you have to reload complete solving system before you can start next stage.

Better is doing this complete:

Code: Select all

    def applyPlacementStep(self, pl):
        self.placement = pl.multiply(self.placement)
        self.spinCenter = pl.multVec(self.spinCenter)
        # Update dependencies
        for dep in self.dependencies:
                dep.applyPlacement(pl)
After changing this, my devel branch (work in progress) got a bit more functional.

State of the devel branch is:
- completely updated a2p_dependencies.py with your changes
- a2p_rigid.py updated with your and my changes
- a2p_libDOF updated with your changes and a small correction done by me
- a2_solversystem.py is very different from your version

- hierarchy diagramm works again, i took your changes
- magnetic mode still works
- solver Stage 1 is getting better, i think i will get it to run..
- solver Stages 2-5 are still not implemented

- so partial mode on this branch is not functional ATM. I will keep on my work.. ;)

A little wish:
Please stop inserting print functions without brackets ! We will have to fix them all. And better use the a2plib.Msg() or a2plib.debugMsg() functions, as they are using FreeCAD's api with "FreeCAD.Console.PrintMessage". So we will be sure that everything is correct in future FreeCAD versions.
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 »

@kbwbe:

In a2p_libDOF.py:
"if dbg: a = axisa, axisb; print a" produces a syntax error on my python3 system, I replaced it with
"if dbg: print (axisa, axisb)" what was in @Turro75's previous version without brackets.

Manuel
Turro75
Posts: 179
Joined: Mon Aug 15, 2016 10:23 pm

Re: Another approach to assembly solver (A2plus)

Post by Turro75 »

manuelkrause wrote: Sun Aug 12, 2018 2:37 pm @kbwbe:

In a2p_libDOF.py:
"if dbg: a = axisa, axisb; print a" produces a syntax error on my python3 system, I replaced it with
"if dbg: print (axisa, axisb)" what was in @Turro75's previous version without brackets.

Manuel
This will be cleared in the next releases as I have a debugger functional I don't really need anymore a huge amount of prints.

print(a.__str__) should fix
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,

i had to fix a bug within class DependencyPointIdentity().calcRefPoints().

I now looks as this:( I marked the modification)

Code: Select all

    def calcRefPoints(self, index):
        self.index = index

        if index == 1:
            ob = self.doc.getObject(self.constraint.Object1)
            if self.constraint.Type == "sphereCenterIdent":
                vert = getPos(ob, self.constraint.SubElement1)
            else:
                vert = getObjectVertexFromName(ob, self.constraint.SubElement1)                            
        else:
            ob = self.doc.getObject(self.constraint.Object2)
            if self.constraint.Type == "sphereCenterIdent":
                vert = getPos(ob, self.constraint.SubElement2)
            else:
                vert = getObjectVertexFromName(ob, self.constraint.SubElement2)
                                    
        if self.constraint.Type == "sphereCenterIdent": #<==== this section is modified =============
            self.refPoint = vert
        else:
            self.refPoint = vert.Point

Branch "devel" is now cleaned up. It solves the same test assemblies as branch "turro-dof-2". I removed all prints with false syntax.
But branch master is still better. I think there are still some bugs in "devel" and it is still to slow...
If you want to modify something, please take branch "devel" for basis. It is more clean. We cannot work on complete different versions. I do not have enough time to redo cleaning up again and again.
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 »

Hi All,

Kbwbe uploaded a new branch turro-dof3 which is working better. It is able to solve quickly the assemblies I've tested.

Feedbacks are really appreciated.

I had to switch to Firefox to access freecadweb Today as Chrome blocked me.
Post Reply