Pages

Sunday 30 June 2024

Set up a VM to run Gazebo and ROS2

More than a tutorial, this is going to be a summary of the links I used and the hiccups I found in the process of learning Gazebo and ROS 2.

I installed an Ubuntu 22.04 VM. One important thing to consider is that Gazebo requires significant CPU power, so at least 3-4 cores are needed for the simulations to run smoothly.

These are the steps that I followed for the VM:


Step 1: Download and Install VirtualBox

  1. Go to the VirtualBox website.
  2. Click on "Download VirtualBox."
  3. Choose the appropriate version for your operating system (Windows, macOS, Linux).
  4. Download and install VirtualBox by following the on-screen instructions.

Step 2: Download Ubuntu 22.04 ISO

  1. Go to the Ubuntu website.
  2. Click on "Download" for Ubuntu 22.04 LTS.
  3. Save the ISO file to your computer.

Step 3: Create a New Virtual Machine

  1. Open VirtualBox.
  2. Click on "New" to create a new virtual machine.
  3. Enter a name for your VM (e.g., "Ubuntu 22.04").
  4. Choose the type as "Linux" and the version as "Ubuntu (64-bit)."
  5. Click "Next."

Step 4: Allocate Memory (RAM)

  1. Allocate the desired amount of RAM for the VM. A minimum of 2 GB (2048 MB) is recommended, but 4 GB or more is preferred for better performance.
  2. Click "Next."

Step 5: Create a Virtual Hard Disk

  1. Choose "Create a virtual hard disk now" and click "Create."
  2. Select "VDI (VirtualBox Disk Image)" and click "Next."
  3. Choose "Dynamically allocated" and click "Next."
  4. Set the size of the virtual hard disk. A minimum of 25 GB is recommended.
  5. Click "Create."

Step 6: Configure the VM Settings

  1. Select your newly created VM and click on "Settings."
  2. Go to the "System" tab, then the "Processor" tab, and allocate at least 2 CPU cores.
  3. Go to the "Storage" tab, click on the empty optical drive, and choose "Choose a disk file."
  4. Select the Ubuntu 22.04 ISO file you downloaded earlier and click "Open."
  5. Go to the "Network" tab and ensure that "Attached to" is set to "NAT."

Step 7: Start the VM and Install Ubuntu

  1. Click "Start" to boot the VM.
  2. The VM will boot from the Ubuntu ISO. Select "Install Ubuntu" from the menu.
  3. Follow the on-screen instructions to install Ubuntu. This will include selecting your language, keyboard layout, and installation type (usually "Erase disk and install Ubuntu" for a clean installation).
  4. Set your timezone, create a user account, and set a password.
  5. Continue with the installation process. This may take some time.

Step 8: Complete Installation and Reboot

  1. Once the installation is complete, you will be prompted to restart the VM.
  2. After restarting, you may need to remove the ISO from the virtual drive. Go to "Devices" > "Optical Drives" > "Remove disk from virtual drive."
  3. Restart the VM again if necessary.

Step 9: Install VirtualBox Guest Additions (Optional but Recommended)

  1. With the VM running, go to "Devices" > "Insert Guest Additions CD image."

  2. Open a terminal in Ubuntu and run the following commands to install the necessary packages:

    sudo apt update sudo apt install build-essential dkms linux-headers-$(uname -r)
  3. Mount the Guest Additions CD if not already mounted, and run the installer:

    sudo /media/$USER/VBox_GAs_*/VBoxLinuxAdditions.run
  4. Reboot the VM after the installation is complete.

Now you have Ubuntu 22.04 installed and running in a VirtualBox VM!


Gazebo Installation

As I have ubuntu 22.04 the guide recommends gazebo fortress

The following are the instruction from Gazebo ignition fortress.....

https://gazebosim.org/docs/fortress/install_ubuntu

Binary Installation on Ubuntu

Fortress binaries are provided for Ubuntu Bionic, Focal and Jammy. All of the Fortress binaries are hosted in the osrfoundation repository. To install all of them, the metapackage ignition-fortress can be installed.

First install some necessary tools:

sudo apt-get update
sudo apt-get install lsb-release wget gnupg

Then install Ignition Fortress:

sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
sudo apt-get update
sudo apt-get install ignition-fortress

All libraries should be ready to use and the ign gazebo app ready to be executed.




No comments: