Another approach to assembly solver (A2plus)
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- manuelkrause
- Posts: 442
- Joined: Thu Jul 05, 2018 7:16 pm
Re: Another approach to assembly solver (A2plus)
@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
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
Re: Another approach to assembly solver (A2plus)
Hi wandererfan,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.
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
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
- manuelkrause
- Posts: 442
- Joined: Thu Jul 05, 2018 7:16 pm
Re: Another approach to assembly solver (A2plus)
@Turro75 & @kbwbe:
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.
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
Re: Another approach to assembly solver (A2plus)
Thanks, now it worksJee-Bee wrote: ↑Sun Aug 12, 2018 7:04 am https://forum.freecadweb.org/viewtopic.php?f=10&t=3884
Or
https://forum.freecadweb.org/viewtopic.php?t=28256
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.
Re: Another approach to assembly solver (A2plus)
Hi Kbwbe,kbwbe wrote: ↑Sun Aug 12, 2018 10:27 amHi Turro,
your new version seems to be better. Now it solves the last two small test-assemblies.
Now i did tests with 3 bigger assemblies (attached):
"pump-2018-07-26.fcstd" ==>> solved
"16081-frame..." ==>> not solved (convergency problems)
"ZSB-KBWBE-...." ==>> not solved (convergency problems)
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...
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.
Re: Another approach to assembly solver (A2plus)
@Turro75,
i am reworking the devel branch with your changes.
I found this code, which is definitely bad:
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:
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.
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
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)
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
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
- manuelkrause
- Posts: 442
- Joined: Thu Jul 05, 2018 7:16 pm
Re: Another approach to assembly solver (A2plus)
@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
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
Re: Another approach to assembly solver (A2plus)
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.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
print(a.__str__) should fix
Re: Another approach to assembly solver (A2plus)
@Turro75,
i had to fix a bug within class DependencyPointIdentity().calcRefPoints().
I now looks as this:( I marked the modification)
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.
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
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
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
Re: Another approach to assembly solver (A2plus)
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.
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.