|Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.|
WinRos Master and Virtual UbuntuDescription: How to link a windows host running a winros master with nodes running on a virtualbox ubuntu.
Tutorial Level: ADVANCED
These instructions will create an Ubuntu VirtualBox on Windows, and will allow the win_ros listener/talker example programs to communicate with ROS nodes running on the Ubuntu VB.
Follow all the instructions to install win_ros on your windows machine and check that the listener/talker example is working.
- If you get "error code 2" when running roscore, it's because Python is not in your path. I added it into my setup.bat.
Follow all the instructions to install VirtualBox.
Download your desired version of the Ubuntu iso.
Create an Ubuntu VirtualBox by following these directions
Once you successfully boot into your Ubuntu VirtualBox, follow all the instructions to install ROS onto it, and make sure that it can run properly by running through some simple tests or the first few tutorials.
Now comes the tricky bit - interfacing the guest and host. You must modify your VirtualBox network adapter to make your Ubuntu VirtualBox visible to the Windows host.
In the VirtualBox window, try using Devices->Network Adapters... to change your network adapter to "Bridged". Some have gotten this to work (try step 9 below to test), but when tried on a Vista host, the Vista machine couldn't ping the VirtualBox.
If the above step fails, change the network adapter back to "NAT" and follow the following steps:
Shut down your Ubuntu VirtualBox.
In the VirtualBox Manager, select the Ubuntu VirutalBox, then go to Settings->Network->Adapter 2. Enable this second Adapter, make it a "Host-only Adapter", and save the changes.
You need the NAT adapter to supply internet connection to the Ubuntu VirtualBox. You need the Host-Only adapter to allow the Ubuntu VirtualBox and Windows host to see each other.
Open a command window in Windows and run ipconfig. You should have a "VirtualBox Host-Only Network" adapter. Note the IP Address.
Start your Ubuntu VirtualBox again. When it loads, go to System Setting->Network. You should have two wired connections. Find the one that has an IP address where the first three numbers are the same as the VirtualBox Host-Only Network IP address on your Windows host. This is your "Host-Only" network connection.
Click Options and go to the IPv4 tab. Make this connection have a static IP address by choosing Method:Manual and plugging in the Address, Netmask, and Gateway that's currently being displayed in the Network Settings window.
- Save your changes, write down the IP address for later and close out of there.
- Modify the Ubuntu hosts file (/etc/hosts). Add the Host-Only IP Address and computer name of your windows host to the list. (You might have to open the file with admin privileges to actually change it).
Modify the Windows hosts file (It's at C:\Windows\System32\drivers\etc\hosts on Vista). Add the Host-Only IP Address and computer name of your Ubuntu VirtualBox. (You might have to open the file with admin privileges to actually change it).
Verify your setup: try to ping your VirtualBox from windows and your windows host from Ubuntu. Make sure that the ipadress associated with the pinging is the right one for the Host-Only network.
Now for the final verification: Getting nodes on the separate machines to communicate.
- Start up roscore on your windows machine.
It is theoretically possible to start roscore on the Ubuntu VirtualBox, but initial trials of this failed with strange errors, and since some diagnostics (like rosnode) have not yet been fully ported into win_ros, it is currently easier to just run roscore on Windows.
- In another command window, start up the example talker win_ros example project.
roslaunch msvc_runtime talker.launch
- In Ubuntu, change the ROS_MASTER_URI variable to your windows Host. This URI should be the same one that the windows roscore is connected to (if your windows host says "localhost", use the network name of Windows in it's place in Ubuntu).
- In Ubuntu, listen to the chatter topic.
rostopic echo /chatter
- You should get "hello world" printed over and over in the Ubuntu terminal.
- You can run a similar verification for talking on Ubuntu and listening on Windows.
Once you have this in place, you should be able to talk/listen on any topic you want from your windows project and see an associated package that is running in Ubuntu respond.
This has yet to be tested for complicated scenarios or for service/client connections. If there is something missing from this or a step doesn't work, please contact the winros google group for more help.