I'd be very interested in this also
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!
Re: Another approach to assembly solver (A2plus)
Re: Another approach to assembly solver (A2plus)
Resulting principle from help-request ( https://forum.freecadweb.org/viewtopic. ... 11#p453711) is:
Code: Select all
import FreeCADGui
import FreeCAD
from PySide import QtGui
from PySide import QtCore
from pivy import coin
#setup the contour
color = coin.SoBaseColor()
color.rgb = (1, 0, 0)
points=coin.SoCoordinate3()
lines=coin.SoLineSet()
points.point.values = ( (0,0,0),(10,10,10),(10,10,0) )
#feed data to separator
sep=coin.SoSeparator()
sep.addChild(points)
sep.addChild(color)
sep.addChild(lines)
#add separator to sceneGraph
sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()
sg.addChild(sep)
I will now create some functionality according to this within the workbench.
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)
First quick and dirty test: Convergency (red = spin vector, blue = move vector) tracked on screen...
(Arrow heads missing, will follow)
.
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)
I've done some changes in your code.
I have only my few models to test it, so it is not tested well.
Probably it may fail for some other models (maybe in different scale, with different constrains etc.).
So rather think about is as a proof-of-concept, then solution for everything.
But for my model works, is faster and can handle models with everything messed up.
But it still not works for my more complex models in animation mode - I don't understand why, but I not analyzed this method yet.
With less complex models it works and is quite fast
Main changes:
1) spinCenter is now randomly chosen from inside "bounding box" - it works quite well to avoid stuck in some 'pitfalls'
2) rotations are weighted averaged by radius length (so it works like torque right now), for axial spins that (pseudo)radius is refPointsBoundBoxSize
3) added one more required accuracy step (0.033) - also I think here posAccuracy should not be absolute (it would behave different in different scale models) - should be calculated based on model bounding box size
4) added lot of debug messages (+ changed DebugMsg to be compatible with print() )
5) added SOLVER_ONESTEP to do only one step of solving (usefull for debugging)
I attached .patch with changes all together, because your github project is private and I can't create a branch.
I have only my few models to test it, so it is not tested well.
Probably it may fail for some other models (maybe in different scale, with different constrains etc.).
So rather think about is as a proof-of-concept, then solution for everything.
But for my model works, is faster and can handle models with everything messed up.
But it still not works for my more complex models in animation mode - I don't understand why, but I not analyzed this method yet.
With less complex models it works and is quite fast
Main changes:
1) spinCenter is now randomly chosen from inside "bounding box" - it works quite well to avoid stuck in some 'pitfalls'
2) rotations are weighted averaged by radius length (so it works like torque right now), for axial spins that (pseudo)radius is refPointsBoundBoxSize
3) added one more required accuracy step (0.033) - also I think here posAccuracy should not be absolute (it would behave different in different scale models) - should be calculated based on model bounding box size
4) added lot of debug messages (+ changed DebugMsg to be compatible with print() )
5) added SOLVER_ONESTEP to do only one step of solving (usefull for debugging)
I attached .patch with changes all together, because your github project is private and I can't create a branch.
- Attachments
-
- a2.patch.gz
- (4.43 KiB) Downloaded 286 times
Re: Another approach to assembly solver (A2plus)
Thank you very much. Sounds very, very interesting. I did some first tests. For a very small system, solving was succesful. For a medium sized model solving failed. I attach the test file.
I created a branch called "topyra" at github repo. Your patch is already applied. So you can do PR's if you want.
- Attachments
-
- pump-system.fcstd
- (765.13 KiB) Downloaded 260 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
Re: Another approach to assembly solver (A2plus)
I found there was as problem in one constrain rigids.
refPointsBoundBoxSize was zero, and I used this as 'radius' for axial forces.
As a workaround I expand bounding box by 5 in each direction (not good solution, as every that use fixed number not related to actual model dimensions), but it fixing this issue. I'll find something better later.
Patch is attached.
But I cant still solve pump-system, but I found interesting thing.
I can't be solved using 'a2p_SolverCommand' - it can't even go down to 10.0 accuracy.
But when I use 'a2p_SearchConstraintConflictsCommand' (conflict finder) it is able to solve it quick in each step with perfect accuracy like 1e-07
Could you please briefly describe differences between regular solver, and solving during searching for conflicts?
Is only difference is adding constrains one-by-one? Or there is some more magic behind?
refPointsBoundBoxSize was zero, and I used this as 'radius' for axial forces.
As a workaround I expand bounding box by 5 in each direction (not good solution, as every that use fixed number not related to actual model dimensions), but it fixing this issue. I'll find something better later.
Patch is attached.
But I cant still solve pump-system, but I found interesting thing.
I can't be solved using 'a2p_SolverCommand' - it can't even go down to 10.0 accuracy.
But when I use 'a2p_SearchConstraintConflictsCommand' (conflict finder) it is able to solve it quick in each step with perfect accuracy like 1e-07
Could you please briefly describe differences between regular solver, and solving during searching for conflicts?
Is only difference is adding constrains one-by-one? Or there is some more magic behind?
- Attachments
-
- a2.fix2.patch.gz
- (635 Bytes) Downloaded 252 times
Re: Another approach to assembly solver (A2plus)
Ok, found simple bug why pump was unsolvable.
In axial rotation when calculated 'weight' of each rotation I temporally put '30' and forgot about that.
So there is next patch (should be applied on one from previous post)
PS I don't know much about github.com but is this possible to give me permission to commit changes into topyra branch?
In axial rotation when calculated 'weight' of each rotation I temporally put '30' and forgot about that.
So there is next patch (should be applied on one from previous post)
PS I don't know much about github.com but is this possible to give me permission to commit changes into topyra branch?
- Attachments
-
- a2.fix3.patch.gz
- (1.15 KiB) Downloaded 272 times
Re: Another approach to assembly solver (A2plus)
I applied both patches to branch "topyra" and uploaded the new version to github.
Usual way is: (but im also not an very experienced git user)
- you create your own github accont (it's free of costs)
- fork my A2plus repo to your account at github
- clone your A2plus repo to your local machine
- checkout the topyra branch on local machine
- do your changes
- commit them on your local machine
- push the changed branch to your repo
- on github, use the compare button. After that you can create a pull request, which appears in my repo. I will merge it soon to your branch.
It's much better to track changes at github than managing patch sets manually.
If to complicated, i can still apply your patches like i do at moment.
Test results of your new changes:
- pump-system can be solved now
I attach 2 other files, which now have solving problems with your new version.
P.S: Tomorrow, i try to implement the graphical output for 3D debugging of constraints. I will try to reduce the 3D output somehow to selected rigids/constraints. Perhaps we can trace the problems more exactly.
I think i cannot grant commit permissions to a single branch only. That's a problem.
Usual way is: (but im also not an very experienced git user)
- you create your own github accont (it's free of costs)
- fork my A2plus repo to your account at github
- clone your A2plus repo to your local machine
- checkout the topyra branch on local machine
- do your changes
- commit them on your local machine
- push the changed branch to your repo
- on github, use the compare button. After that you can create a pull request, which appears in my repo. I will merge it soon to your branch.
It's much better to track changes at github than managing patch sets manually.
If to complicated, i can still apply your patches like i do at moment.
Test results of your new changes:
- pump-system can be solved now
I attach 2 other files, which now have solving problems with your new version.
P.S: Tomorrow, i try to implement the graphical output for 3D debugging of constraints. I will try to reduce the 3D output somehow to selected rigids/constraints. Perhaps we can trace the problems more exactly.
- Attachments
-
- hexapod.fcstd
- (39.74 KiB) Downloaded 282 times
-
- machinery-frame.FCStd
- (442.18 KiB) Downloaded 239 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
Re: Another approach to assembly solver (A2plus)
I have integrated some helper tools for this now.
Within a2plib.py, there is now a section for debug setup and you can activate a GRAPHICALDEBUG flag:
Code: Select all
#===================================================
# do debug settings here:
#===================================================
A2P_DEBUG_LEVEL = A2P_DEBUG_NONE #normal: A2P_DEBUG_NONE
GRAPHICALDEBUG = True #normal: False
# for debug purposes
# 0:normal
# 1:one step in each worklist
# 2:one step in first worklist
SOLVER_ONESTEP = 1 #normal: 0
#===================================================
Code: Select all
def drawDebugVectorAt(position,direction,rgbColor):
'''
function draws a vector directly to 3D view using pivy/Coin
expects position and direction as Base.vector type
color as tuple like (1,0,0)
'''
color = coin.SoBaseColor()
color.rgb = rgbColor
# Line style.
lineStyle = coin.SoDrawStyle()
lineStyle.style = coin.SoDrawStyle.LINES
lineStyle.lineWidth = 2
points=coin.SoCoordinate3()
lines=coin.SoLineSet()
startPoint = position.x,position.y,position.z
ep = position.add(direction)
endPoint = ep.x,ep.y,ep.z
points.point.values = (startPoint,endPoint)
#create and feed data to separator
sep=coin.SoSeparator()
sep.addChild(points)
sep.addChild(color)
sep.addChild(lineStyle)
sep.addChild(lines)
#add separator to sceneGraph
sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()
sg.addChild(sep)
solver_debug_objects.append(sep)
If you set "debugmode" = True at moment the move function of the corresponding rigid will draw it's movement vector (blue) and it's rotation vector (red) to screen. So you can see what the solver is producing.
If the output is getting to much, you can clean up the debug lines with this button:
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,
is there a way to constrain the sideway distance of two circles?
is there a way to constrain the sideway distance of two circles?