Hi Samuel,
I just tried this on my end and it works fine as shown below:
sub3 was created with a node when "ROS_DISCOVERY_SERVER" was set to empty, while sub2 was with a node when "ROS_DISCOVERY_SERVER" was set to the same address as the virtual machine IP. As shown on the screenshot, sub3 did not receive anything, while sub2 was able to continuously receive messages from the publisher on remote device.
Couple things to check are:
- Which version of MATLAB are you currently use? I did the above experiment with MATLAB R2022a, which supports ROS 2 Foxy.
- Make sure you set the correct IP address for the environment variable "ROS_DISCOVERY_SERVER". This can only be the ipaddress of the remote machine. If you set it to something else, it may work for local network inside the remote machine (e.g. publisher and subscirber all start in the same remote machine), but it will not work elsewhere.
- It is always good practice to provide subscriber type while creating subscriber, and use "sub.LatestMessage" to check during prototype to avoid network issues.
Hope this helps,
Josh