Skip to content
This repository has been archived by the owner on Aug 3, 2020. It is now read-only.

Commit

Permalink
Allow supplying NodeHandle for initParam
Browse files Browse the repository at this point in the history
Previously, initParam always constructs a default NodeHandle, which
works correctly as long as robot_description param and the node
calling initParam are in the same namespace. This is not true,
when initParam is called via a ros_control controller running in
the global namespace (gazebo), but robot_descriptions still need
to be namespaced. This backwards compatible change allows setting
the NodeHandle.
  • Loading branch information
piyushk committed Dec 5, 2016
1 parent 5c246be commit 4073f54
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 2 additions & 1 deletion urdf/include/urdf/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <tinyxml.h>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <ros/ros.h>

namespace urdf{

Expand All @@ -57,7 +58,7 @@ class Model: public ModelInterface
/// \brief Load Model given a filename
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);
bool initParam(const std::string& param, const ros::NodeHandle& nh = ros::NodeHandle());
/// \brief Load Model from a XML-string
bool initString(const std::string& xmlstring);
};
Expand Down
5 changes: 1 addition & 4 deletions urdf/src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@

#include "urdf/model.h"

#include <ros/ros.h>

/* we include the default parser for plain URDF files;
other parsers are loaded via plugins (if available) */
#include <urdf_parser/urdf_parser.h>
Expand Down Expand Up @@ -86,9 +84,8 @@ bool Model::initFile(const std::string& filename)
}


bool Model::initParam(const std::string& param)
bool Model::initParam(const std::string& param, const ros::NodeHandle& nh)
{
ros::NodeHandle nh;
std::string xml_string;

// gets the location of the robot description on the parameter server
Expand Down

0 comments on commit 4073f54

Please sign in to comment.