FreeGCS 3D constraints

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: FreeGCS 3D constraints

Post by jriegel »

Good job indeed! Im looking forward on integration!!

As soon as the 0.12 is history we should go right after that!
Stop whining - start coding!
logari81
Posts: 658
Joined: Mon Jun 14, 2010 6:00 pm

Re: FreeGCS 3D constraints

Post by logari81 »

@ickby
concerning the LM solver, I think we should incorporate it into the 2D version as well. Let us meet in #freecad on freenode in order to synchronize our versions as far as we can.
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: FreeGCS 3D constraints

Post by ickby »

thank you guys!

@logari: i wont make it to the irc today, but maybe tomorrow evening! i will look out for you.
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: FreeGCS 3D constraints

Post by NormandC »

A-W-E-S-O-M-E :)

v0.12 is already kicking @ss, but I think we're going to be short on superlatives for v0.13! 8-)
logari81
Posts: 658
Joined: Mon Jun 14, 2010 6:00 pm

Re: FreeGCS 3D constraints

Post by logari81 »

@ickby:
now that we have the DogLeg and Levenberg-Marquardt solvers included in FreeGCS I will need your help to make them respect the subsys->maxStep(xdir) limit. Could we meet on IRC one of these days?
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: FreeGCS 3D constraints

Post by ickby »

Hello logari,

I've looked into the maxStep problem and as we discussed yesterday the best way to go is just to scale the calculatet step by it's infinity norm.
here ist some code (both time the same, just diffrent in position, first LM then DL:

Code: Select all

 // check if solving works
            if (rel_error < 1e-5) {

                //new maxStep scaling
		              double scale = subsys->maxStep() / h.lpNorm<Eigen::Infinity>();
		              if( scale < 1.) 
		                    h *= scale;
		
                // compute par's new estimate and ||d_par||^2
                x_new = x + h;
                double h_norm = h.squaredNorm();

Code: Select all

// see if we are already finished
        if (stop)
            break;

        double scale = subsys->maxStep() / h_dl.lpNorm<Eigen::Infinity>();
        if ( scale < 1.)
            h_dl *= scale;

        // get the new values
ickby
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: FreeGCS 3D constraints

Post by ickby »

Hello,

I wasn't able to code much the last weeks, but as talked about long ago in the irc with logari I updated my test enviroment for the assembly constraints. It's in the attached archive, together with some examples. It's based on the latest FreeCGS implementation (just stripped down). Involve the executable as follows:

Code: Select all

solver inputfile outputfile
This will generate a python script (outputfile) interpretable by freecad which shows the faces bevore and after solving. (not too useful, but nice to see)

@logari: As you remember I stated that the system wasn't working very well, but to be honest i cant reproduce any of the failures in this test environment. So it seems my hacky freecad integration has an error somewhere (even if after some extensive searching im still lost wehre it should be). All not working cases I ported to a xml example worked in the test environment, the examples are therefore not usefull at all.

So whats the sense of this post then? I don't know, maybe the notice that I'm still working on it :)

ickby
Attachments
testenvironment.zip
executable to test current solver implementation
(33.15 KiB) Downloaded 105 times
User avatar
yorik
Founder
Posts: 13630
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: FreeGCS 3D constraints

Post by yorik »

ickby wrote:So whats the sense of this post then? I don't know, maybe the notice that I'm still working on it
That's the best notice anyway! :)
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: FreeGCS 3D constraints

Post by triplus »

Video of assembly with constrains looks great! Can't Wait! :)
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: FreeGCS 3D constraints

Post by ickby »

Hello

It's me again, thougth I give some updates on my quest for an working assembly solver. I failed to get the pure numeric approach used in FreeCGS to work reliable in an assembly context (rotations & translations), no matter what i was trying it failed for only few parts. Annoyed of all that fiddling I've started to create a hybrid approach, combining the numeric with a constraint-propagation method. This went quite nice, and rigth now a unlimited number of parts can be assembled acyclic without problems. Cyclic configurations however are still buggy, but I've just started coding this with the new approach.

How it works: All constraints are represented solver-intern in an undirected graph. For solving one part is fixed, and a spanning tree from this part along the constraints is created. Every constraint is then allowed to "propagate" itself in respekt to the part bevore, create a equation for some variables of the second part depending on variables of the first. This leads to a (quite huge) equation system, where most free variables are alredy eliminated. Only if no propagation is possible (in a cyclic configuration for example), a objective function is added and solved numerical (thats the part that is still not working so good). For this numeric solving and due to the variable eqaution system I use automatic differentation approach to get the needed jacobi matrices.

Thats my current state of work. I may have overcomplicated things, but I'm getting closer to something usable and hope the solver to be ready soon!

ickby.
Post Reply