This section discusses how to prepare a virtual machine for installing ROS. Because many students don’t have a spare computer they can load Ubuntu on, a virtual machine often makes sense. The most recent versions of virtualbox are quite adept and providing full support to usb devices piped in through a windows host, making this a nice, general solution for developing ROS environments.
If you are installing a linux virtual machine on your windows computer, your windows computer is called the “host”, and the linux virtual machine is called the “guest”
You will need some packages installed on the host side to communicate with your guest(virtual) machine
You’ll need some additional packages. From a command prompt:
pip install service_identity roslibpy
You probably want Ubuntu 18.04 (LTS) desktop edition. Make sure you download an .iso file so that the virutal machine can load it.
Note: The ROS version you want to use impacts which Ubuntu version you should select. They are paired together.
The next steps outline how to go about creating a Virtual Machine similar to the one used in this tutorial.
Note: All these steps should be run within the guest.
Hint: To open up a terminal, remember the handy keyboard-based shortcut of
install guest additions
First, run this in the terminal
sudo apt install -y virtualbox-guest-utils virtualbox-guest-dkms
Install the virtualbox guest additions cd from the guest os window and select run when the button pops up.
let it run
eject the cd from the virtualbox host menu
Restart guest computer (using the guest menu in the top right corner)
Install other packages. See Ros Prerequisites
Take another Snapshot
Follow the detailed installation instructions at https://wiki.ros.org/melodic/Installation/Ubuntu, or follow the condensed instructions in the next section.
Power down your guest machine from within the guest OS (top right corner of the screen)
Once powered down, in your host machine, change the virtualbox network settings to “bridged adapter” mode
Assign a custom MAC address to the guest in the advanced preferences menu. This will make your virtual machine easier to identify for further network setup
Start the guest machine again
Find the ip address of ethernet port in the terminal
#sudo apt install net-tools ifconfig -v
this will return information about each networking device, that looks like this:
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.0.17 netmask 255.255.255.0 broadcast 192.168.0.255 inet6 2600:8800:2281:3600:a6d7:41a9:9d6b:e48b prefixlen 64 scopeid 0x0<global> inet6 fe80::7804:5434:c83:a827 prefixlen 64 scopeid 0x20<link> inet6 2600:8800:2281:3600:588c:62a0:442a:d6ce prefixlen 64 scopeid 0x0<global> ether 08:00:27:00:80:00 txqueuelen 1000 (Ethernet) RX packets 47127 bytes 47300474 (47.3 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 13563 bytes 1385399 (1.3 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 117914 bytes 20197993 (20.1 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 117914 bytes 20197993 (20.1 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
The value you want is the “inet” value under, in this case, enp0s3, or 192.168.0.17 in our case. Remember this value, this is how you will communicate with your virtual pc
You can do this in your router or within the guest machine; this will enable you to communicate with this machine at a known address.
Please see the router specific instructions for reserving a specific IP address (using the guest machine’s custom MAC address) using DHCP. You must have administrator access to your router
Open up the network configuration (top right hand corner of the screen near power) and follow the menu system to assign a custom IP4 address to your ethernet controller. You should be comfortable with networking concepts and have a firm understanding of your network topology before modifying this setting, or other computers will no longer be able to communicate with this computer.