If you're using a VM, you'll have to review the networking configuration it uses.
If it's using NAT, connecting to processes running inside the VM will not be possible without (extensive) port forwarding. With an application that uses dynamically chosen ports (ie: random), then forwarding will be difficult to setup correctly. All your ROS nodes use random ports (well, from a certain range, but still random enough).
If you're running this on a machine in an unmanaged network (ie: at home, or in a really small company with no IT policy/department), you may get away with using bridged networking between the host and the VM. Your VM will get a "real" IP address, allowing it to communicate with all other hosts on your network, as-if it was a real computer.
If you're in a company (that has strict networking policies) or don't want to give your VM an IP from your physical network, then try to use host only networking. It is like bridging, but only within your own computer.
Note that after you have all of this setup, you need to make sure ROS (and Ubuntu) in the VM are properly configured for a multi-machine setup. See wiki/ROS/NetworkSetup for a start with that, or one of the myriad of questions here on ROS Answers about setting up Matlab for use with ROS (use Google: matlab ros_ip ros_hostname site:answers.ros.org
).
Originally posted by gvdhoorn with karma: 86574 on 2018-09-24
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by roberto on 2018-09-25:
Thanks a lot for your replying, it was so useful. Now, based on your suggestions, it is working well under the host only networking. I was using bridge networking in an unmanaged network and also trying with NAT, Thanks,