diff --git a/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.cpp b/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.cpp index a01c4b37c08698a77fea6588d46963fee6e6c6df..4722e9c5ce8deaabfc33a917c9b0c744d1a781fd 100644 --- a/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.cpp +++ b/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.cpp @@ -22,7 +22,7 @@ namespace armarx::viz::coin if (filename.empty()) { ARMARX_INFO << deactivateSpam() << "No filename provided for robot."; - return result; + return nullptr; } std::string fullFilename; @@ -41,7 +41,7 @@ namespace armarx::viz::coin { ARMARX_INFO << deactivateSpam() << "Unable to find readable file for name: " << filename; - return result; + return nullptr; } try @@ -226,15 +226,21 @@ namespace armarx::viz::coin // robot.setGlobalPose(pose, false); // Check joint values for changes - bool jointValuesChanged = false; - for (auto& pair : element.jointValues) + + for (const auto& pair : element.jointValues) { std::string const& nodeName = pair.first; float newJointValue = pair.second; VirtualRobot::RobotNodePtr robotNode = robot.getRobotNode(nodeName); - float oldJointValue = robotNode->getJointValue(); - float diff = std::abs(newJointValue - oldJointValue); - jointValuesChanged = diff > 0.001f; + + if (robotNode == nullptr) + { + continue; + } + + const float oldJointValue = robotNode->getJointValue(); + const float diff = std::abs(newJointValue - oldJointValue); + const bool jointValuesChanged = diff > 0.001f; if (jointValuesChanged) { // Only set the joint values if they changed