--- 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 ``` ![](https://i.imgur.com/M7YpcLA.png) 3. Open model editor - Press ctrl+m - Or from menu "Edit -> Model Editor" ![](https://i.imgur.com/jM6NRLK.png) ## Create the chassis 1. Add a box ![](https://i.imgur.com/0GbvA5s.png) 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==) ![](https://i.imgur.com/NkYDMdM.png) 4. Adjust the Geometry in Collision tab. (==x:2.0, y:1.0, z:0.5==) ![](https://i.imgur.com/tj5fW2b.png) 5. Reserve some space between chassis and the floor by modifying the Pose in Link tab. (==z:0.4==) ![](https://i.imgur.com/AuhIQzs.png) 6. After clicking OK, you'll get a rectangle box, which is the chassis. ![](https://i.imgur.com/0VmtIRi.png) ## Add front wheels 1. Add a cylinder. ![](https://i.imgur.com/3nCy4ai.png) 2. Rotate the cylinder by modifying Roll value in Link tab.(==Roll:1.5707==, 90 degree) ![](https://i.imgur.com/5uGgZWq.png) 3. Decrease the size of wheel by modifying Geometry in Visual and Collision tab. (==radius:0.3, length:0.25==) ![](https://i.imgur.com/cJQJxtB.png) ![](https://i.imgur.com/aKUg4LA.png) 4. Now right click the wheel and copy another one. ![](https://i.imgur.com/ch7UxAQ.png) ## Add joint for front wheels 1. Click "Joint" in tool box. ![](https://i.imgur.com/R3hGPnX.png) 2. Select Joint types as ==Revolute== and then link the chassis and wheel. (==Chassis is parent, child is wheel==) ![](https://i.imgur.com/WKUCFnA.png) 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. ![](https://i.imgur.com/Ky7FxtA.png) 4. Align chassis and wheel on X-axis by setting Align links. (==X Align Max==) ![](https://i.imgur.com/BQJseU8.png) 5. Align chassis and wheel on Y-axis by setting Align links. (==Y Align Max, reverse==) ![](https://i.imgur.com/YSD7YJH.png) 6. Click Create and then double click the wheel. Set Pose of Z in Link tab. (==Z:03==) ![](https://i.imgur.com/NSy7ZTR.png) 7. Do the same thing on the other wheel but different value on Y Align links. (==Y Align Min, reverse==) ![](https://i.imgur.com/n9LFnX2.png) ![](https://i.imgur.com/rX7WrkR.png) ## Add Back wheel and joint 1. Add a ball. ![](https://i.imgur.com/LzOUlqS.png) 2. Adjust the Radius of Geometry in Visual and Collision tab. (==Radius:0.2==) ![](https://i.imgur.com/kPPPKJa.png) ![](https://i.imgur.com/4H3PoqY.png) 3. Add joint for back wheel. - Joint types: ==Ball== - Link Selections: ==chassis and back wheel== - Align links: ==X Align Min== and ==Y Align Center== ![](https://i.imgur.com/etL8jbe.png) 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. ![](https://i.imgur.com/qEnAaIb.png) ## Add Depth Camera and joint 1. Insert Depth Camera from Model Database. ![](https://i.imgur.com/41rfAUD.png) 2. Put Depth Camera on the top of chassis. ![](https://i.imgur.com/YxtZYGH.png) 3. Add the joint of Depth Camera. - Joint types: ==Fixed== - Link selections: ==chassis and camera== ![](https://i.imgur.com/TxCZcW6.png) ## Add new plugins 1. Add model plugins ![](https://i.imgur.com/16zpK4C.png) 2. Add plugin into Model Plugin Inspector. - Plugin name: ==follower== - Filename: ==libFollowerPlugin.so== ![](https://i.imgur.com/J49YuRz.png) 3. There will be "follower" under Model Plugins. ![](https://i.imgur.com/DsxBi7B.png) ## Save the model and demo 1. Click Menu=>Save as ![](https://i.imgur.com/Xx0FzM5.png) 3. Press ctrl+x to exist Model Editor. 4. Put an object behind the vehicle and press play. ![](https://i.imgur.com/CFUVXRf.png) 4. The vehicle will follow the object. ![](https://i.imgur.com/6LozP2q.png) ## How to use exsiting models You can reuse your model by adding the path where the model is saved. ![](https://i.imgur.com/Y7UnyK3.png) ## Reference * [Gazebo Models Example](https://github.com/Adlink-ROS/gazebo_demo)