## For instruction on writing tutorials
## http://www.ros.org/wiki/WritingTutorials
####################################
## Gazebo Plugin Introduction Tutorial
####################################
## for a custom note with links:
## note = For ROS Fuerte
## for the canned note of "This tutorial assumes that you have completed the previous tutorials:" just add the links 
## note.0= 
## descriptive title for the tutorial
## title = Gazebo Plugin Intro
## multi-line description to be displayed in search 
## description = A basic tutorial that shows users how to create a gazebo plugin.
## the next tutorial description (optional)
## next =
## links to next tutorial (optional)
## next.0.link=
## next.1.link=
## what level user is this tutorial for 
## level= BeginnerCategory
## keywords =
## domain_answers=answers.gazebosim.org
####################################

<<IncludeCSTemplate(TutorialCSHeaderTemplate)>>

<<TableOfContents(4)>>

{{{#!wiki red/solid
Users are highly discouraged from using the documentation and tutorials for Gazebo on this page. Gazebo is now a stand alone project at [[http://gazebosim.org/wiki/Tutorials|gazebosim.org]]. See documentation there, thanks!
}}}

<<Buildsystem()>>

{{{{{#!wiki buildsystem catkin
 /!\ Disclaimer; as of now (12/28/2012), this tutorial doesn't work with `catkin` since the dependency (`gazebo` pkg) is not yet catkinized.
}}}}}

== Install ROS ==
Install the [[simulator_gazebo]] stack.

== Create a Gazebo Plugin ==

Create a ROS package in a scratch workspace and add its path to `ROS_PACKAGE_PATH
{{{{{#!wiki buildsystem rosbuild
{{{
$ roscreate-pkg gazebo_tutorials gazebo
}}}
}}}}}

{{{{{#!wiki buildsystem catkin
{{{
$ catkin_create-pkg gazebo_tutorials gazebo
}}}
}}}}}

{{{
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:`pwd`
}}}

Create a very simple plugin as described [[http://gazebosim.org/wiki/tutorials/plugins/simple_world|here]] and save the file as `gazebo_tutorials/src/simple_world_plugin.cpp`:
{{{
#include "gazebo.hh"
#include "common/common.h"
#include <stdio.h>

namespace gazebo
{
  class HelloWorld : public WorldPlugin
  {
    public: HelloWorld() : WorldPlugin() 
            {
              printf("Hello World!\n");
            }

    public: void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf)
            {
            };

  };
  GZ_REGISTER_WORLD_PLUGIN(HelloWorld)
}
}}}

Update `gazebo_tutorials/CMakeLists.txt` by adding the following lines:
{{{{{#!wiki buildsystem rosbuild
{{{
rosbuild_add_library(gazebo_tutorials src/simple_world_plugin.cpp)
}}}
}}}}}

{{{{{#!wiki buildsystem catkin
{{{
add_executable(gazebo_tutorials src/simple_world_plugin.cpp)
target_link_libraries(gazebo_tutorials ${catkin_LIBRARIES})
}}}
}}}}}

Update `gazebo_tutorials/manifest.txt` by adding the following block:
{{{
  <export>
    <gazebo plugin_path="${prefix}/lib" gazebo_media_path="${prefix}" />
  </export>
}}}

== Compiling the Plugin ==

{{{
rosmake gazebo_tutorials
}}}

== Creating a World file ==
Save the following file as `gazebo_tutorials/worlds/hello.world`:

{{{
<?xml version="1.0"?> 
<gazebo version="1.0">
  <world name="default">
    <!-- A ground plane -->
    <include filename="ground_plane.model"/>

    <!-- A global light source -->
    <include filename="sun.light"/>

    <!-- reference to your plugin -->
    <plugin name="gazebo_tutorials" filename="libgazebo_tutorials.so"/>
  </world>
</gazebo>
}}}

== Running the plugin ==
Create the following launch file `gazebo_tutorials/launch/hello.launch`:
{{{
<launch>
  <!-- set use_sim_time flag -->
  <param name="/use_sim_time" value="true" />
  <node name="gazebo" pkg="gazebo" type="gazebo" args="$(find gazebo_tutorials)/worlds/hello.world" respawn="false" output="screen"/>
  <node name="gazebo_gui" pkg="gazebo" type="gui" respawn="false" output="screen"/>
</launch>
}}}

and finally,
{{{
roslaunch gazebo_tutorials hello.launch
}}}



## AUTOGENERATED DO NOT DELETE 
## TutorialCategory
## FILL IN THE STACK TUTORIAL CATEGORY HERE