diff --git a/idl/gepetto/viewer/graphical-interface.idl b/idl/gepetto/viewer/graphical-interface.idl index 8d2946262344690a68e4ade5f758aad454f2157e..bec1455692beacc597b2f3d6afbe79167906d61f 100644 --- a/idl/gepetto/viewer/graphical-interface.idl +++ b/idl/gepetto/viewer/graphical-interface.idl @@ -116,6 +116,34 @@ typedef float Color [4]; /// \param input RGBAcolor : color of the face. boolean addTriangleFace(in string faceName, in Position pos1, in Position pos2, in Position pos3, in Color RGBAcolor) raises (Error); + + // Add a sphere with xyz axis + // The colors are x=red, y=green, z=blue (xyz=RGB) + // \param input nodeName : name of the node + // \param input RGBAcolor : color of the sphere + // \param input radius : radius of the sphere + // \param input sizeAxis : size of the axis (proportionnaly to the sphere radius, size axis = 1 -> axis are radius*4 in length and radius/4 in radius) + boolean addXYZaxis(in string nodeName, in Color RGBAcolor,in float radius,in float sizeAxis) raises(Error); + + // Add an empty roadmap to the scene + // \param input nameCorba : name of the roadmap + // \param input RGBAcolorNode : color of the sphere + // \param input radius : radius of the sphere + // \param input sizeAxis :size of the axis (proportionnaly to the sphere radius, size axis = 1 -> axis are radius*4 in length and radius/4 in radius) + // \param input RGBAcolorEdge : color of the edges + boolean createRoadmap(in string nameCorba,in Color RGBAcolorNode, in float radius, in float sizeAxis, in Color RGBAcolorEdge) raises(Error); + + // Add an edge to the roadmap + // \param input nameRoadmap : name of the roadmap + // \param input posFrom : position of the beginning of the edge + // \param input posTo : position of the end of the edge (not oriented edge, order doesn't matter) + boolean addEdgeToRoadmap(in string nameRoadmap, in Position posFrom, in Position posTo)raises(Error); + + // Add a node to the roadmap + // \param input nameRoadmap : name of the roadmap + // \param input configuration : configuration of the node + boolean addNodeToRoadmap(in string nameRoadmap, in Transform configuration)raises(Error); + /// Create a node from an urdf file /// \param robotName Name of the node that will contain the robot geometry, /// each geometric part is prefixed by this name, @@ -129,6 +157,7 @@ typedef float Color [4]; /// a groupNode is created and each link will be child node of this node. /// Links are named "prefix/linkName", linkName is the name of the link /// in the URDF file. + boolean addURDF (in string robotName, in string urdfFilePath, in string meshDataRootDir) raises (Error); diff --git a/include/gepetto/viewer/corba/windows-manager.h b/include/gepetto/viewer/corba/windows-manager.h index 1bc4653bffcf81b457dbe5db6dce0975a01fc15b..1c4065a6dc782f21628c417f341eefa832f144cb 100644 --- a/include/gepetto/viewer/corba/windows-manager.h +++ b/include/gepetto/viewer/corba/windows-manager.h @@ -18,6 +18,7 @@ #define SCENEVIEWER_WINDOWMANAGERS_HH #include <gepetto/viewer/window-manager.h> +#include <gepetto/viewer/roadmap-viewer.h> #include <boost/thread/mutex.hpp> namespace graphics { @@ -45,6 +46,7 @@ namespace graphics { WindowManagerVector_t windowManagers_; std::map<std::string, NodePtr_t> nodes_; std::map<std::string, GroupNodePtr_t> groupNodes_; + std::map<std::string, RoadmapViewerPtr_t> roadmapNodes_; boost::mutex mtx_; int rate_; std::list<NodeConfiguration> newNodeConfigurations_; @@ -103,6 +105,13 @@ namespace graphics { virtual bool addSquareFace(const char* faceName, const value_type* pos1, const value_type* pos2, const value_type* pos3, const value_type* pos4, const value_type* color); virtual bool addTriangleFace(const char* faceName, const value_type* pos1, const value_type* pos2, const value_type* pos3, const value_type* color); + virtual bool addXYZaxis (const char* nodeNameCorba, const value_type* colorCorba, float radius, float sizeAxis); + + 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 addNodeToRoadmap(const char* nameRoadmap, const value_type* configuration); virtual bool addURDF(const char* urdfNameCorba, const char* urdfPathCorba, const char* urdfPackagePathCorba); diff --git a/src/corbaserver.cc b/src/corbaserver.cc index d17bb0174d3554780a8a6a08684cdab12becfabc..28f1f37a09c2500f893c418b11ab3aeec8746c4d 100644 --- a/src/corbaserver.cc +++ b/src/corbaserver.cc @@ -17,7 +17,7 @@ int main (int argc, const char* argv[]) { graphics::WindowsManagerPtr_t wm = graphics::WindowsManager::create (); - Server server (wm, argc, argv, true); + Server server (wm, argc, argv, false); // dernier arg : autorise ou non multithread (original = true) server.startCorbaServer (); server.processRequest(true); diff --git a/src/graphical-interface.impl.cpp b/src/graphical-interface.impl.cpp index af1e9f38ede13e51a252b183d5bc60ef446edf16..0cbca83a75d0bb95bba4606a0ef9557794b483d4 100644 --- a/src/graphical-interface.impl.cpp +++ b/src/graphical-interface.impl.cpp @@ -200,6 +200,44 @@ namespace graphics { } } + bool GraphicalInterface::addXYZaxis(const char* nodeNameCorba, const value_type* colorCorba, float radius, float sizeAxis) + throw (Error) + { + try { + return windowsManager_->addXYZaxis (nodeNameCorba,colorCorba,radius,sizeAxis); + } catch (const std::exception& exc) { + throw Error (exc.what ()); + } + } + + /** initialise the roadmap (graphical roadmap)*/ + bool GraphicalInterface::createRoadmap(const char* nameCorba,const value_type* colorNodeCorba, float radius, float sizeAxis, const value_type* colorEdgeCorba) throw(Error){ + try { + return windowsManager_->createRoadmap (nameCorba,colorNodeCorba,radius,sizeAxis,colorEdgeCorba); + } catch (const std::exception& exc) { + throw Error (exc.what ()); + } + } + + + bool GraphicalInterface::addEdgeToRoadmap(const char* nameRoadmap, const value_type* posFrom, const value_type* posTo) throw(Error){ + try { + return windowsManager_->addEdgeToRoadmap (nameRoadmap,posFrom,posTo); + } catch (const std::exception& exc) { + throw Error (exc.what ()); + } + } + + bool GraphicalInterface::addNodeToRoadmap(const char* nameRoadmap, const value_type* configuration) throw(Error){ + try { + return windowsManager_->addNodeToRoadmap (nameRoadmap,configuration); + } catch (const std::exception& exc) { + throw Error (exc.what ()); + } + } + + + void GraphicalInterface::getNodeList () throw (Error) { try { diff --git a/src/graphical-interface.impl.hh b/src/graphical-interface.impl.hh index 1f08ca43650b6c16689e98177fd66830215cf839..b4f07fae9338af4f10c45dba1f5dee5c0195a8df 100644 --- a/src/graphical-interface.impl.hh +++ b/src/graphical-interface.impl.hh @@ -71,6 +71,15 @@ public: virtual bool addSquareFace(const char* faceName, const value_type* pos1, const value_type* pos2, const value_type* pos3, const value_type* pos4, const value_type* color) throw (Error); virtual bool addTriangleFace(const char* faceName, const value_type* pos1, const value_type* pos2, const value_type* pos3, const value_type* color) throw (Error); + virtual bool addXYZaxis (const char* nodeNameCorba, const value_type* colorCorba, float radius, float sizeAxis) throw (Error); + + virtual bool createRoadmap(const char* nameCorba,const value_type* colorNodeCorba, float radius, float sizeAxis, const value_type* colorEdgeCorba) throw(Error); + + virtual bool addEdgeToRoadmap(const char* nameRoadmap, const value_type* posFrom, const value_type* posTo) throw(Error); + + virtual bool addNodeToRoadmap(const char* nameRoadmap, const value_type* configuration) throw(Error); + + virtual bool addURDF(const char* urdfNameCorba, const char* urdfPathCorba, const char* urdfPackagePathCorba) throw (Error); virtual bool addUrdfCollision (const char* urdfNameCorba, diff --git a/src/windows-manager.cpp b/src/windows-manager.cpp index ad2e8d9683bc58ea8c94212df4ce41b1ae767652..5d00e95bf5dc442db296099d6561dc79ea781c93 100644 --- a/src/windows-manager.cpp +++ b/src/windows-manager.cpp @@ -28,6 +28,8 @@ #include <gepetto/viewer/leaf-node-line.h> #include <gepetto/viewer/leaf-node-face.h> #include <gepetto/viewer/leaf-node-sphere.h> +#include <gepetto/viewer/leaf-node-xyzaxis.h> +#include <gepetto/viewer/roadmap-viewer.h> #include <gepetto/viewer/macros.h> #include <gepetto/viewer/config-osg.h> #include <gepetto/viewer/leaf-node-ground.h> @@ -36,7 +38,7 @@ namespace graphics { WindowsManager::WindowsManager () : - windowManagers_ (), nodes_ (), groupNodes_ (), + windowManagers_ (), nodes_ (), groupNodes_ (),roadmapNodes_(), mtx_ (), rate_ (20), newNodeConfigurations_ () { } @@ -479,6 +481,60 @@ namespace graphics { } } + bool WindowsManager::addXYZaxis (const char* nodeNameCorba,const value_type* colorCorba, float radius, float sizeAxis) + { + + std::string nodeName (nodeNameCorba); + if (nodes_.find (nodeName) != nodes_.end ()) { + std::cout << "You need to chose an other name, \"" << nodeName + << "\" already exist." << std::endl; + return false; + } + else { + LeafNodeXYZAxisPtr_t axis = LeafNodeXYZAxis::create + (nodeName,getColor(colorCorba),radius,sizeAxis); + WindowsManager::initParent (nodeName, axis); + addNode (nodeName, axis); + return true; + } + } + + bool WindowsManager::createRoadmap(const char* nameCorba,const value_type* colorNodeCorba, float radius, float sizeAxis, const value_type* colorEdgeCorba){ + const std::string roadmapName (nameCorba); + if (nodes_.find (roadmapName) != nodes_.end ()) { + std::cout << "You need to chose an other name, \"" << roadmapName + << "\" already exist." << std::endl; + return false; + } + else { + RoadmapViewerPtr_t rm = RoadmapViewer::create(roadmapName,getColor(colorNodeCorba),radius,sizeAxis,getColor(colorEdgeCorba)); + WindowsManager::initParent (roadmapName, rm); + addNode (roadmapName, rm); + roadmapNodes_[roadmapName]=rm; + return true; + } + } + + bool WindowsManager::addEdgeToRoadmap(const char* nameRoadmapCorba, const value_type* posFromCorba, const value_type* posToCorba){ + 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 posFrom = osgVector3(posFromCorba[0], posFromCorba[1],posFromCorba[2]); + osgVector3 posTo = osgVector3(posToCorba[0], posToCorba[1],posToCorba[2]); + rm_ptr->addEdge(posFrom,posTo); + return true; + } + } + + bool WindowsManager::addNodeToRoadmap(const char* nameRoadmap, const value_type* configuration){ +//TODO + } + std::vector<std::string> WindowsManager::getNodeList () { std::vector<std::string> l;