Home › Forum › SOFA › Using SOFA › [SOLVED] Error in RigidRigidMapping (v15.09)
- This topic has 8 replies, 3 voices, and was last updated 8 years, 10 months ago by
Deimel.
-
AuthorPosts
-
16 September 2015 at 13:29 #3596
Deimel
BlockedHello all,
I just noticed an error in the RigidRigidMapping when the parameter globalToLocalCoords is set to true. I created a test scene to show the problem.
The upper node is without RigidRigidMapping (showing the positions of the DOFs).
The lower node is with: <RigidRigidMapping repartition=”2 “globalToLocalCoords=”1” />The expected result is (imho) that the mapped DOFs (smaller trihedra) retain their global position, but some of them get displaced.
git commit: a93d18d453b35b130abe1fc2dd52443549ca5ae4 (current v15.09 branch)
Best,
Raphael Deimel16 September 2015 at 13:39 #3597Deimel
Blocked3 October 2015 at 09:39 #3730Deimel
BlockedSeems like the rotations are applied to MechanicalObject’s in the wrong order. As long as either of the rotation property or the DoF’s orientation in the position property are not set (or set to 0 0 0 1), this bug does not affect the outcome.
Here’s the simple fix:
diff --git a/modules/SofaBaseMechanics/MechanicalObject.cpp b/modules/SofaBaseMechanics/MechanicalObject.cpp index 074ea8e..9c32cfe 100644 --- a/modules/SofaBaseMechanics/MechanicalObject.cpp +++ b/modules/SofaBaseMechanics/MechanicalObject.cpp @@ -132,7 +132,7 @@ void MechanicalObject<defaulttype::Rigid3dTypes>::applyRotation (const defaultty for (unsigned int i = 0; i < x.size(); i++) { x[i].getCenter() = q.rotate(x[i].getCenter()); - x[i].getOrientation() *= q; + x[i].getOrientation() = q * x[i].getOrientation(); } }
It would be nice if somebody with repository access could fix the patch 🙂 Here’s a simple testcase to check the result:
<?xml version="1.0"?> <!-- the point frame coordinates are rotated in global frame, but the orientation is rotated in local frame --> <Node name="root" gravity="0 -9.81 0" dt="1e-4" time="0" > <BackgroundSetting name="prettify" color=" 0 0 0" /> <ViewerSetting cameraMode="Orthographic" /> <VisualStyle name="visualStyle1" displayFlags="showVisual showBehaviorModels hideForceFields showInteractionForceFields hideCollision hideMapping hideOptions" /> <MultiStepAnimationLoop collisionSteps="1" integrationSteps="5"/> <MechanicalObject template="Rigid3d" name="DOFs" showObjectScale="2.5" showObject="1" rest_position=" 0 0 0 0 0 0 1 32.1804178343 0.0 11.73187801 0.0 0.371991451914 0.0 -0.928236155137 42.4985667543 0.0 38.9022536239 0.0 0.702721776175 0.0 -0.711464760399 " translation="0 0 0" rotation="0 0 0" /> <MechanicalObject template="Rigid3d" name="DOFs" showObjectScale="2.5" showObject="1" rest_position=" 0 0 0 0 0 0 1 32.1804178343 0.0 11.73187801 0.0 0.371991451914 0.0 -0.928236155137 42.4985667543 0.0 38.9022536239 0.0 0.702721776175 0.0 -0.711464760399 " translation="0 0 0" rotation="0 0 30" /> </Node> </Node>
3 October 2015 at 09:44 #3731Deimel
BlockedThe forum does not seem to handle code correctly :/
Patch:
http://pastebin.com/cE3X4YENTestcase:
http://pastebin.com/X10WnYPH4 October 2015 at 11:00 #3734Hugo
KeymasterThank you very much Raphael for your post ! This information will be forwarded to the developers.
By the way, concerning the forum, it is now possible to:
insert code using the
instruction before your code
but we acknowledge it is not perfect yet !
The format of the users' profile has been corrected : the nickname will really be used in the forum. You just need to re-edit the profile once and fill in the nickname.
Cheers,
Hugo
6 October 2015 at 13:19 #3740max
BlockedHello Raphael,
I had a quick look at your test scene and it seems that the
repartition
is the issue.More precisely, if you get rid of the repartition field in the mapping, like this:
<RigidRigidMapping globalToLocalCoords="1" />
then the problem seems to go away. Can you confirm this ?
The semantic for
repartition
is somewhat complex, and admittedly the doc does not help much. I did not dwelve into it yet (anyone?) but as long as you simply want 1->1 mappings between rigid bodies, you’d better removerepartition
andindex
informations altogether.Hope this helps,
Maxime
13 October 2015 at 22:42 #3743Deimel
BlockedHello Maxime,
Please have a look at the testcase I posted, it doesn’t contain a RigidRigidMapping directive but nevertheless rotates the DOFs around the wrong axis (the DoF’s frame instead of the global frame).
Best,
Raphael21 October 2015 at 16:46 #3811max
BlockedHello Deimel, and sorry for the delay.
You are correct, the multiplication order is inconsistent.
2c9f6b4 on master applies your changes (+ float rigid types). Do we need to backport it to another branch ?
Thanks again for your patch.
Best,
max.
24 October 2015 at 19:00 #3872Deimel
BlockedIt would probably be nice to also fix it in the current “stable” v15-09 branch.
Best,
Raphael -
AuthorPosts
- You must be logged in to reply to this topic.