[ros-users] strange namespace behavior when setting the ROS_NAMESPACE environment variable

Achtelik Markus markus.achtelik at mavt.ethz.ch
Thu Jul 21 08:27:39 UTC 2011

Hi all,

I tried to post this via nabble.com but somehow it didn't get through ... I have a node publishing a topic let's say "my_topic". Simply running this node, rostopic list tells me as expected:

Now, when I want to push this node to a namespace by:
export ROS_NAMESPACE=my_ns

rostopic list says:

Any idea where three times "my_ns" comes from? When I run the node from a launch file and set the "ns" attribute, everything is alright. I'm not doing anything fancy with namespaces etc. in the node, I put some example code below. rosversion ros says 1.4.8 . 

Best, Markus

#include <ros/ros.h>
#include <std_msgs/String.h>

int main(int argc, char** argv)

  ros::init(argc, argv, "ns_test");
  ros::NodeHandle nh;
  ros::Publisher pub = nh.advertise<std_msgs::String> ("my_topic", 1);

  ros::Rate r(5);
  while (ros::ok())
    std_msgs::String msg;
    msg.data = "my string message";
  return 0;

More information about the ros-users mailing list