Skip to content

Commit 2dc7b4e

Browse files
committed
add speed and power
1 parent 21a7b0b commit 2dc7b4e

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/OpenCOVER/plugins/hlrs/TacxFTMS/TacxFTMS.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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();

src/OpenCOVER/plugins/hlrs/TacxFTMS/TacxFTMS.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class PLUGINEXPORT TacxFTMS : public opencover::coVRPlugin, public opencover::co
9494
osg::Matrix getMatrix();
9595
osg::Matrix TransformMat;
9696
osg::Matrix TacxFTMSPos;
97+
osg::Matrix invTacxFTMSPos;
9798
void setEnabled(bool) override;
9899
void updateThread();
99100
std::unique_ptr<UDPComm> udpNeo=nullptr;

0 commit comments

Comments
 (0)