# 9. ROS2-Movelt & Gazebo Simulation
## 9.1 Virtual Machine Installation and Configuration ### 9.1.1 Virtual Machine Installation and Import * **VMware Installation** A virtual machine allows us to run other operating systems within our current operating system. In this section, we will demonstrate the installation process using VMware Workstation as an example: (1) Unzip the virtual machine software package located under the "**Configuration File -\> VMware**" path.
(2) After unzipping, locate the virtual machine folder and double-click the executable file (with the "**.exe**" extension).
(3) Follow the on-screen instructions to complete the installation of the virtual machine.
(4) VMware Workstation offers 30-day free trial. After 30-day trial, you can purchase a license key to activate this software. If you need free resource, please contact us via email.
* **VirtualBox Installation**
(1) Open the software installation package in the same directory and click `Next`.
(2) Modify the installation path if needed, then click `Next`.
(3) No changes needed, just click `Next`.
(4) Confirm the installation and click `Start Installation`.
(5) Once the installation is complete, click `Finish`.
### 9.1.2 Virtual System Image Import
(1) In the software interface, click on `Open Virtual Machine`.
(2) Locate the required virtual machine file in the same directory, and open it.
(3) Select a storage path and click `Import`. Wait for the import to complete.
(4) Once the import is finished, you can start using the virtual machine.
### 9.1.3 Virtual Machine Settings
(1) Locate the virtual machine you just imported and click `Edit Virtual Machine Settings`.
(2) Click on `Network Adapter` and select `Bridged Mode`.
(3) Click on `Display` and uncheck the `Accelerate 3D Graphics` option.
:::Note
Enabling the "**Accelerate 3D Graphics**" option can negatively affect virtual machine performance and may cause lag during simulation.
:::
### 9.1.4 Configuration
It is normal for the virtual machine to take a longer time to start for the first time.
The virtual machine interface is as below:
* **Package Import (Performed on Virtual Machine)**
(1) Start the virtual machine. Click the system desktop icon
to open the command-line terminal.
(2) Click the "**Home**" icon
on the desktop to enter the Home directory.
(3) Locate the [jetacker_description.zip](resources_download.md), [robot_gazebo.zip](resources_download.md) compressed file in the same directory. Drag the compressed file into the **Home** directory of the virtual machine.
:::{Note}
Only drag one file at a time.
:::
(4) Right-click in the Home directory and select **"Open in terminal"** to open the terminal.
(5) Enter the following command to create a directory:
```
mkdir -p ~/ros2_ws/src
```
(6) Execute the following commands to extract the source files and enter the source directory:
```
unzip ~/jetacker_description.zip -d ~/ros2_ws/src/
```
```
unzip ~/robot_gazebo.zip -d ~/ros2_ws/src
```
If prompted to replace files, type **A** and press Enter.
(7) Run the following command to compile the packages and wait for the process to finish:
```
cd ~/ros2_ws && colcon build --symlink-install
```
(8) Run the following command to replace the `.typerc` file:
```
mv /home/ubuntu/.typerc ~/ros2_ws/.typerc
```
(9) Check if the file move was successful by running:
```
cd ~/ros2_ws/ && ls -a
```
(10) To update the settings, reload the configuration file using:
```
source ~/.bashrc
```
## 9.2 Introduction to URDF Models
### 9.2.1 URDF Model
:::{Note}
This tutorial is based on configuration and simulation within a virtual machine. If the virtual machine is not yet installed, please first refer to [9.1 Virtual Machine Installation and Configuration](#anchor_9_1) to complete the installation.
:::
* **URDF Model Introduction**
The Unified Robot Description Format (URDF) is an XML file format widely used in ROS (Robot Operating System) to comprehensively describe all components of a robot.
Robots are typically composed of multiple links and joints. A link is defined as a rigid object with certain physical properties, while a joint connects two links and constrains their relative motion.
By connecting links with joints and imposing motion restrictions, a kinematic model is formed. The URDF file specifies the relationships between joints and links, their inertial properties, geometric characteristics, and collision models.
* **Comparison between Xacro and URDF Model**
The URDF model serves as a description file for simple robot models, offering a clear and easily understandable structure. However, when it comes to describing complex robot structures, using URDF alone can result in lengthy and unclear descriptions.
To address this limitation, the xacro model extends the capabilities of URDF while maintaining its core features. The xacro format provides a more advanced approach to describe robot structures. It greatly improves code reusability and helps avoid excessive description length.
For instance, when describing the two legs of a humanoid robot, the URDF model would require separate descriptions for each leg. On the other hand, the xacro model allows for describing a single leg and reusing that description for the other leg, resulting in a more concise and efficient representation.
* **Install URDF Dependency**
:::{Note}
The URDF and Xacro models are already pre-installed in the virtual machine, so there is no need for users to reinstall them. This section is for informational purposes only.
:::
(1) Run the following command and press Enter to update the package information:
```
sudo apt update
```
(2) Run the following command and press Enter to install the URDF dependencies:
```
sudo apt-get install ros-humble-urdf
```
When the output matches the image below, the installation is successful:
(3) Run the following command and press Enter to install the Xacro model extension for URDF:
```
sudo apt-get install ros-humble-xacro
```
When the output matches the image below, the installation is successful:
* **URDF Model Basic Syntax**
(1) XML Basic Syntax
The URDF model is written using XML standard.
**Elements**:
An element can be defined as desired using the following formula:
```