diff --git a/urdf/include/urdf/model.h b/urdf/include/urdf/model.h index f9e676a..e9041d9 100644 --- a/urdf/include/urdf/model.h +++ b/urdf/include/urdf/model.h @@ -44,6 +44,7 @@ #include #include #include +#include namespace urdf{ @@ -58,6 +59,8 @@ public: bool initFile(const std::string& filename); /// \brief Load Model given the name of a parameter on the parameter server bool initParam(const std::string& param); + /// \brief Load Model given the name of a parameter on the parameter server using provided nodehandle + bool initParamWithNodeHandle(const std::string& param, const ros::NodeHandle& nh = ros::NodeHandle()); /// \brief Load Model from a XML-string bool initString(const std::string& xmlstring); }; diff --git a/urdf/src/model.cpp b/urdf/src/model.cpp index 69f96b8..03cc774 100644 --- a/urdf/src/model.cpp +++ b/urdf/src/model.cpp @@ -36,8 +36,6 @@ #include "urdf/model.h" -#include - /* we include the default parser for plain URDF files; other parsers are loaded via plugins (if available) */ #include @@ -88,7 +86,11 @@ bool Model::initFile(const std::string& filename) bool Model::initParam(const std::string& param) { - ros::NodeHandle nh; + return initParamWithNodeHandle(param, ros::NodeHandle()); +} + +bool Model::initParamWithNodeHandle(const std::string& param, const ros::NodeHandle& nh) +{ std::string xml_string; // gets the location of the robot description on the parameter server