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
openfablab
Posts: 62
Joined: Wed Nov 02, 2016 4:42 pm
Contact:

Re: Another approach to assembly solver (A2plus)

Post by openfablab »

kkremitzki wrote: Thu Sep 24, 2020 6:42 pm For spatial and geographic data there is PostGIS, a PostgreSQL extension: https://postgis.net/

A while back I thought it would be interesting to wrap OpenCASCADE functionality in a PostgreSQL extension as well; then PG servers running that extension could serve as model backends for FreeCAD, and you'd get all the functionality of PG and its ecosystem, for example permissions & access model, locking, transactions, replication, sharding, etc. -- PostCAD.

As I looked more and more into this, though, it'd be really hard! Not really something I could do in my free time just yet.
So deep integration with PG would be great! :) Hope to see it one day.

However for experimenting with new database-centered workflows we need very modest level of integration: just ability to somehow keep and retrieve FCStd file contents in database records with some custom fields.
Smiling_user
Posts: 196
Joined: Tue Jul 28, 2020 7:31 am

Re: Another approach to assembly solver (A2plus)

Post by Smiling_user »

openfablab wrote: Thu Sep 24, 2020 7:48 pm So deep integration with PG would be great! :) Hope to see it one day.
However for experimenting with new database-centered workflows we need very modest level of integration: just ability to somehow keep and retrieve FCStd file contents in database records with some custom fields.
1. It seems that sqlite is already used in the FC
2. one through problem in the FC is details associations: what dan-miel pointed: replacement of the part in one file - destroys associations.

for that last - very needed would be to have a table (left-right) of present associations available to replace them manually. And then the idea of backtracking would have sense.
User avatar
openfablab
Posts: 62
Joined: Wed Nov 02, 2016 4:42 pm
Contact:

Re: Another approach to assembly solver (A2plus)

Post by openfablab »

Smiling_user wrote: Fri Sep 25, 2020 8:07 am
openfablab wrote: Thu Sep 24, 2020 7:48 pm So deep integration with PG would be great! :) Hope to see it one day.
However for experimenting with new database-centered workflows we need very modest level of integration: just ability to somehow keep and retrieve FCStd file contents in database records with some custom fields.
1. It seems that sqlite is already used in the FC
2. one through problem in the FC is details associations: what dan-miel pointed: replacement of the part in one file - destroys associations.

for that last - very needed would be to have a table (left-right) of present associations available to replace them manually. And then the idea of backtracking would have sense.
Unfortunately I did not find how to work with sqlite in FreeCAD :(

Now I am thinking about generating virtual disk or filesystem.

FreeCAD and any other tool can browse "folders", read and save "files" which are really processed with some custom python code which retrieves them from database. Thus I can draw two cubes with FreeCAD, save it to ~/PLM/FreeCAD/1.FCStd, then open e.g. with Excel folder ~/PLM/Excel/1/list_of_cubes.xls, delete there one of them, and then open ~/PLM/FreeCAD/1.FCStd with FreeCAD - and see there no second cube. And, of course, I can undo or extract older version through custom PLM interface - into specific folder.

If A2plus FreeCAD assembly A.FCStd file have link to my FreeCAD file B.FCStd (as sub-part), when I try open one of these files it can be generated already with all tables of dependencies, hyperlinks (pointing inside of virtual filesystem and being really PLM commands, and other arbitrary objects). Thus FreeCAD only works with files, but links - direct, lateral or reverse - are stored and managed in independent database. And I can work with cross-file networks of these links: I can take any diagram editor (supported by my code under this virtual FS), inspect/add/delete/repoint links - and on file save this is automatically reflected in my assembly structure.

Here part paths for A2plus (or, due to universality, for any kind of Assembly workbench file) are generated on file loading and can not be broken occasionally due to database supervision.

Screenshot_2020-09-25_14-23-47.png
Screenshot_2020-09-25_14-23-47.png (100.54 KiB) Viewed 12478 times

So we can end up with ultimately simple in installation (and integration with all kinds of software tools) PLM: just running script mounting and serving virtual filespace. Could anybody suggest an appropriate python library for it? (I am not so good in other languages)
EskiBrew
Posts: 100
Joined: Fri Apr 24, 2015 10:21 am

Re: Another approach to assembly solver (A2plus)

Post by EskiBrew »

OS: Linux Mint 20 (XFCE/xfce)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22670 (Git) AppImage
Build type: Release
Branch: master
Hash: 12155f4aab09047c5697db0c1b3cf93b02edda03
Python version: 3.8.6
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United Kingdom (en_GB)


It's a long time since I tried A2+ and I suspect there will have been improvements so I am keen to try again. I have recently tried Assembly4 but that does not seem terribly intuitive to me. I have also tried Assembly3 which is more intuitive than Assembly4 but still not as intuitive as A2+.

When I last tried A2+, there was a the problem of assemblies breaking if a component part was modified after assembly (think that's the topological naming problem). Can anyone tell me if that is still a problem to be aware of?

Looking on the A2+ wiki page (here) I am interested to try out the scripting for animation. I find however two problems:
1) Animation.FCMacro", line 3, in <module>
import A2plus.a2p_solversystem as a2p_solver
<class 'ModuleNotFoundError'>: No module named 'A2plus'
I do have A2plus installed though. What's the problem here?

2) If I use the other macro which uses a Qt interface, my computer simply locks, completely and irretrievably requiring a hard reboot. It could be linked to problem 1 above and if I solve that, the Qt interface one might work.

Any ideas?
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 »

EskiBrew wrote: Tue Oct 20, 2020 9:57 am Looking on the A2+ wiki page (here) I am interested to try out the scripting for animation. I find however two problems:
1) Animation.FCMacro", line 3, in <module>
import A2plus.a2p_solversystem as a2p_solver
<class 'ModuleNotFoundError'>: No module named 'A2plus'
I do have A2plus installed though. What's the problem here?
There seems to be a little error. Please use:

Code: Select all

import FreeCAD.A2plus.a2p_solversystem as a2p_solver
EskiBrew wrote: Tue Oct 20, 2020 9:57 am 2) If I use the other macro which uses a Qt interface, my computer simply locks, completely and irretrievably requiring a hard reboot. It could be linked to problem 1 above and if I solve that, the Qt interface one might work.
I did not test this yet.
.
EskiBrew wrote: Tue Oct 20, 2020 9:57 am When I last tried A2+, there was a the problem of assemblies breaking if a component part was modified after assembly (think that's the topological naming problem). Can anyone tell me if that is still a problem to be aware of?
Yes. This is still a huge problem for complete FC.
A2plus has a build-in mechanism to reduce the problems caused by reordered vertexes,edges faces. You should activate the A2p preference "use experimental topological naming"

Next to screenshots are showing, what is happening without using that option. A simple basepart has been connected via 3 plane coincident constraints. Everything seems to be fine. Only applying one champfer to the basepart leads to wrong assembly result. See here:
no-toponaming-1.png
no-toponaming-1.png (95.4 KiB) Viewed 12310 times
no-toponaming-2.png
no-toponaming-2.png (6.06 KiB) Viewed 12310 times
.
After that, i activated the preference "use experimental topological naming" and started a complete new assembly. Using this option leads to geometric informations in the mux-info field of an imported part. This infos are used to recover reordered geometric elements.
See the new assembly here:
.
with-toponaming-1.png
with-toponaming-1.png (143.9 KiB) Viewed 12310 times
.
Now i could do horrible things to the original parts without blowing up the assembly:
.
with-topnaming-2.png
with-topnaming-2.png (102.7 KiB) Viewed 12310 times
.
I attach the files. Via Partdesign WB you can iterate back by setting the tip of the parts, to get earlier states of their features. After saving and updating the assembly you can see that it keeps stable.

But there are still many ways to get problems with the topological naming issue. Add new lines to a sketch. This is enough, if the sketch is used for a pad which is referenced by a constraint.

P.S. For testing the files you have to activate the preference "use experimental topological naming". Otherwise nothing will work.
Attachments
files.zip
(109.39 KiB) Downloaded 162 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
EskiBrew
Posts: 100
Joined: Fri Apr 24, 2015 10:21 am

Re: Another approach to assembly solver (A2plus)

Post by EskiBrew »

kbwbe wrote: Tue Oct 20, 2020 4:39 pm There seems to be a little error. Please use:

Code: Select all

import FreeCAD.A2plus.a2p_solversystem as a2p_solver
Thank you, that works with that correction. It's not the same problem in the other macro but at least one of them is working 8-)
kbwbe wrote: Tue Oct 20, 2020 4:39 pm Now i could do horrible things to the original parts without blowing up the assembly:
Wow, that's brilliant! :o
EskiBrew
Posts: 100
Joined: Fri Apr 24, 2015 10:21 am

Re: Another approach to assembly solver (A2plus)

Post by EskiBrew »

Can anyone help me understand how to lock the rotation of two parts so that if one rotates, the other rotates?
I've tried both the circularEdge constraint and the axisCoincident constraint with the "lock rotation" set to true however if I then rotate one part, the other does not rotate when I press solve. What am I missing? I've attached a really simple example file.
Screenshot1.png
Screenshot1.png (6.49 KiB) Viewed 12180 times
A2P V0.4.47e
OS: Linux Mint 20 (XFCE/xfce)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22670 (Git) AppImage
Build type: Release
Branch: master
Hash: 12155f4aab09047c5697db0c1b3cf93b02edda03
Python version: 3.8.6
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United Kingdom (en_GB)
Attachments
a2p_test_rotation.FCStd
(7.8 KiB) Downloaded 194 times
Turro75
Posts: 179
Joined: Mon Aug 15, 2016 10:23 pm

Re: Another approach to assembly solver (A2plus)

Post by Turro75 »

Hi,

lock rotation has never been implemented, it's an old property used in previous assembly2.
You can try constraining objs to an external sketch, it is a very powerful feature of a2plus

Valerio
Attachments
schetch sample.FCStd
(3.7 KiB) Downloaded 179 times
a2p_test_rotation.FCStd
(10.47 KiB) Downloaded 166 times
topyra
Posts: 12
Joined: Thu Nov 12, 2020 8:55 pm

Re: Another approach to assembly solver (A2plus)

Post by topyra »

Hi

I am trying to make a McPherson strut using A2+, but encountered wired problem with moving parts.
Error "animation problem detected" appears in positions where whole model should behave quite stable (nothing "strained", all angles looks good etc.)

Model contain "armRF" constrained to fixed rotation axis (FixCylinder) and spherical to "KnuckleRF-asm" on the other side.
Knuckle (green part - in fact knuckle and bottom of shock absorber in one part) is constrained spherical to "SteeringRod" and axially coincident to "ShockTopRF".
SteeringRod (yellow on model) is spherically connected on both ends between fixed mounting point (FixSphere_001) and knuckle.
"ShockTopRE" (top grey part of shock absorber) is spherically connected to fixed |FixSphere_002) on top.

All files included - A2+ assembly is in file frontAsm.FCStd, in two other FCStd are models used in assembly.
Also I attached few pictures of assembly and tree.

And in general model works, can be solved resulting proper alignment of all parts with message:

Code: Select all

===== Start Solving System ====== 
20:20:35  
20:20:35  convergency-conter: 151
20:20:35  Calculation stopped, no convergency anymore!
20:20:35  TARGET   POS-ACCURACY :0.0001
20:20:35  REACHED  POS-ACCURACY :0.00013470727165820507
20:20:35  TARGET  SPIN-ACCURACY :0.0001
20:20:35  REACHED SPIN-ACCURACY :9.659346157805867e-06
20:20:35  SA SPIN-ACCURACY      :0.00021294593556323688
20:20:35  ===== System solved using partial + recursive unfixing =====
But when trying to animate it, in positions where lower arm is closer to horizontal positions, everything starts to broke apart, with an message "animation problem detected", that happen every time when reaching similar position of model. When "animation problem detected" appears, I can still click on "solve constrains" and it works, but still can move model in that direction.

But is works quite well in position where lower arm is nearly vertical.
Positions where problem occurs not seem to be complicated - nothing is strained, all angles looks sane, so have no idea why.

Any advice how to handle such issue?
Is this possible to run solver in more verbose mode, to be able to understand/debug such problem by myself?

Thanks :)
mcpherson.jpg
mcpherson.jpg (143.53 KiB) Viewed 11973 times

A2plus V0.4.47e
OS: Ubuntu 20.04.1 LTS (ubuntu:GNOME/ubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.23058 (Git)
Build type: Release
Branch: master
Hash: 6e60870ebcb2df018adb7a1281c00dde87750f11
Python version: 3.8.6
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)
Attachments
frontAsm.FCStd
(57.44 KiB) Downloaded 171 times
armRF-simple.FCStd
(220.06 KiB) Downloaded 168 times
armRF.FCStd
(189.59 KiB) Downloaded 185 times
tree.jpg
tree.jpg (106 KiB) Viewed 11973 times
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 »

topyra wrote: Sat Nov 28, 2020 7:30 pm I am trying to make a McPherson strut using A2+, but encountered wired problem with moving parts.
Error "animation problem detected" appears in positions where whole model should behave quite stable (nothing "strained", all angles looks good etc.)

...

But when trying to animate it, in positions where lower arm is closer to horizontal positions, everything starts to broke apart, with an message "animation problem detected", that happen every time when reaching similar position of model. When "animation problem detected" appears, I can still click on "solve constrains" and it works, but still can move model in that direction.
Hi,
nice model ! I can reproduce the problem and i guess, this is some instability of the axisCoincident constraint. I will have a look at the code, whether there is a bug or something else what can be improved.

As a temporary solution i inserted an additional pointOnLine constraint, see the red parts in the screenshot.
.
New-PointOnLine-Constraint.png
New-PointOnLine-Constraint.png (98.31 KiB) Viewed 17778 times
.
Compared to other numeric solvers the one of A2+ is not sensitive to redundant constraints and sometimes an additional constraint can stabilize computations. With adding the pointOnLine constraint at least i could extend the range where the simulation is working properly.

Nevertheless something is wrong with the solver here. But i need time to investigate this. Please find the modified files attached.
.
topyra wrote: Sat Nov 28, 2020 7:30 pm Is this possible to run solver in more verbose mode, to be able to understand/debug such problem by myself?
Unfortunately there is no more verbose mode. Debugging of such issues is very complex and is usually done with a lot of printouts from the code.
Attachments
a2p-McPherson-modified.zip
(482.24 KiB) Downloaded 176 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
Post Reply