Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport support for <uri>s from Fuel #255

Merged
merged 3 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions examples/worlds/fuel.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,44 @@
</link>
</model>

<!-- Included model without meshes -->
<include>
<uri>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Double pendulum with base</uri>
</include>

<!-- Included model with meshes -->
<include>
<pose>1 0 0 0 0 0</pose>
<uri>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Backpack</uri>
</include>

<!-- Included model with meshes using relative paths -->
<include>
<pose>2 5 0 0 0 0</pose>
<uri>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Gazebo - relative paths</uri>
</include>

<!-- Model with meshes -->
<model name="Radio">
<pose>3 -1.5 0 0 0 0</pose>
<static>true</static>
<link name="link">
<collision name="collision">
<geometry>
<mesh>
<uri>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Radio/4/files/meshes/Radio.dae</uri>
</mesh>
</geometry>
</collision>
<visual name="visual">
<geometry>
<mesh>
<uri>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Radio/4/files/meshes/Radio.dae</uri>
</mesh>
</geometry>
</visual>
</link>
</model>

</world>
</sdf>
2 changes: 2 additions & 0 deletions src/Server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ Server::Server(const ServerConfig &_config)
// Configure SDF to fetch assets from ignition fuel.
sdf::setFindCallback(std::bind(&ServerPrivate::FetchResource,
this->dataPtr.get(), std::placeholders::_1));
common::addFindFileURICallback(std::bind(&ServerPrivate::FetchResourceUri,
this->dataPtr.get(), std::placeholders::_1));

sdf::Errors errors;

Expand Down
6 changes: 6 additions & 0 deletions src/ServerPrivate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -418,3 +418,9 @@ std::string ServerPrivate::FetchResource(const std::string &_uri)
}
return path;
}

//////////////////////////////////////////////////
std::string ServerPrivate::FetchResourceUri(const common::URI &_uri)
{
return this->FetchResource(_uri.Str());
}
5 changes: 5 additions & 0 deletions src/ServerPrivate.hh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ namespace ignition
/// \return Path to the downloaded resource, empty on error.
public: std::string FetchResource(const std::string &_uri);

/// \brief Fetch a resource from Fuel using fuel-tools.
/// \param[in] _uri The resource URI to fetch.
/// \return Path to the downloaded resource, empty on error.
public: std::string FetchResourceUri(const common::URI &_uri);

/// \brief Signal handler callback
/// \param[in] _sig The signal number
private: void OnSignal(int _sig);
Expand Down
6 changes: 6 additions & 0 deletions src/gui/GuiRunner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <ignition/common/Console.hh>
#include <ignition/common/Profiler.hh>
#include <ignition/fuel_tools/Interface.hh>
#include <ignition/gui/Application.hh>

// Include all components so they have first-class support
Expand All @@ -34,6 +35,11 @@ GuiRunner::GuiRunner(const std::string &_worldName)
this->setProperty("worldName", QString::fromStdString(_worldName));
this->stateTopic = "/world/" + _worldName + "/state";

common::addFindFileURICallback([] (common::URI _uri)
{
return fuel_tools::fetchResource(_uri.Str());
});

igndbg << "Requesting initial state from [" << this->stateTopic << "]..."
<< std::endl;

Expand Down