3 #include <VirtualRobot/VirtualRobot.h>
8 #include <RobotAPI/interface/units/RobotUnit/NJointCartesianNaturalPositionController.h>
22 public NJointCartesianNaturalPositionControllerInterface
25 using ConfigPtrT = NJointCartesianNaturalPositionControllerConfigPtr;
28 const NJointCartesianNaturalPositionControllerConfigPtr& config,
32 std::string
getClassName(
const Ice::Current& = Ice::emptyCurrent)
const override;
46 void setConfig(
const CartesianNaturalPositionControllerConfig& cfg,
47 const Ice::Current& = Ice::emptyCurrent)
override;
49 const Eigen::Vector3f& elbowTarget,
51 const Ice::Current& = Ice::emptyCurrent)
override;
53 const Eigen::Vector3f& elbowTarget,
56 const Ice::Current&)
override;
59 void setNullspaceTarget(
const Ice::FloatSeq& nullspaceTarget,
const Ice::Current&)
override;
65 void setFTOffset(
const FTSensorValue& offset,
const Ice::Current&)
override;
67 void setFTLimit(
float force,
float torque,
const Ice::Current&)
override;
69 void setFakeFTValue(
const FTSensorValue& ftValue,
const Ice::Current&)
override;
73 void stopMovement(
const Ice::Current& = Ice::emptyCurrent)
override;
76 const Ice::Current& = Ice::emptyCurrent)
override;
88 Eigen::Vector3f elbowTarget;
102 CartesianNaturalPositionControllerConfig cfg;
103 bool updated =
false;
108 std::vector<float> nullspaceTarget;
109 bool clearRequested =
false;
110 bool updated =
false;
115 Eigen::Vector3f force = Eigen::Vector3f::Zero();
116 Eigen::Vector3f torque = Eigen::Vector3f::Zero();
117 bool updated =
false;
124 bool updated =
false;
129 Eigen::Vector3f force = Eigen::Vector3f::Zero();
130 Eigen::Vector3f torque = Eigen::Vector3f::Zero();
132 bool updated =
false;
137 Eigen::Vector3f force = Eigen::Vector3f::Zero();
138 Eigen::Vector3f torque = Eigen::Vector3f::Zero();
158 std::atomic<float> errorPos{0};
159 std::atomic<float> errorOri{0};
160 std::atomic<float> errorPosMax{0};
161 std::atomic<float> errorOriMax{0};
162 std::atomic<float> tcpPosVel{0};
163 std::atomic<float> tcpOriVel{0};
164 std::atomic<float> elbPosVel{0};
170 void setNullVelocity();
171 FTSensorValue frost(
const FTval& ft);
173 using Ctrl = CartesianNaturalPositionController;
177 VirtualRobot::RobotNodeSetPtr _rtRns;
178 VirtualRobot::RobotNodePtr _rtTcp;
179 VirtualRobot::RobotNodePtr _rtElbow;
180 VirtualRobot::RobotNodePtr _rtFT;
181 VirtualRobot::RobotNodePtr _rtRobotRoot;
183 std::unique_ptr<Ctrl> _rtPosController;
184 bool _rtSetOrientation =
true;
185 Eigen::VectorXf _rtJointVelocityFeedbackBuffer;
187 int _rtFFvelMaxAgeMS;
188 long _rtFFvelLastUpdateMS = 0;
190 std::vector<const float*> _rtVelSensors;
191 std::vector<float*> _rtVelTargets;
193 const Eigen::Vector3f* _rtForceSensor =
nullptr;
194 const Eigen::Vector3f* _rtTorqueSensor =
nullptr;
196 std::vector<FTval> _rtFTHistory;
197 size_t _rtFTHistoryIndex = 0;
200 TB_FTlimit _rtFTlimit;
206 bool _rtStopConditionReached =
false;
208 std::atomic_bool _nullspaceControlEnabled{
true};
212 std::atomic_bool _publishIsAtForceLimit{
false};
214 std::atomic_bool _stopNowRequested{
false};
217 mutable std::recursive_mutex _mutexSetTripBuf;
219 TripleBuffer<TB_Target> _tripBufTarget;
220 TripleBuffer<TB_NT> _tripBufNullspaceTarget;
221 TripleBuffer<TB_FFvel> _tripBufFFvel;
222 TripleBuffer<TB_Cfg> _tripBufCfg;
223 TripleBuffer<TB_FT> _tripBufFToffset;
224 TripleBuffer<TB_FTlimit> _tripBufFTlimit;
225 TripleBuffer<TB_FTfake> _tripBufFTfake;
228 mutable std::recursive_mutex _tripRt2NonRtMutex;
229 TripleBuffer<RtToNonRtData> _tripRt2NonRt;
231 mutable std::recursive_mutex _tripFakeRobotGPWriteMutex;
232 TripleBuffer<Eigen::Matrix4f> _tripFakeRobotGP;
235 PublishData _publish;