Skip to content

Commit 26de96f

Browse files
committed
Soft-fail on encoder speed/acceleration errors
Reason: gz-sim-yarp-plugins don't expose encoder acceleration, yet.
1 parent 96b20d4 commit 26de96f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

libraries/YarpPlugins/BasicCartesianControl/PeriodicThreadImpl.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
using namespace roboticslab;
1212

1313
constexpr int MAX_ENCODER_ERRORS = 20;
14-
constexpr double ERROR_THROTTLE = 0.5; // [s]
14+
constexpr double ENCODER_THROTTLE = 1.0; // [s]
1515

1616
// ------------------- PeriodicThread Related ------------------------------------
1717

@@ -30,9 +30,9 @@ void BasicCartesianControl::run()
3030
std::vector<double> qdot(numJoints);
3131
std::vector<double> qdotdot(numJoints);
3232

33-
if (!iEncoders->getEncoders(q.data()) || !iEncoders->getEncoderSpeeds(qdot.data()) || !iEncoders->getEncoderAccelerations(qdotdot.data()))
33+
if (!iEncoders->getEncoders(q.data()))
3434
{
35-
yCErrorThrottle(BCC, ERROR_THROTTLE) << "Unable to query encoders";
35+
yCErrorThrottle(BCC, ENCODER_THROTTLE) << "Unable to query encoders";
3636
encoderErrors++;
3737

3838
if (encoderErrors > MAX_ENCODER_ERRORS)
@@ -46,6 +46,10 @@ void BasicCartesianControl::run()
4646

4747
return;
4848
}
49+
else if (!iEncoders->getEncoderSpeeds(qdot.data()) || !iEncoders->getEncoderAccelerations(qdotdot.data()))
50+
{
51+
yCWarningThrottle(BCC, ENCODER_THROTTLE) << "Unable to query encoder speeds or accelerations";
52+
}
4953

5054
encoderErrors = 0; // reset error counter
5155

0 commit comments

Comments
 (0)