30 using namespace ForceTorqueUtility;
43 const float forceThreshold = in.getForceThreshold();
47 getForceTorqueObserver()->getForceDatafield(in.getFTDatafieldName()));
48 const Eigen::Vector3f weights = in.getForceWeights()->toEigen();
49 const Eigen::Vector3f axis = in.getAxis()->toEigen().normalized();
50 auto getForceAlongAxis = [&]() ->
float
52 return forceDf->getDataField()
55 .cwiseProduct(weights)
60 in.getTriggerInAxisDirection();
61 in.getTriggerCounterAxisDirection();
62 std::deque<float> spikes(in.getWindowSizeMs() / 10, getForceAlongAxis());
64 while (!isRunningTaskStopped())
66 spikes.push_back(getForceAlongAxis());
69 float refValue = spikes.at(0);
71 bool risingEdgeDetected =
false;
72 bool fallingEdgeDetected =
false;
74 bool f2rDetected =
false;
75 bool r2fDetected =
false;
77 for (
const float spike : spikes)
85 else if (spike > refValue + forceThreshold)
88 risingEdgeDetected =
true;
89 f2rDetected |= fallingEdgeDetected;
99 else if (spike < refValue - forceThreshold)
102 fallingEdgeDetected =
true;
103 r2fDetected |= risingEdgeDetected;
107 if ((in.getTriggerInAxisDirection() && r2fDetected) ||
108 (in.getTriggerCounterAxisDirection() && f2rDetected))
114 std::this_thread::sleep_for(std::chrono::milliseconds{10});