From 3384a0a76f6ab02dc01354bdc0e55fe482c29f57 Mon Sep 17 00:00:00 2001 From: Piyush Khandelwal Date: Thu, 9 Feb 2017 18:53:46 -0600 Subject: [PATCH] Allow supplying NodeHandle for initParam (#168) * Allow supplying NodeHandle for initParam using new function. * fixed missing return statement in previous commit. --- urdf/include/urdf/model.h | 3 +++ urdf/src/model.cpp | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) 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