# Introduction to Gazebo
###### tags: `tutorial` `electrical_system` `NTURT` `vehicle_dynamics`
##### Author: @QuantumSpawner
## Why using gazebo
Before you actually build your robot, or in case operating it requires tremendous setups, constructing your virtual robot, or a digital twin, is often the better choice in terms of time and cost during development. That's why we resort to a simulation environment for testing vehicle dynamics before we even make our race car.
Gazebo is commonly known as a simulating environment for ROS as its throughout integration with ROS. Therefore we choose it as our simulating environment.
Please checkout this extensive overview of when to use gazebo: [Robotic simulation scenarios with Gazebo and ROS](https://www.generationrobots.com/blog/en/robotic-simulation-scenarios-with-gazebo-and-ros/)
and the official website of gazebo: [Gazebo](https://gazebosim.org/home)
## Getting started - gazebo on ROS
Youtube video playlist: [Gazebo in 5 Minutes](https://www.youtube.com/watch?v=qi2A32WgRqI&list=PLK0b4e05LnzbHiGDGTgE_FIWpOCvndtYx&index=1)
Written and desktop description:
1. [How To Launch Your First Gazebo World Using ROS](https://www.theconstructsim.com/gazebo-5-mins-launch-first-gazebo-world-using-ros/)
2. [How to add gazebo models to a simulation](https://www.theconstructsim.com/gazebo-5-minutes-002-add-gazebo-models-simulation/)
3. [How to spawn a robot in gazebo](https://www.theconstructsim.com/gazebo-5-minutes-003-spawn-robot-gazebo/)
4. [How to create a gazebo model using SDF](https://www.theconstructsim.com/gazebo-5-minutes-004-create-gazebo-model-using-sdf/)
5. [How to use a mesh file to create a gazebo model](https://www.theconstructsim.com/gazebo-5-minutes-005-use-mesh-file-create-gazebo-model/)
6. [How to use an image file as texture for gazebo model](https://www.theconstructsim.com/gazebo-5-minutes-006-use-image-file-texture-gazebo-model-2/)
7. [How to create a robot using URDF #Part 1 – Links](https://www.theconstructsim.com/gazebo-5-minutes-007-create-robot-using-urdf-part-1-links/)
8. [How to visualize a robot URDF using RVIZ](https://www.theconstructsim.com/gazebo-5-minutes-008-visualize-robot-urdf-using-rviz/)
9. [How to create a robot using URDF](https://www.theconstructsim.com/gazebo-5-mins-009-create-robot-using-urdf-part-2-joints/)
10. [How to launch RViz using a configuration file](https://www.theconstructsim.com/gazebo-in-5-minutes-010-how-to-launch-rviz-using-a-configuration-file/)
11. [How to use joint_state_publisher](https://www.theconstructsim.com/gazebo-in-5-minutes-011-how-to-use-joint_state_publisher/)
### Gazebo documentations
Official gazebo tutorial: [Gazebo Tutorial](https://classic.gazebosim.org/tutorials)
Using gazebo with ROS: [Connect to ROS](https://classic.gazebosim.org/tutorials?cat=connect_ros)
Documentation: [Gazebo API](https://osrf-distributions.s3.amazonaws.com/gazebo/api/dev/index.html)
## Gazebo topic
:::success
Please utilize the provided docker environment.
:::
:::success
Please document your code using doxygen.
:::
:::success
Please push your homework onto your github repository in the `gazebo` directory.
:::
Before entering electrical system group, we hope you not only have the basic understanding of gazebo, but also can use it in practical scenarios.
Hence, please design a vehicle(a cuboid with four wheels is enough) in gazebo, with the following minimum requirements and optional features.
:::info
Note: Please describe briefly about how you implement your vehicle in gazebo and how to launch and control it in a `README.md` file. Please also point out what optional feature(s) is implemented and how you achieve it.
:::
### Minium requirements
1. Construct a vehicle model that's a cuboid with four wheels in urdf or xacro. The `interial`, `visual` and `collision` part should be considered. Please checkout: [urdf/Tutorials](https://wiki.ros.org/urdf/Tutorials), and [Tutorial: Using a URDF in Gazebo](https://classic.gazebosim.org/tutorials?tut=ros_urdf&cat=connect_ros)
:::info
Something as simple as this is good enough

:::
3. Coordinate transform is such an important aspect of ROS, please consider and broadcast the transform of the vehicle body. Please checkout: [tf2/tutorial](https://wiki.ros.org/tf2/Tutorials).
4. Use ROS to control the vehicle. There are two possible solutions here, one is to use `ros_control` package and gazebo physic engine, see: [Tutorial: ROS Control](https://classic.gazebosim.org/tutorials?tut=ros_control&cat=connect_ros), or write a gazebo model plugin that calculates vehicle dynamics, see: [Model plugins](https://classic.gazebosim.org/tutorials?tut=plugins_model&cat=write_plugin).
There is no limitation on what type of vehicle actuation you should build. single motor, front/rear or four wheel drive, or even independent drive.
If you don't know how to input to ROS from the keyboard, see: [teleop_twist_keyboard](https://wiki.ros.org/teleop_twist_keyboard).
### Optional features
1. Add some sensors(encoder, imu, gps, pedal travel, etc) that simulates the sensors on our race car. And plot them using [rqt_multiplot](https://wiki.ros.org/rqt_multiplot).
2. Consider simple vehicle dynamics, especially Pacejka tire model if you use the standard friction formula as your tire model.