diff --git a/idl/gepetto/viewer/graphical-interface.idl b/idl/gepetto/viewer/graphical-interface.idl index 50f510c4946191c4442baf11f22c12702a48ecb5..bc7f3ec0a69069f408ba2861d1585924af0ba500 100644 --- a/idl/gepetto/viewer/graphical-interface.idl +++ b/idl/gepetto/viewer/graphical-interface.idl @@ -130,6 +130,25 @@ typedef double Color [4]; boolean addURDF (in string robotName, in string urdfFilePath, in string meshDataRootDir) 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, + /// \param urdfFilePath to the package containing the urdf file, + /// i.e. "/opt/ros/hydro/share/pr2_description", + /// \param meshDataRootDir path to the package that contains the collada + /// files, this path should finish by "/", + /// i.e. "/opt/ros/hydro/share/" + /// \note the parser will replace "package://" by meshDataRootDir in the + /// urdf file. + /// 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. + /// + /// Unlike addURDF, this method will load the collision geometry instead + /// of the visual geometry. + boolean addUrdfCollision (in string robotName, in string urdfFilePath, + in string meshDataRootDir) raises (Error); + /// create a groupNode called groupName /// \param input groupName : name of the group. boolean createGroup(in string groupName) raises (Error); diff --git a/src/graphical-interface.impl.cpp b/src/graphical-interface.impl.cpp index 7d7d084ff1adbae7cb2a49a93fb5b1fb4ea7fcf3..c71e4927f22e7980e429bd4f0b2d4a5c0591fd94 100644 --- a/src/graphical-interface.impl.cpp +++ b/src/graphical-interface.impl.cpp @@ -595,6 +595,36 @@ namespace graphics { } } + bool GraphicalInterface::addUrdfCollision + (const char* urdfNameCorba, const char* urdfPathCorba, + const char* urdfPackagePathCorba) throw (Error) + { + try { + const std::string urdfName (urdfNameCorba); + const std::string urdfPath (urdfPathCorba); + const std::string urdfPackagePath (urdfPackagePathCorba); + if (nodes_.find (urdfName) != nodes_.end ()) { + std::cout << "You need to chose an other name, \"" << urdfName + << "\" already exist." << std::endl; + return false; + } + else { + GroupNodePtr_t urdf = urdfParser::parse + (urdfName, urdfPath, urdfPackagePath, "collision"); + NodePtr_t link; + for (int i=0; i< urdf->getNumOfChildren (); i++) { + link = urdf->getChild (i); + nodes_[link->getID ()] = link; + } + GraphicalInterface::initParent (urdfName, urdf); + addGroup (urdfName, urdf); + return true; + } + } catch (const std::exception& exc) { + throw Error (exc.what ()); + } + } + bool GraphicalInterface::addToGroup (const char* nodeNameCorba, const char* groupNameCorba) throw (Error) diff --git a/src/graphical-interface.impl.hh b/src/graphical-interface.impl.hh index 6657aaccbc4fb5300ba993158e25b757e3f76a22..f8d7ca25734399e97fa8388d16af3cd936064384 100644 --- a/src/graphical-interface.impl.hh +++ b/src/graphical-interface.impl.hh @@ -108,6 +108,11 @@ public: virtual bool addURDF(const char* urdfNameCorba, const char* urdfPathCorba, const char* urdfPackagePathCorba) throw (Error); + virtual bool addUrdfCollision (const char* urdfNameCorba, + const char* urdfPathCorba, + const char* urdfPackagePathCorba) + throw (Error); + virtual bool createGroup(const char* groupNameCorba) throw (Error); virtual bool addToGroup(const char* nodeNameCorba, const char* groupNameCorba) throw (Error);