---
tags: ROS2note,Gazebo,Training
---
This is the simplified tutorial for creating a simple vehicle, which can follow the object. The detail steps can refer to [offical website](http://gazebosim.org/tutorials?cat=guided_b&tut=guided_b3).
# Tutorial
## Open Gazebo and model editor
1. Open terminal
2. Execute Gazebo
```
gazebo
```

3. Open model editor
- Press ctrl+m
- Or from menu "Edit -> Model Editor"

## Create the chassis
1. Add a box

2. Double click the box and show Link Inspector.
3. Adjust the Geometry in Visual tab. (==x:2.0, y:1.0, z:0.5==)

4. Adjust the Geometry in Collision tab. (==x:2.0, y:1.0, z:0.5==)

5. Reserve some space between chassis and the floor by modifying the Pose in Link tab. (==z:0.4==)

6. After clicking OK, you'll get a rectangle box, which is the chassis.

## Add front wheels
1. Add a cylinder.

2. Rotate the cylinder by modifying Roll value in Link tab.(==Roll:1.5707==, 90 degree)

3. Decrease the size of wheel by modifying Geometry in Visual and Collision tab. (==radius:0.3, length:0.25==)


4. Now right click the wheel and copy another one.

## Add joint for front wheels
1. Click "Joint" in tool box.

2. Select Joint types as ==Revolute== and then link the chassis and wheel. (==Chassis is parent, child is wheel==)

3. Set Joint axis to make the wheel rotate with z-axis. (==z,0,0,1==)
- X-axis: red, Y-axis: green, Z-axis: blue.

4. Align chassis and wheel on X-axis by setting Align links. (==X Align Max==)

5. Align chassis and wheel on Y-axis by setting Align links. (==Y Align Max, reverse==)

6. Click Create and then double click the wheel. Set Pose of Z in Link tab. (==Z:03==)

7. Do the same thing on the other wheel but different value on Y Align links. (==Y Align Min, reverse==)


## Add Back wheel and joint
1. Add a ball.

2. Adjust the Radius of Geometry in Visual and Collision tab. (==Radius:0.2==)


3. Add joint for back wheel.
- Joint types: ==Ball==
- Link Selections: ==chassis and back wheel==
- Align links: ==X Align Min== and ==Y Align Center==

4. Adjust the Z pose of the back wheel.
- You need to select wheel from Model tab, since the is already hidden in the chassis.

## Add Depth Camera and joint
1. Insert Depth Camera from Model Database.

2. Put Depth Camera on the top of chassis.

3. Add the joint of Depth Camera.
- Joint types: ==Fixed==
- Link selections: ==chassis and camera==

## Add new plugins
1. Add model plugins

2. Add plugin into Model Plugin Inspector.
- Plugin name: ==follower==
- Filename: ==libFollowerPlugin.so==

3. There will be "follower" under Model Plugins.

## Save the model and demo
1. Click Menu=>Save as

3. Press ctrl+x to exist Model Editor.
4. Put an object behind the vehicle and press play.

4. The vehicle will follow the object.

## How to use exsiting models
You can reuse your model by adding the path where the model is saved.

## Reference
* [Gazebo Models Example](https://github.com/Adlink-ROS/gazebo_demo)