Overview
Gazebo Fuel Tools lets you perform a set of operations over the resources hosted in any Gazebo Fuel server. These operations allow you to list all resources of a particular server, get the details of a resource or download it.
We're going to run a few examples, so let's start by creating a directory for this tutorial:
Download the files list.cc
, details.cc
, download.cc
, CMakeLists.txt
, and save them under /tmp/fuel_tutorial
:
Let's start by compiling the examples:
List resources from a Fuel server
Run the following example to see the list of models hosted in the default server:
You should see the name of the server followed by its list of models. Here's an example:
Walkthrough
This example contains some boilerplate to parse command line arguments and load some configuration. Refer to the configuration tutorial for details about this part of the code. Let's focus on the relevant code for listing resources:
As you can see, we're iterating over the list of servers. For each server, we use the Models()
or the Worlds()
method to retrieve all the relevant resources from that server. Then, iterate over the resulting resources and print their names.
Get details of a resource
Run the following example to see the details of a model hosted in the default server:
You should see the details of the model. Here's an example:
Walkthrough
This example contains some boilerplate to parse command line arguments and load some configuration. Refer to the configuration tutorial for details about this part of the code. Let's focus on the relevant code for getting details of a resource:
As usual, we're iterating over the list of servers. For each server, we use the ModelDetails()
or WorldDetails()
methods to retrieve most of the properties of the resource. Then if the resource is retrieved successfully, we use the AsPrettyString()
method to print its information to the screen.
Download a resource
Refer to the configuration tutorial to see an example of how to download resources programmatically.