70 void init(
const std::string& name,
const M_string& remappings, uint32_t options);
76 return ThisNode::instance().getName();
81 return ThisNode::instance().getNamespace();
94 void init(
const std::string& name,
const M_string& remappings, uint32_t options)
96 ThisNode::instance().init(name, remappings, options);
103 _dupenv_s(&ns_env, NULL,
"ROS_NAMESPACE");
105 ns_env = getenv(
"ROS_NAMESPACE");
122 bool disable_anon =
false;
123 M_string::const_iterator it = remappings.find(
"__name");
124 if (it != remappings.end())
130 it = remappings.find(
"__ns");
131 if (it != remappings.end())
133 namespace_ = it->second;
137 if (namespace_.empty() || (namespace_[0] !=
'/'))
139 namespace_ =
"/" + namespace_;
145 std::stringstream ss;
146 ss <<
"Namespace [" << namespace_ <<
"] is invalid: " << error;
154 if (name_.find(
"/") != std::string::npos)
158 if (name_.find(
"~") != std::string::npos)
168 std::snprintf(buf,
sizeof(buf),
"_%llu", (
unsigned long long)
WallTime::now().toNSec());
Anonymize the node name. Adds a random number to the end of your node's name, to make it unique...
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROS initialization function.
ROSCONSOLE_DECL void setFixedFilterToken(const std::string &key, const std::string &val)
ROSCPP_DECL const std::string & getName()
Returns the name of the current node.
ROSCPP_DECL bool validate(const std::string &name, std::string &error)
Validate a name against the name spec.
ROSCPP_DECL std::string resolve(const std::string &name, bool remap=true)
Resolve a graph resource name into a fully qualified graph resource name.
ROSCPP_DECL std::string clean(const std::string &name)
Cleans a graph resource name: removes double slashes, trailing slash.
static ThisNode & instance()
std::map< std::string, std::string > M_string
void init(const M_string &remappings)
std::vector< std::string > V_string
ROSCPP_DECL const std::string & getNamespace()
Returns the namespace of the current node.
const std::string & getNamespace() const
ROSCPP_DECL void getSubscribedTopics(V_string &topics)
Get the list of topics subscribed to by this node.
Thrown when an invalid graph resource name is specified to any roscpp function.
Thrown when an invalid node name is specified to ros::init()
ROSCPP_DECL void getAdvertisedTopics(V_string &topics)
Get the list of topics advertised by this node.
const std::string & getName() const
static const TopicManagerPtr & instance()