38 #define snprintf _snprintf_s 77 void init(
const std::string& name,
const M_string& remappings, uint32_t options);
83 return ThisNode::instance().getName();
88 return ThisNode::instance().getNamespace();
101 void init(
const std::string& name,
const M_string& remappings, uint32_t options)
103 ThisNode::instance().init(name, remappings, options);
110 _dupenv_s(&ns_env, NULL,
"ROS_NAMESPACE");
112 ns_env = getenv(
"ROS_NAMESPACE");
129 bool disable_anon =
false;
130 M_string::const_iterator it = remappings.find(
"__name");
131 if (it != remappings.end())
137 it = remappings.find(
"__ns");
138 if (it != remappings.end())
140 namespace_ = it->second;
143 if (namespace_.empty())
148 namespace_ = (namespace_ ==
"/")
157 std::stringstream ss;
158 ss <<
"Namespace [" << namespace_ <<
"] is invalid: " << error;
166 if (name_.find(
"/") != std::string::npos)
170 if (name_.find(
"~") != std::string::npos)
180 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...
const std::string & getName() const
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.
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.
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 & getNamespace() const
static const TopicManagerPtr & instance()