Tutorials/2.2/plugins/ModelPush


 * 1) Prerequisites

Overview / HelloWorld Plugin Tutorial

> Note: If you're continuing from the previous tutorial, make sure you put in the proper `#include` lines for this tutorial that are listed below.


 * 1) Code

Source: `gazebo/examples/plugins/model_push`

Plugins allow complete access to the physical properties of models and their underlying elements (links, joints, collision objects). The following plugin will apply a linear velocity to its parent model.

cd ~/gazebo_plugin_tutorial gedit model_push.cc

Plugin Code: 


 * 1) Compiling the Plugin ###

Assuming the reader has gone through the Hello WorldPlugin tutorial, all that needs to be done is to add the following lines to `~/gazebo_plugin_tutorial/CMakeLists.txt`



Compiling this code will result in a shared library, ~/gazebo_plugin_tutorial/build/libmodel_push.so, that can be inserted in a Gazebo simulation.

cd ~/gazebo_plugin_tutorial/build cmake ../ make


 * 1) Running the Plugin ###

This plugin is used in the world file `examples/plugins/model_push/model_push.world`.

cd ~/gazebo_plugin_tutorial gedit model_push.world



The hook to attach a plugin to a model is specified at the end of the model element block using:

 

To start simulation, run

cd ~/gazebo_plugin_tutorial/ gzserver -u model_push.world

The `-u` option starts the server in a paused state.

In a separate terminal, start the gui

gzclient

Click on the play button in the gui to unpause the simulation, and you should see the box move.