diff --git a/source/RobotAPI/components/units/RobotUnit/NJointControllers/NJointCartesianWaypointController.cpp b/source/RobotAPI/components/units/RobotUnit/NJointControllers/NJointCartesianWaypointController.cpp index f7087a226d59906ad7794a123742953d68e4c589..0078a0e05e3743fd076f257e7a45777ca8253873 100644 --- a/source/RobotAPI/components/units/RobotUnit/NJointControllers/NJointCartesianWaypointController.cpp +++ b/source/RobotAPI/components/units/RobotUnit/NJointControllers/NJointCartesianWaypointController.cpp @@ -91,6 +91,11 @@ namespace armarx _rtVelSensors.emplace_back(&(sv->velocity)); } } + //visu + { + _tripFakeRobotGP.getWriteBuffer()(0, 0) = std::nanf(""); + _tripFakeRobotGP.commitWrite(); + } } void NJointCartesianWaypointController::rtPreActivateController() @@ -308,6 +313,21 @@ namespace armarx ARMARX_CHECK_NOT_NULL(_rtForceSensor); _setFTOffset = true; } + + void NJointCartesianWaypointController::setVisualizationRobotGlobalPose(const Eigen::Matrix4f& p, const Ice::Current&) + { + std::lock_guard g{_tripFakeRobotGPWriteMutex}; + _tripFakeRobotGP.getWriteBuffer() = p; + _tripFakeRobotGP.commitWrite(); + } + + void NJointCartesianWaypointController::resetVisualizationRobotGlobalPose(const Ice::Current&) + { + std::lock_guard g{_tripFakeRobotGPWriteMutex}; + _tripFakeRobotGP.getWriteBuffer()(0, 0) = std::nanf(""); + _tripFakeRobotGP.commitWrite(); + } + void NJointCartesianWaypointController::stopMovement(const Ice::Current&) { std::lock_guard g{_tripBufWpCtrlMut}; @@ -363,8 +383,10 @@ namespace armarx const auto& buf = _tripRt2NonRt.getUpToDateReadBuffer(); if (buf.tcp != buf.tcpTarg) { - const Eigen::Matrix4f gtcp = buf.rootPose * buf.tcp; - const Eigen::Matrix4f gtcptarg = buf.rootPose * buf.tcpTarg; + const Eigen::Matrix4f fakeGP = _tripFakeRobotGP.getUpToDateReadBuffer(); + const Eigen::Matrix4f gp = std::isfinite(fakeGP(0, 0)) ? fakeGP : buf.rootPose; + const Eigen::Matrix4f gtcp = gp * buf.tcp; + const Eigen::Matrix4f gtcptarg = gp * buf.tcpTarg; drawer->setPoseVisu(getName(), "tcp", new Pose(gtcp)); drawer->setPoseVisu(getName(), "tcptarg", new Pose(gtcptarg)); drawer->setLineVisu( diff --git a/source/RobotAPI/components/units/RobotUnit/NJointControllers/NJointCartesianWaypointController.h b/source/RobotAPI/components/units/RobotUnit/NJointControllers/NJointCartesianWaypointController.h index 16ebac8c13fa0acba8a0e96ce4950a428461aa68..d16afbcbe35a604e85dba2ff80972db59fb3b227 100644 --- a/source/RobotAPI/components/units/RobotUnit/NJointControllers/NJointCartesianWaypointController.h +++ b/source/RobotAPI/components/units/RobotUnit/NJointControllers/NJointCartesianWaypointController.h @@ -61,6 +61,9 @@ namespace armarx FTSensorValue getFTSensorValue(const Ice::Current& = Ice::emptyCurrent) override; void setCurrentFTAsOffset(const Ice::Current& = Ice::emptyCurrent) override; + + void setVisualizationRobotGlobalPose(const Eigen::Matrix4f& p, const Ice::Current& = Ice::emptyCurrent) override; + void resetVisualizationRobotGlobalPose(const Ice::Current& = Ice::emptyCurrent) override; protected: void rtPreActivateController() override; void rtPostDeactivateController() override; @@ -120,6 +123,9 @@ namespace armarx mutable std::recursive_mutex _tripRt2NonRtMutex; TripleBuffer<RtToNonRtData> _tripRt2NonRt; + mutable std::recursive_mutex _tripFakeRobotGPWriteMutex; + TripleBuffer<Eigen::Matrix4f> _tripFakeRobotGP; + //publish data std::atomic_size_t _publishWpsNum{0}; std::atomic_size_t _publishWpsCur{0}; diff --git a/source/RobotAPI/interface/units/RobotUnit/NJointCartesianWaypointController.ice b/source/RobotAPI/interface/units/RobotUnit/NJointCartesianWaypointController.ice index 4d722bb953bac5b6b14badefb5bb93bdba23c5ad..765afbb10068a59ecec091e416dfdff73b0d2ea7 100644 --- a/source/RobotAPI/interface/units/RobotUnit/NJointCartesianWaypointController.ice +++ b/source/RobotAPI/interface/units/RobotUnit/NJointCartesianWaypointController.ice @@ -63,5 +63,8 @@ module armarx FTSensorValue getFTSensorValue(); void setCurrentFTAsOffset(); void stopMovement(); + + void setVisualizationRobotGlobalPose(Eigen::Matrix4f p); + void resetVisualizationRobotGlobalPose(); }; };