Commit d06ff674 authored by yannick legoc's avatar yannick legoc
Browse files

Take the middle position in Nomad3DController when the position is outside limits

parent 3ad6b1d8
......@@ -153,7 +153,18 @@ void Nomad3DController::updateActualPosition(int32 i) {
writer.Key(data.name.c_str());
// Do not apply the offset.
writer.Double(data.controller->position() * data.coef);
float64 position = data.controller->position();
// Get the middle position if the position is outside the limits.
// This can be due to a unplugged encoder.
float64 minPosition = data.controller->minPosition();
float64 maxPosition = data.controller->maxPosition();
if (position < minPosition || position > maxPosition) {
position = 0.5 * (minPosition + maxPosition);
}
writer.Double(position * data.coef);
}
// Write the virtual axis controllers.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment