%% Connect to Multiple ROS Masters
% Connecting to multiple ROS masters is possible using MATLAB®. These separate ROS masters do not share information and must have different port numbers. Connect ROS nodes to each master based on how you want to distribute information across the network.
% Create two ROS masters on different ports.

m1 = ros.Core; % Default port of 11311 
m2 = ros.Core(12000);

%
% Connect separate ROS nodes to each ROS master.

node1 = ros.Node('/test_node_1','localhost');
node2 = ros.Node('/test_node_2','localhost',12000);

%
% Clear the ROS nodes. Shut down the ROS masters.

clear('node1','node2')
clear('m1','m2')

% Copyright 2015 The MathWorks, Inc.
%