Home | Tutorials | Wiki | Issues
Ask Your Question

What Is The Best Way to0 Learn GAZEBO in ROS For Beginners?

asked 2013-03-20 16:45:43 -0500

updated 2013-03-20 16:46:46 -0500

i am beginner and i wanna learn how can I use gazebo in ros. i installed gazebo 1.5.0 in synaptic.

in http://gazebosim.org/wiki/1.5/install wroted:

Only install Gazebo from here, and only follow tutorials from this website. Documentation on ros.org for Gazebo is old and not actively maintained.

and i wanna work gazebo with ros interface, but i'm confused! cus there is another tutorial for gazebo here >> http://www.ros.org/wiki/simulator_gazebo/Tutorials

what is your idea?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-03-21 07:08:13 -0500

GAugusto gravatar image

updated 2013-04-04 09:16:13 -0500

hello. ROS simulator gazebo is outdated, use the gazebosim here wich is the one being updated and developed.

You can follow the tutorials here to learn how to use sensor data and move models and then use a plugin to send data to ROS. You will need some knowledge of ROS publishing/subscribe to topics and types of messages, but once this "bridge" is set up you can use ROS to send vel commands to your gazebo robot.

At the moment i have a robot in gazebo that sends laser scans and Pose to ROS and receives geometry_msgs/Twist (linear and angular vel) to move him around. With this i'm able to use ROS gmapping and rviz to create the maps just like in any other ROS simulation.

EDIT/UPDATE: @amit, and everyone who might find this usefull to use Gazebosim and ROS, this assumes you have done the tutorials, specialy Control model and ROS-enabled plugin. Also i'm using gazebo-1.4 and ROS fuerte.

WARNING: this is what i did, i'm not using join commands (and don't intend to for now), only set the velocity of the model, using a robot model without friction and the hokuyo model for laser, already in the gazebo models library (gazebosim.org/models). I'm almost sure that you can use the tutorial "box" (not tried it myself tho).

->If there are better ways of doing it please feel free to comment.

TYPOS: the forum feature that uses underscores "_" to set italic text is setting some parts of my answer to italic without me wanting to and removing underscores where it should not.

Be sure to get familiar with ROS messages, in this case geometrymsgs/Twist , geometrymsgs/PoseStamped (http://www.ros.org/wiki/geometrymsgs) and sensormsgs/LaserScan (http://ros.org/wiki/sensor_msgs) and have some understanding of publishing/subscribing topics in ROS. I tried to clean, comment and remove unecessary code the best i could. Hope you get the basic ideas of how things work and then experiment on your own.

#include <boost/bind.hpp>
#include <gazebo.hh>
#include <physics/physics.hh>
#include <common/common.hh>
#include <stdio.h>

#include "ros/ros.h"
#include "geometry_msgs/Twist.h"
#include "geometry_msgs/PoseStamped.h"
#include "sensor_msgs/LaserScan.h"

#include "gazebo/gazebo.hh"
#include "gazebo/physics/physics.hh"
#include "gazebo/common/common.hh"
#include "gazebo/sensors/RaySensor.hh"
#include "gazebo/sensors/SensorManager.hh"
#include "math/Vector3.hh"
#include <math/gzmath.hh>

static float Vlin=0.0, Vang=0.0; // set as global 

namespace gazebo
  class ROSModelPlugin : public ModelPlugin
    public: ROSModelPlugin()
      // Start up ROS
      std::string name1 = "gz"; // this is what appears in the rostopics
      int argc = 0;
      ros::init(argc, NULL, name1);      
    public: ~ROSModelPlugin()
      delete this->nh;

    public: void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/)
      // Store the pointer to the model
      this->model = _parent;

      // ROS Nodehandle
      this->nh = new ros::NodeHandle("~");
      // ROS Subscriber
      this->subvel = this->nh->subscribe<geometry_msgs::Twist>("cmd_vel", 1000, &ROSModelPlugin::ROSCallback_Vel, this );

      this->nh = new ...
edit flag offensive delete link more


Hi :) tnx! i read Ros beginner level tutorials from here >> http://www.ros.org/wiki/ROS/Tutorials but now i wanna learn gazzebo first, then use ROS interface for. i find some link for next step : (http://gazebosim.org/wiki/Tutorials#GazeboVersion1.5) , (http://gazebosim.org/userguide/) , (http://gazebosim.org/wiki/MainPage) , (http://www.ros.org/wiki/gazebo) , (http://www.ros.org/wiki/simulatorgazebo) , (http://www.ros.org/wiki/simulatorgazeb). what is your idea if i wanna learn in order?

Mohsen Hk gravatar imageMohsen Hk ( 2013-03-21 16:17:58 -0500 )edit

The best way to learn Gazebo is to follow the tutorials (http://gazebosim.org/wiki/tutorials). Once you're ready, you can advance onto ROS plugins(http://gazebosim.org/wiki/Tutorials/1.5/rosenabledmodel_plugin)

nkoenig gravatar imagenkoenig ( 2013-03-22 11:01:35 -0500 )edit

hello. i advise you start with the tutorials from gazebosim 1.5 version, then you will have a basic idea of how things work. http://gazebosim.org/wiki/Tutorials#GazeboVersion1.5 in between "Building a Robot" and "Plugins" go to version 1.3 (3.3 on the tutorial page) and do "Controlling a Robot" (this section is not on 1.4 and 1.5) wich will give some understanding on how to move objects/robots. then ros model plugin http://gazebosim.org/wiki/Tutorials/1.5/rosenabledmodel_plugin

GAugusto gravatar imageGAugusto ( 2013-03-22 11:04:25 -0500 )edit

thank you friends :)

Mohsen Hk gravatar imageMohsen Hk ( 2013-03-23 06:31:31 -0500 )edit

@GAugusto Hi, You have mentioned that you have a robot in Gazebo that sends laser scans and Pose to ROS and receives geometry_msgs/Twist (linear and angular vel) to move him around. I need to do the same thing. Could you please explain a little further how did you do it ?

amit gravatar imageamit ( 2013-04-02 19:40:48 -0500 )edit

@amit hi, i edited my answer, hope that helps. also some parts where the text is italic are missing "_" underscores and that might give the typos. saddly can't find a way around it.

GAugusto gravatar imageGAugusto ( 2013-04-03 11:36:19 -0500 )edit

Hi, if there's anyone who's done ROS plugins in gazebosim in Python, please provide code/tips, etc., for people who prefer python over C++. Thanks!

logicalguy gravatar imagelogicalguy ( 2013-04-03 12:16:53 -0500 )edit

Thanks GAugusto..

amit gravatar imageamit ( 2013-04-03 23:25:23 -0500 )edit

Hello. I have two questions. 1) ROS is communicated through plugin, so to control a robot , publishing force/volocity to the robot, and receive the position/sensor data, we need plugin, and we also need to write our own ROS-Node, is this true? 2) do you recommand any resource for writing the plugin and the ROS to achieve the purposes mention in question 1? thank you very much for your time. very appreciated!

gazer gravatar imagegazer ( 2013-05-20 00:43:27 -0500 )edit
nkoenig gravatar imagenkoenig ( 2013-05-20 17:31:11 -0500 )edit
Login/Signup to Answer

Question Tools



Asked: 2013-03-20 16:45:43 -0500

Seen: 4,833 times

Last updated: Apr 04 '13