Topic Info At Runtime
A list of all the Gazebo topics running on the system can be found with the command:
gz topic -l
Make sure Gazebo is running (the server) first.
The tilde (
~) in a topic name will be replaced with the default world path. Usually this is
A Gazebo Node (
gazebo::transport::Node) can advertise and subscribe to topics. The recommended way to create a Gazebo Node is through the use of the NodePtr type, which wraps a Node up in
gazebo::transport::NodePtr nodePtr = transport::NodePtr(new transport::Node());
The initialisation method,
Node::Init(), sets the global namespace of all topics. Note that
Init() does not have to be called for you to be able to use the Node.
Publishers are entities which publish messages onto a topic. Publishers can be created by calling the
Advertise() method of a node handle. An example would be:
imu_pub_ = node_handle_->Advertise<sensor_msgs::Imu>("~/imu", 1);
Advertise() returns a pointer to the publisher. This can be used later to publish messages.
Plugins are compiled are a shared library and are linked to Gazebo at runtime when needed.
All plugins must be defined in the gazebo namespace. There are the following types of plugins:
|GUI||Provides a GUI overlay. QT widgets can be added to the GUI through the plugin API. This can be used for something as simple as displaying the time or as complicated as a parameter entry form.|
|Model||Attached to a model.|
|Sensor||Must inherit from SensorPlugin.|
|System||System plugins are called at startup, before Gazebo is loaded. That allows them to configure the system in special ways.|
|World||Attached to a world.|
For each type of plugin there is a corresponding
GZ_REGISTER_xxx_PLUGIN(<class name>) macro for registering the plugin to the Gazebo engine.
When Gazebo tries to load a plugin, it either loads the full path (if a full path name was specified), or searches through the directories specified by the environment variable
As of Dec 2016 this package has 5 plugins:
GazeboRosGps- Publishes SatNavFix messages regarding the robots location in WGS84 coordinates.
Gazebo provides a standard way to provide assertions through the macro:
A standard example of using this macro would be:
GZ_ASSERT(x == 2, "x must equal 2.");
GZ_ASSERT is just a wrapper around
No namespace found
The error message might look something like:
[Err] [Node.cc:105] No namespace found
This is usually because a
.world file is loaded which contains external models which Gazebo tries to pull in from the model repository.
The exact line of code which prints this error can be found in the Node.cc file on BitBucket.
World files contain all elements of a simulation, including robots, lights, sensors, and static objects. The files are in
SDF format, and typically have a
.world extension (this is not strictly enforced).
Models can be included into world files with the following syntax:
<include> <uri>model://model_file_name</uri> </include>
If Gazebo has internet connectivity, it will search it’s online model database and download the appropriate models.
Gazebo uses environment variables to configure how it operates. It uses the following environment variables:
||Colon-separated set of directories where Gazebo will search for models|
||Colon-separated set of directories where Gazebo will search for other resources such as world and media files.|
||URI of the Gazebo master. This specifies the IP and port where the server will be started and tells the clients where to connect to.|
||Colon-separated set of directories where Gazebo will search for the plugin shared libraries at runtime.|
||URI of the online model database where Gazebo will download models from. You can set this to an empty string ("") to prevent Gazebo from downloading models (i.e. they are all provided locally).|
All of the above environment variables are set to sensible defaults by Gazebo.