Problems launching many nodes on OSX
I recently did a fresh install of ROS-jade on OSX El Capitan and for the most part everything is working well. However, I have noticed that when launching large launch files (e.g., 100 nodes), there seems to be problems accessing the ROS master (registering pub/sub, reading params, etc).
In an effort to test things, I wrote a simple test node:
#include <ros/ros.h>
#include <std_msgs/Float64.h>
void onFloatSub(const std_msgs::Float64::ConstPtr& msg)
{
}
int main(int argc, char *argv[])
{
ros::init(argc, argv, "test_node");
ros::NodeHandle pnh("~");
ros::Subscriber sub = pnh.subscribe<std_msgs::Float64>("float_sub", 1, &onFloatSub);
ros::Publisher pub = pnh.advertise<std_msgs::Float64>("float_pub", 1);
ros::Rate r(10.0);
while(ros::ok()) {
std::string test_param_value;
if(!pnh.getParam("test_param", test_param_value)) {
ROS_ERROR("Unable to read local 'test_param'");
}
if(test_param_value != std::string("test_param_value_set"))
ROS_ERROR("Incorrect test_param_value!");
ros::spinOnce();
r.sleep();
}
return 0;
}
And ran 100 versions of it in a launch file
<node pkg="test_many_node" type="test_many_node" name="test_node_1" output="screen">
<param name="test_param" value="test_param_value_set"/>
</node>
(with nodes 1 through 100).
Some nodes seem to run ok, but then I see errors like these (which are similar to what I saw in more complicated, real-world examples):
...
process[test_node_53-54]: started with pid [25907]
process[test_node_54-55]: started with pid [25908]
process[test_node_55-56]: started with pid [25909]
process[test_node_56-57]: started with pid [25910]
[ERROR] ros.test_many_node> Unable to read local 'test_param'
[ERROR] ros.test_many_node> Incorrect test_param_value!
[ERROR] ros.test_many_node> Unable to read local 'test_param'
[ERROR] ros.test_many_node> Incorrect test_param_value!
[ERROR] ros.roscpp> [registerService] Failed to contact master at [localhost:11311]. Retrying...
...
I don't think that I have experienced this problem before upgrading to El Capitan - has anyone else seen similar problems or have thoughts on things to try? I did a quick check on a Ubuntu machine (in a virtualized Docker image) and everything worked fine...