Skip to content
Snippets Groups Projects
Commit fd6b005a authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

seg fault issue corrected (use mutex in roadmapViewer)

parent 4e8342ef
No related branches found
No related tags found
No related merge requests found
...@@ -209,6 +209,11 @@ typedef float Color [4]; ...@@ -209,6 +209,11 @@ typedef float Color [4];
/// \param input groupName : name of the mother node (=group node). /// \param input groupName : name of the mother node (=group node).
boolean addToGroup(in string nodeName, in string groupName) raises (Error); boolean addToGroup(in string nodeName, in string groupName) raises (Error);
/// remove the node from the child list of a group node.
/// \param input nodeName : name of the child node.
/// \param input groupName : name of the mother node (=group node).
boolean removeFromGroup(in string nodeName, in string groupName) raises (Error);
/// Set a new configuration to a node. THIS CONFIGURATION WILL AFFECTIVE ONLY AFTER CALLING REFRESH FUNCTION!!! /// Set a new configuration to a node. THIS CONFIGURATION WILL AFFECTIVE ONLY AFTER CALLING REFRESH FUNCTION!!!
/// \param input nodeName : name of the node. /// \param input nodeName : name of the node.
/// \param input configuration : Float[7] new configuration. /// \param input configuration : Float[7] new configuration.
......
...@@ -109,9 +109,9 @@ namespace graphics { ...@@ -109,9 +109,9 @@ namespace graphics {
virtual bool createRoadmap(const char* nameCorba,const value_type* colorNodeCorba, float radius, float sizeAxis, const value_type* colorEdgeCorba); virtual bool createRoadmap(const char* nameCorba,const value_type* colorNodeCorba, float radius, float sizeAxis, const value_type* colorEdgeCorba);
virtual bool addEdgeToRoadmap(const char* nameRoadmap, const value_type* posFromCorba, const value_type* posToCorba); virtual bool addEdgeToRoadmap(const char* nameRoadmapCorba, const value_type* posFromCorba, const value_type* posToCorba);
virtual bool addNodeToRoadmap(const char* nameRoadmap, const value_type* configuration); virtual bool addNodeToRoadmap(const char* nameRoadmapCorba, const value_type* configuration);
virtual bool addURDF(const char* urdfNameCorba, const char* urdfPathCorba, const char* urdfPackagePathCorba); virtual bool addURDF(const char* urdfNameCorba, const char* urdfPathCorba, const char* urdfPackagePathCorba);
...@@ -126,6 +126,8 @@ namespace graphics { ...@@ -126,6 +126,8 @@ namespace graphics {
virtual bool createGroup(const char* groupNameCorba); virtual bool createGroup(const char* groupNameCorba);
virtual bool addToGroup(const char* nodeNameCorba, const char* groupNameCorba); virtual bool addToGroup(const char* nodeNameCorba, const char* groupNameCorba);
virtual bool removeFromGroup (const char* nodeNameCorba, const char* groupNameCorba);
virtual bool applyConfiguration(const char* nodeNameCorba, const value_type* configuration); virtual bool applyConfiguration(const char* nodeNameCorba, const value_type* configuration);
......
...@@ -308,6 +308,16 @@ namespace graphics { ...@@ -308,6 +308,16 @@ namespace graphics {
} }
} }
bool GraphicalInterface::removeFromGroup (const char* nodeNameCorba,
const char* groupNameCorba) throw (Error)
{
try {
return windowsManager_->removeFromGroup ( nodeNameCorba, groupNameCorba) ;
} catch (const std::exception& exc) {
throw Error (exc.what ());
}
}
bool GraphicalInterface::applyConfiguration (const char* nodeNameCorba, const value_type* configurationCorba) throw (Error) bool GraphicalInterface::applyConfiguration (const char* nodeNameCorba, const value_type* configurationCorba) throw (Error)
{ {
try { try {
......
...@@ -95,6 +95,7 @@ public: ...@@ -95,6 +95,7 @@ public:
virtual bool createGroup(const char* groupNameCorba) throw (Error); virtual bool createGroup(const char* groupNameCorba) throw (Error);
virtual bool addToGroup(const char* nodeNameCorba, const char* groupNameCorba) throw (Error); virtual bool addToGroup(const char* nodeNameCorba, const char* groupNameCorba) throw (Error);
virtual bool removeFromGroup (const char* nodeNameCorba,const char* groupNameCorba) throw (Error);
virtual bool applyConfiguration(const char* nodeNameCorba, const value_type* configuration) throw (Error); virtual bool applyConfiguration(const char* nodeNameCorba, const value_type* configuration) throw (Error);
......
...@@ -142,6 +142,7 @@ namespace graphics { ...@@ -142,6 +142,7 @@ namespace graphics {
return parentName; return parentName;
} }
void WindowsManager::initParent (const std::string& nodeName, void WindowsManager::initParent (const std::string& nodeName,
NodePtr_t node) NodePtr_t node)
{ {
...@@ -175,6 +176,8 @@ namespace graphics { ...@@ -175,6 +176,8 @@ namespace graphics {
} }
} }
osgQuat WindowsManager::corbaConfToOsgQuat (const value_type* configCorba) osgQuat WindowsManager::corbaConfToOsgQuat (const value_type* configCorba)
{ {
// configurationCorba = trans (x, y, z), quat (w, x, y, z) // configurationCorba = trans (x, y, z), quat (w, x, y, z)
...@@ -232,8 +235,8 @@ namespace graphics { ...@@ -232,8 +235,8 @@ namespace graphics {
it != newNodeConfigurations_.end (); it++) { it != newNodeConfigurations_.end (); it++) {
(*it).node->applyConfiguration ( (*it).position, (*it).quat); (*it).node->applyConfiguration ( (*it).position, (*it).quat);
} }
mtx_.unlock ();
newNodeConfigurations_.clear (); newNodeConfigurations_.clear ();
mtx_.unlock ();
} }
void WindowsManager::createScene (const char* sceneNameCorba) void WindowsManager::createScene (const char* sceneNameCorba)
...@@ -526,13 +529,29 @@ namespace graphics { ...@@ -526,13 +529,29 @@ namespace graphics {
RoadmapViewerPtr_t rm_ptr = roadmapNodes_[nameRoadmap]; RoadmapViewerPtr_t rm_ptr = roadmapNodes_[nameRoadmap];
osgVector3 posFrom = osgVector3(posFromCorba[0], posFromCorba[1],posFromCorba[2]); osgVector3 posFrom = osgVector3(posFromCorba[0], posFromCorba[1],posFromCorba[2]);
osgVector3 posTo = osgVector3(posToCorba[0], posToCorba[1],posToCorba[2]); osgVector3 posTo = osgVector3(posToCorba[0], posToCorba[1],posToCorba[2]);
rm_ptr->addEdge(posFrom,posTo); // mtx_.lock(); mtx is now locked only when required in addEdge
rm_ptr->addEdge(posFrom,posTo,mtx_);
// mtx_.unlock();
return true; return true;
} }
} }
bool WindowsManager::addNodeToRoadmap(const char* nameRoadmap, const value_type* configuration){ bool WindowsManager::addNodeToRoadmap(const char* nameRoadmapCorba, const value_type* configuration){
//TODO const std::string nameRoadmap (nameRoadmapCorba);
if (roadmapNodes_.find (nameRoadmap) == roadmapNodes_.end ()) {
//no node named nodeName
std::cout << "No roadmap named \"" << nameRoadmap << "\"" << std::endl;
return false;
}
else {
RoadmapViewerPtr_t rm_ptr = roadmapNodes_[nameRoadmap];
osgVector3 position = WindowsManager::corbaConfToOsgVec3 (configuration);
osgQuat quat = WindowsManager::corbaConfToOsgQuat (configuration);
// mtx_.lock();
rm_ptr->addNode(position,quat,mtx_);
// mtx_.unlock();
return true;
}
} }
std::vector<std::string> WindowsManager::getNodeList () std::vector<std::string> WindowsManager::getNodeList ()
...@@ -686,6 +705,23 @@ namespace graphics { ...@@ -686,6 +705,23 @@ namespace graphics {
} }
} }
bool WindowsManager::removeFromGroup (const char* nodeNameCorba,
const char* groupNameCorba)
{
const std::string nodeName (nodeNameCorba);
const std::string groupName (groupNameCorba);
if (nodes_.find (nodeName) == nodes_.end () ||
groupNodes_.find (groupName) == groupNodes_.end ()) {
std::cout << "Node name \"" << nodeName << "\" and/or groupNode \""
<< groupName << "\" doesn't exist." << std::endl;
return false;
}
else {
groupNodes_[groupName]->removeChild(nodes_[nodeName]);
return true;
}
}
bool WindowsManager::applyConfiguration (const char* nodeNameCorba, bool WindowsManager::applyConfiguration (const char* nodeNameCorba,
const value_type* configurationCorba) const value_type* configurationCorba)
{ {
...@@ -709,7 +745,9 @@ namespace graphics { ...@@ -709,7 +745,9 @@ namespace graphics {
"quatY, quatZ]" <<std::endl; "quatY, quatZ]" <<std::endl;
return false; return false;
} }
mtx_.lock();
newNodeConfigurations_.push_back (newNodeConfiguration); newNodeConfigurations_.push_back (newNodeConfiguration);
mtx_.unlock();
return true; return true;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment