Skip to content
Snippets Groups Projects
Commit 8baf12ea authored by Mirko Wächter's avatar Mirko Wächter
Browse files

fixed race condition when setting control mode on kinematicunit and setting a...

fixed race condition when setting control mode on kinematicunit and setting a target immediately after
parent fb006db1
No related branches found
No related tags found
No related merge requests found
......@@ -63,6 +63,11 @@ namespace armarx
*target = control;
}
inline virtual void rtPreActivateController() override
{
}
void reset()
{
control = (*sensor) * sensorToControlOnActivateFactor;
if (std::abs(control) < resetZeroThreshold)
......
......@@ -219,7 +219,7 @@ void armarx::KinematicSubUnit::switchControlMode(const armarx::NameControlModeMa
<< "'. (ignoring this device)";
continue;
}
auto ctrl = devs.at(name).getController(mode);
NJointKinematicUnitPassThroughControllerPtr ctrl = NJointKinematicUnitPassThroughControllerPtr::dynamicCast(devs.at(name).getController(mode));
if (!ctrl)
{
ARMARX_WARNING << "requested unsupported mode " << mode << " for device '" << name
......@@ -230,6 +230,7 @@ void armarx::KinematicSubUnit::switchControlMode(const armarx::NameControlModeMa
{
continue;
}
ctrl->reset(); // reset immediately instead of preActivate() to avoid race condition
toActivate[name] = std::move(ctrl);
}
const auto printToActivate = ARMARX_STREAM_PRINTER
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment