@@ -75,6 +75,7 @@ bool TacxFTMS::init() {
7575 MAKE_EULER_MAT (TacxFTMSPos, h, p, r);
7676 TacxFTMSPos.postMultTranslate (osg::Vec3 (x, y, z));
7777
78+ invTacxFTMSPos.invert (TacxFTMSPos);
7879
7980 /* std::cerr << "TacxFTMS config: UDP: serverHost: " << host
8081 << ", localPort: " << localPort << ", serverPort: " << serverPort
@@ -200,7 +201,7 @@ bool TacxFTMS::update() {
200201 osg::Vec3 V (0 , s, 0 );
201202 float rotAngle = 0.0 ;
202203 float wheelAngle = - getAngle () / 100.0 ;
203- // fprintf(stderr, "wheelAngle: %f\n", wheelAngle);
204+ fprintf (stderr, " wheelAngle: %f\n " , wheelAngle);
204205
205206 if (fabs (s) < 0.001 || fabs (wheelAngle) < 0.001 ) {
206207 rotAngle = 0 ;
@@ -222,7 +223,9 @@ bool TacxFTMS::update() {
222223
223224 auto mat = getMatrix ();
224225
225- TransformMat = mat * relTrans * relRot;
226+ fprintf (stderr, " rotAngle: %f\n " , rotAngle);
227+ // TransformMat = mat * relTrans * invTacxFTMSPos *relRot * TacxFTMSPos;
228+ TransformMat = mat * relTrans *relRot;
226229 coVRMSController::instance ()->sendSlaves (TransformMat.ptr (),
227230 sizeof (osg::Matrix::value_type) * 16 );
228231 } else {
@@ -456,6 +459,13 @@ osg::Matrix TacxFTMS::getMatrix()
456459
457460 osg::Matrix newMatrix;
458461 osg::Vec3d translation = front.getWorldIntersectPoint ();
462+ // cerr << "trans:" << TransformMat(3,2) << "front " <<front.getWorldIntersectPoint()[2] << "Tacx" <<TacxFTMSPos.getTrans()[2]<< endl;
463+ // cerr << "transN:" << front.getWorldIntersectPoint()[2]-TacxFTMSPos.getTrans()[2] << endl;
464+
465+ osg::Matrix tmp;
466+ tmp.makeTranslate (0 , 0 , -(front.getWorldIntersectPoint ()[2 ]-TacxFTMSPos.getTrans ()[2 ]));
467+ TransformMat.postMult (tmp);
468+ return TransformMat;
459469
460470 /* osg::Vec3d newY =
461471 front.getWorldIntersectPoint() - back.getWorldIntersectPoint();
0 commit comments