From 6b5bff1e7ea107979d358c8834ef5a340ec6a11a Mon Sep 17 00:00:00 2001 From: Fabian Paus <fabian.paus@kit.edu> Date: Wed, 18 Sep 2019 17:42:36 +0200 Subject: [PATCH] Check for nullptr in NJointController list and skip it --- .../RobotUnitModules/RobotUnitModuleControlThread.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControlThread.cpp b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControlThread.cpp index 3cc35d38b..056498070 100644 --- a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControlThread.cpp +++ b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControlThread.cpp @@ -203,10 +203,15 @@ namespace armarx::RobotUnitModule for (std::size_t i = 0; i < actJC.size(); ++i) { + postSwitchSetup_ActivatedJointControllers.at(i) = actJC.at(i); postSwitchSetup_ActivatedJointToNJointControllerAssignement.at(i) = assig.at(i); postSwitchSetup_ActivatedNJointControllers.at(i) = actNJC.at(i); + if (actNJC.at(i) == nullptr) + { + continue; + } if (dynamic_cast<SynchronousNJointController*>(actNJC.at(i))) { _activatedSynchronousNJointControllersIdx.at(numSyncNj++) = i; @@ -217,8 +222,10 @@ namespace armarx::RobotUnitModule } else { - throw std::logic_error{"NJoint controller that is neither SynchronousNJointController" - " nor AsynchronousNJointController"}; + ARMARX_RT_LOGF_ERROR("NJoint controller that is neither SynchronousNJointController" + " nor AsynchronousNJointController: %s", actNJC.at(i)->rtGetClassName().c_str()); + // Throwing exceptions in a destructor causes std::abort to be called + //throw std::logic_error{}; } } for ( -- GitLab