Closed fjourdes closed 5 years ago
I believe that if that branch makes it way to master, someone at mimesis should have close look too.
I am ready to rebase your branch on issofa_constraintsolving (updated with master). Are you OK for me to force push?
You will do it in a branch of Master ? I was suppose to push it on sofaDefrost but if you are doing it on the Master, that's even better...
@guparan : I think it is fine to rebase with the updated issofa_constraint_solving branch. I believe the conflicts come from the override
keyword that was added in many places in the code recently.
The integration branch fjourdes:insimo_freemotion_integration will still work if someone wants want to try.
It's done. Yes most of the conflicts went from override
keywords.
@ChristianDuriez I did it on this branch to be able to easily rebase it on master when #484 will be merged.
This PR will be rebased and reviewed this week. Any help in review would be most welcome @EulalieCoevoet ;)
This PR is now rebased and aiming master. Review shall begin!
[ci-build][with-scene-tests]
ping @EulalieCoevoet :-)
[ci-build]
hey @EulalieCoevoet will you be available to review this PR by next week ? This PR starts being a bit old. Thanks !
Hi, Big sorry for the late answer... I'm looking at it now.
So I have tested the branch fjourdes:insimo_freemotion_integration with our plugins. Our tests and examples ran fine. I have read the very well detailed changelog (thanks for that) and from what I know it looks fine. I didn't review the files changes, because there is too much to look at... but I would agree to merge. Again, I'm really sorry for the late answer.
Thank you for your feedback Eulalie! I guess some fixes / merges are required to fit the current master.
To start with, let's [ci-build]
@fjourdes could you please confirm that my fix in 792d95c is not breaking your changes?
Wrong fix replaced with correct one :-)
[ci-build][with-scene-tests]
Damned, it seems there's some test failing with BilateralInteractionConstraint_test/0.checkVec3ConstrainedPositions
@EulalieCoevoet there is an issue with the test, do you have time within the 7 upcoming days to have a look at it ? either the test needs to be updated, or the code to be fixed. Let us know if you don't ;)
Ok, this PR is almost there. Only one test is failing. @fjourdes have you few minutes to check it out ? thx
[ci-build][with-scene-tests]
test BilateralInteractionConstraint_test failing due to the constraint which is not exactly met
Hi, I think I have solved the test problem.. by changing the test ! It was not designed to take into account the tolerance of the solver... see commit: https://github.com/fjourdes/sofa/commit/78b84592651836809078c18971300f6abde6806a
Hi Christian,
Using a tolerance is working, but is this normal that the constraint is not exactly applied? (although it was before)
[ci-build][with-scene-tests]
@hugtalbot , @ChristianDuriez Can you reproduce locally the problem that happens in ubuntu or is this a CI issue ?
I am not on Ubuntu. It seems to be a problem with a test in the Flexible plugin.
@ChristianDuriez
One scene was crashing in SensableEmulation plugin : testOmniDriverEmu.scn
I fixed it by adding the option : solveVelocityConstraintFirst="true"
. I have no idea why actually! Could you give some insight?
I fixed some added warnings, let me know if this was normal: Note that :
What appears really necessary, is to have some documentation on this constraint pipeline. This could be a good task for the STC#5 don't you think?
[ci-build][with-scene-tests]
Conflicts are again fixed, if it compiles the PR will have to be merged asap
[ci-build][with-scene-tests]
Merge ...
Delay problem still exists using Geomagic plugin. See https://www.sofa-framework.org/community/forum/topic/problem-about-geomagic-plugin-in-v18-12/
Thanks @fangzhouzisb This is not the correct place to ask, here the pull-request has been merged and focuses on FreeAnimationLopp Do not hesitate to create a dedicated issue referring (as you did) the forum topic.
This PR diffs against the sofa-framework::issofa_constrainsolving branch until it has been merged into master.
Objectives
Requirements
The following PR are required in order to build this
484 ✔️
450 ✔️
452 ✔️
456 ✔️
For testing:
SOFA_USE_MASK
must be deactivated, otherwise derivatives quantities ( velocity at contact points for example) are not propagated at all since all dofs are "masked" by default. After having a rather quick look, apparently theSOFA_USE_MASK
impose some strict (undocumented) requirements (on top of other limitations like the fact that it does not support changes in the topology) about where in the time step the "apply" method of mappings is called.There is a branch on my local fork that integrates all the requirements for testing that can be found at the following location fjourdes:insimo_freemotion_integration
Changelog
API Breaking
[SofaCore]
ConstraintSolver
can now define the VecId where the constraint lambdas and constraint correction are stored. Previously, these were fixed locations, usually VecId::externalForce() and VecId::dx(), but it could vary depending on the implementation of both the ConstraintSolver and the ConstraintCorrection API. Components can retrieve these locations when inspecting their ConstraintParams object which is usually a parameter of the API methods for constraint solving.ConstraintParams
contains theMultiMatrixDerivId
that can be used by components related to theConstraintSolver
to retrieve the location of the constraint jacobian.ConstraintResolution
API constructor needs to be passed the number of lines that are involved in the solving of this constraint equation. The previous implementation was silently initializing this value to one. If that property has to modified because it depends on some other state variables of a concrete implementation of theConstraintResolution
, thesetNbLines
method has to be called to reflect it. Also added some getters/setters method.BaseConstraintCorrection
API separates the methods which computes the constraint displacement in motion space from the methods which apply it.ConstraintCorrection
APIBaseConstraint
API defines astoreLambda
method which is used to store the result of the constraint force computation (stored in aBaseVector
form) inside a dedicated state vector of aMechanicalState
. Requires PR #456. This value can be used later on to discover the stiffness coming from the non linear mapping that result from it.BaseMechanicalState
resetConstraint
andgetConstraintJacobian
methods need to be given aConstraintParams
to be able to retrieve theMatrixDerivId
containing the constraint jacobian.LinearSolver
APIapplyContactForce
API method intoapplyConstraintForce
. This method is no longer responsible for applying the corrective motion, but just to compute it.buildComplianceMatrix
API method needs to be passed aConstraintParams
so that concrete instances ofLinearSolver
can retrieve theMatrixDerivId
that points to the constraint jacobian.FIX
[SofaConstraint]
GenericConstraintSolver
block gauss seidel can support arbitrary size of blocks. The previous implementation had an hard coded limit of 6 for the block size.UPDATES
[SofaSimulationCore]
AnimateVisitor
,MechanicalGetConstraintJacobianVisitor
andMechanicalResetConstraintVisitor
to the changes introduced inBaseMechanicalState
API[SofaBaseMechanics]
MechanicalObject
dynamically allocated state vectors are given a name and a owner like any other Data. As a result, these dynamic state vectors can be displayed by the GUI. Also adapted the code to the API changes introduced inBaseMechanicalState
API[SofaMeshCollision]
updateXfree()
method were not callingapplyJ
and therefore were not propagating the free velocity towards contact dofs, resulting in segfault when solving constraints in velocity mode.[SofaConstraint]
GenericConstraintSolver
accumulates the constraint lambdas towards independant dofs, so that non linear mappings can compute the geometric stiffness induced by the constraint forces from the previous time step.FreeMotionAnimationLoop
assembles mapping geometric stiffness when possible. It also uses a single mapping linearisation within the time step. The solving step becomes very similar to the one explained in the "Stable Constraints" paper, when the compliance of the constraint is equal to zero.BilateralConstraintResolutionNDofs
uses Eigen library to factorize a constraint block of arbitrary size using LDLT decomposition.ConstraintAnimationLoop
minor changes introduced to reflect API changes.[SofaMiscMapping]
DistanceMapping
implements theapplyJT
method forMatrixDeriv
types using the utility methods provided in #452[SofaGeneralAnimationLoop]
MultiStepAnimationLoop
andMultiTagAnimationLoop
: adapted code to reflect API change.ADD
[SofaConstraint]
MappingGeometricStiffnessForceField
can assemble the geometric stiffness of a mapping.UniformConstraint
defines a constraint with a uniform direction in the contact space, internally it represents an identity matrix. It computes the right hand side of constraint equations in velocity mode asrhs = phi / dt + dvfree
, following the same calculus notation and derivation as the one explained in the "Stable Constraints" paper. In position mode the constraint rhs differs from the constraint rhs in velocity mode by adt
factor.rhs = phi + dvfree * dt
which givesrhs = dxfree
which is similar to what was done by the previous implementation.ConstraintStoreLambdaVisitor
which is used by theGenericConstraintSolver
to store the lambda resulting from the constraint solving step into a specific location ( by defaultVecId::externalForce()
, but a dynamicVecId
can be used also)[Examples]
InextensiblePendulum.scn
shows the benefits of the linearisation of the constraint forceRemarks
MappingGeometricStiffnessForceField
suffers the same limitation as any other forcefield, ie the mapping must be directly connected to the independant dofs, otherwise it would require an additional unsupported computation to project the mapped stiffness matrix into the space of the independant degrees of freedom. Multimappings support is not there, since it would probably require some adapatation in the API, so that it is easy to retrieve the stiffness block associated with each of the mapping parent dofs.ContactMappers : It is (very) questionable to let contact mappers propagate the unconstrained dynamics solution vector towards contact dofs by calling
updateXfree()
since it will induce inconsistencies in mapping linearisation if the contact mappers are non linear, since contact mappings will therefore be linearised around the free motion configuration, and the rest being linearised around the configuration at the beginning of the time step. This PR does not address this problem which is left for future work. It arises only with non linear contact mappers (like theRigidContactMapper
for instance), but this should be kept in mind.LinearSolver API : As a general note, I believe the LinearSolver API is a bloated with virtual methods which are difficult to understand since they are not directly related to the computation / factorisation of a positive definite matrix, and are mostly optional especially for non assembled solver like CG. Most of the methods should reside in the ConstraintCorrection API, and concrete instance of ConstraintCorrection should be templated on the type of LinearSolver in my opinion, since it is the only objects that actually make use of these methods, and really what you want is to have access to the concrete type of Matrix and Vector used by the solver. Also from my understanding only
LinearSolver
instances that derive fromMatrixLinearSolver
implement these kind of methods, so maybe a first step would be to move them here.This PR:
Reviewers will merge only if all these checks are true.