From 78e955c5b835f4d5108263badc0786e7db50c181 Mon Sep 17 00:00:00 2001
From: Florent Lamiraux <florent@laas.fr>
Date: Thu, 15 Dec 2011 12:17:09 +0100
Subject: [PATCH] Allow access by joint name in entity Dynamic.

---
 src/dynamic.cpp | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/dynamic.cpp b/src/dynamic.cpp
index d9976a3..05d91ca 100644
--- a/src/dynamic.cpp
+++ b/src/dynamic.cpp
@@ -1271,13 +1271,21 @@ CjrlJoint* Dynamic::getJointByName( const std::string& jointName )
     else
 		return m_HDR->rightAnkle()->childJoint(0);
 
-  } else {
-    throw ExceptionDynamic(ExceptionDynamic::GENERIC,
-			   jointName + " is not a valid name."
-			   " Valid names are \n"
-			   "gaze, left-ankle, right-ankle, left-wrist,"
-			   " right-wrist, waist, chest.");
   }
+  else {
+    std::vector< CjrlJoint* > jv = m_HDR->jointVector ();
+    for (std::vector< CjrlJoint* >::const_iterator it = jv.begin();
+	 it != jv.end(); it++) {
+      if ((*it)->getName () == jointName) {
+	return *it;
+      }
+    }
+  }
+  throw ExceptionDynamic(ExceptionDynamic::GENERIC,
+			 jointName + " is not a valid name."
+			 " Valid names are \n"
+			 "gaze, left-ankle, right-ankle, left-wrist,"
+			 " right-wrist, waist, chest, or any joint name.");
 }
 
 void Dynamic::cmd_createOpPointSignals( const std::string& opPointName,
-- 
GitLab