From a3c28e588e6cca29dbef31ffef98a0d32e273c68 Mon Sep 17 00:00:00 2001 From: Florent Lamiraux <florent@laas.fr> Date: Sun, 10 Nov 2013 22:43:13 +0100 Subject: [PATCH] Check that joint exists when creating an operational point createOpPoint command with a valid name ("waist", "left-wrist",...) not set produced a segmentation faullt at signal recomputation due to access to a null pointer. --- src/sot-dynamic.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/sot-dynamic.cpp b/src/sot-dynamic.cpp index bafad0e..2fa4b4d 100644 --- a/src/sot-dynamic.cpp +++ b/src/sot-dynamic.cpp @@ -1430,6 +1430,9 @@ void Dynamic::cmd_createOpPointSignals( const std::string& opPointName, const std::string& jointName ) { CjrlJoint* joint = getJointByName(jointName); + if (!joint) { + throw runtime_error ("Robot has no joint corresponding to " + jointName); + } createEndeffJacobianSignal(std::string("J")+opPointName, joint); createPositionSignal(opPointName, joint); } @@ -1437,18 +1440,27 @@ void Dynamic::cmd_createJacobianWorldSignal( const std::string& signalName, const std::string& jointName ) { CjrlJoint* joint = getJointByName(jointName); + if (!joint) { + throw runtime_error ("Robot has no joint corresponding to " + jointName); + } createJacobianSignal(signalName, joint); } void Dynamic::cmd_createJacobianEndEffectorSignal( const std::string& signalName, const std::string& jointName ) { CjrlJoint* joint = getJointByName(jointName); + if (!joint) { + throw runtime_error ("Robot has no joint corresponding to " + jointName); + } createEndeffJacobianSignal(signalName, joint); } void Dynamic::cmd_createPositionSignal( const std::string& signalName, const std::string& jointName ) { CjrlJoint* joint = getJointByName(jointName); + if (!joint) { + throw runtime_error ("Robot has no joint corresponding to " + jointName); + } createPositionSignal(signalName, joint); } -- GitLab