Another approach to assembly solver (A2plus)

Discussion about the development of the Assembly workbench.
User avatar
kkremitzki
Posts: 2168
Joined: Thu Mar 03, 2016 9:52 pm
Location: Texas

Re: Another approach to assembly solver (A2plus)

Postby kkremitzki » 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.
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
User avatar
openfablab
Posts: 62
Joined: Wed Nov 02, 2016 4:42 pm
Contact:

Re: Another approach to assembly solver (A2plus)

Postby openfablab » Thu Sep 24, 2020 7:48 pm

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: 173
Joined: Tue Jul 28, 2020 7:31 am

Re: Another approach to assembly solver (A2plus)

Postby Smiling_user » 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.
User avatar
openfablab
Posts: 62
Joined: Wed Nov 02, 2016 4:42 pm
Contact:

Re: Another approach to assembly solver (A2plus)

Postby openfablab » Fri Sep 25, 2020 11:18 am

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 555 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: 67
Joined: Fri Apr 24, 2015 10:21 am

Re: Another approach to assembly solver (A2plus)

Postby EskiBrew » Tue Oct 20, 2020 9:57 am

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

Re: Another approach to assembly solver (A2plus)

Postby kbwbe » Tue Oct 20, 2020 4:39 pm

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 387 times
no-toponaming-2.png
no-toponaming-2.png (6.06 KiB) Viewed 387 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 387 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 387 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 8 times
KBWBE

https://github.com/kbwbe/A2plus
latest release: v0.4.47f, 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: 67
Joined: Fri Apr 24, 2015 10:21 am

Re: Another approach to assembly solver (A2plus)

Postby EskiBrew » Tue Oct 20, 2020 8:50 pm

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: 67
Joined: Fri Apr 24, 2015 10:21 am

Re: Another approach to assembly solver (A2plus)

Postby EskiBrew » Sat Oct 31, 2020 12:05 pm

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 257 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 10 times
Turro75
Posts: 176
Joined: Mon Aug 15, 2016 10:23 pm

Re: Another approach to assembly solver (A2plus)

Postby Turro75 » Sun Nov 01, 2020 8:45 pm

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 8 times
a2p_test_rotation.FCStd
(10.47 KiB) Downloaded 8 times
topyra
Posts: 8
Joined: Thu Nov 12, 2020 8:55 pm

Re: Another approach to assembly solver (A2plus)

Postby topyra » Sat Nov 28, 2020 7:30 pm

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 50 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 2 times
armRF-simple.FCStd
(220.06 KiB) Downloaded 2 times
armRF.FCStd
(189.59 KiB) Downloaded 2 times
tree.jpg
tree.jpg (106 KiB) Viewed 50 times