diff --git a/source/RobotAPI/robotstate/SharedRobotServants.cpp b/source/RobotAPI/robotstate/SharedRobotServants.cpp index fe78f4a157d9931b3cf573ceef31ca814c0fb883..a87910fe6c13d52198c05fc08530bd71f3f9436f 100644 --- a/source/RobotAPI/robotstate/SharedRobotServants.cpp +++ b/source/RobotAPI/robotstate/SharedRobotServants.cpp @@ -236,6 +236,8 @@ SharedRobotServant::~SharedRobotServant() #ifdef VERBOSE ARMARX_WARNING_S << "destruct " << this << flush; #endif + boost::recursive_mutex::scoped_lock cloneLock(m); + BOOST_FOREACH(NodeCache::value_type value, this->_cachedNodes) value.second->unref(); } @@ -244,6 +246,7 @@ SharedRobotNodeInterfacePrx SharedRobotServant::getRobotNode(const string &name, { // ARMARX_LOG_S << "Looking for node: " << name << flush; assert(_robot); + boost::recursive_mutex::scoped_lock cloneLock(m); if (this->_cachedNodes.find(name) == this->_cachedNodes.end()){ RobotNodePtr robotNode = _robot->getRobotNode(name); @@ -264,6 +267,7 @@ SharedRobotNodeInterfacePrx SharedRobotServant::getRobotNode(const string &name, SharedRobotNodeInterfacePrx SharedRobotServant::getRootNode(const Current ¤t) { assert(_robot); + boost::recursive_mutex::scoped_lock cloneLock(m); string name = _robot->getRootNode()/*,current*/->getName(); return this->getRobotNode(name, current); } diff --git a/source/RobotAPI/robotstate/SharedRobotServants.h b/source/RobotAPI/robotstate/SharedRobotServants.h index e52797cd986200eb4a4e631162ea1bc0c03d6308..735682fbb6a57ec816d9831acd2e44cc9469ea7e 100644 --- a/source/RobotAPI/robotstate/SharedRobotServants.h +++ b/source/RobotAPI/robotstate/SharedRobotServants.h @@ -118,6 +118,7 @@ namespace armarx { protected: VirtualRobot::RobotPtr _robot; + boost::recursive_mutex m; std::map<std::string, SharedRobotNodeInterfacePrx> _cachedNodes; }; } diff --git a/source/RobotAPI/robotstate/remote/RemoteRobot.cpp b/source/RobotAPI/robotstate/remote/RemoteRobot.cpp index dc2be4c3c2621b3d607e747b1eb92fd7312c22e6..b8d771e7e16155c04b0ad4b44eef056a4182365a 100644 --- a/source/RobotAPI/robotstate/remote/RemoteRobot.cpp +++ b/source/RobotAPI/robotstate/remote/RemoteRobot.cpp @@ -63,7 +63,7 @@ bool RemoteRobot::hasRobotNode( RobotNodePtr robotNode ) return this->hasRobotNode(robotNode->getName()); /* - * This just does nost work. because you cannot tell wheter RemoteRobotNode<RobotNodeRevolute> or another type is used + * This just does not work. because you cannot tell wheter RemoteRobotNode<RobotNodeRevolute> or another type is used * perhaps you can infer the actual RobotNodeType somehow. Until now we just check for names which is * much faster! * @@ -255,6 +255,7 @@ VirtualRobot::RobotNodePtr RemoteRobot::createLocalNode(SharedRobotNodeInterface VirtualRobot::RobotPtr RemoteRobot::createLocalClone() { + //ARMARX_IMPORTANT_S << "RemoteRobot local clone" << flush; boost::recursive_mutex::scoped_lock cloneLock(m); std::string robotType = getName(); std::string robotName = getName(); @@ -263,7 +264,6 @@ VirtualRobot::RobotPtr RemoteRobot::createLocalClone() //RobotNodePtr SharedRobotNodeInterfacePrx root = _robot->getRootNode(); - std::vector<VirtualRobot::RobotNodePtr> allNodes; std::map< VirtualRobot::RobotNodePtr, std::vector<std::string> > childrenMap; @@ -276,13 +276,14 @@ VirtualRobot::RobotPtr RemoteRobot::createLocalClone() return VirtualRobot::RobotPtr(); } - // clone rns + // clone rns std::vector<std::string> rns = _robot->getRobotNodeSets(); for (size_t i=0;i<rns.size();i++) { RobotNodeSetInfoPtr rnsInfo = _robot->getRobotNodeSet(rns[i]); RobotNodeSet::createRobotNodeSet(robo,rnsInfo->name,rnsInfo->names,rnsInfo->rootName,rnsInfo->tcpName,true); } + //ARMARX_IMPORTANT_S << "RemoteRobot local clone end" << flush; return robo; }