FreeGCS 3D constraints

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
jriegel
Site Admin
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: FreeGCS 3D constraints

Postby jriegel » Tue Nov 08, 2011 7:19 pm

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: 654
Joined: Mon Jun 14, 2010 6:00 pm

Re: FreeGCS 3D constraints

Postby logari81 » Tue Nov 08, 2011 8:18 pm

@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
Posts: 2922
Joined: Wed Oct 05, 2011 7:36 am

Re: FreeGCS 3D constraints

Postby ickby » Tue Nov 08, 2011 8:59 pm

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
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: FreeGCS 3D constraints

Postby NormandC » Tue Nov 08, 2011 11:41 pm

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: 654
Joined: Mon Jun 14, 2010 6:00 pm

Re: FreeGCS 3D constraints

Postby logari81 » Tue Nov 15, 2011 2:22 pm

@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
Posts: 2922
Joined: Wed Oct 05, 2011 7:36 am

Re: FreeGCS 3D constraints

Postby ickby » Wed Nov 16, 2011 2:25 pm

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
Posts: 2922
Joined: Wed Oct 05, 2011 7:36 am

Re: FreeGCS 3D constraints

Postby ickby » Wed Nov 30, 2011 1:26 pm

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 74 times
User avatar
yorik
Site Admin
Posts: 11552
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: FreeGCS 3D constraints

Postby yorik » Wed Nov 30, 2011 2:09 pm

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
Posts: 8744
Joined: Mon Dec 12, 2011 4:45 pm

Re: FreeGCS 3D constraints

Postby triplus » Sat Dec 24, 2011 1:58 pm

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

Re: FreeGCS 3D constraints

Postby ickby » Mon Jan 09, 2012 1:51 pm

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.
cron