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

Download models in the background #1669

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
717f1c4
Download models in the background
Aug 26, 2022
b6952a7
Added ability to disable parallel download
Aug 30, 2022
7fdb8aa
Merge branch 'gz-sim7' into nkoenig_download_parallel
Aug 30, 2022
7dc0b5b
fix help message
Aug 30, 2022
ce26ff7
cleanup
Aug 30, 2022
28280e5
Merge branch 'gz-sim7' into nkoenig_download_parallel
Oct 6, 2022
8ada77a
merged with gz-sim7
Oct 20, 2022
594a509
unblock GUI while waiting for assets
Oct 24, 2022
25bb933
Merge branch 'nkoenig_download_parallel' of github.com:gazebosim/gz-s…
Oct 24, 2022
3e3a362
Resource spawner thread
Oct 25, 2022
60c43b1
Support reset
Oct 25, 2022
d13f72b
working on updates
nkoenig Jun 22, 2023
2a99d60
merged with gz-sim7
nkoenig Jun 22, 2023
b206fe6
fixed build
nkoenig Jun 22, 2023
7d016b0
All tests pass!
nkoenig Aug 16, 2023
17d2763
Cleanup and codechecker
nkoenig Aug 18, 2023
ffdc26a
Merge branch 'gz-sim7' into nkoenig_download_parallel
nkoenig Aug 18, 2023
f79d8ce
More cleanup
nkoenig Aug 21, 2023
9bc310b
Increase UNIT_Server_TEST timeout
nkoenig Aug 23, 2023
85e13d6
Merged with gz-sim7
nkoenig Nov 2, 2023
41a1101
Merge branch 'gz-sim7' into nkoenig_download_parallel
nkoenig Nov 6, 2023
c299c98
Merge branch 'gz-sim7' into nkoenig_download_parallel
nkoenig Feb 14, 2024
ec23a22
Output errors, still create entities
nkoenig Mar 6, 2024
cf5f36a
Fix whitespace
nkoenig Mar 11, 2024
64d4244
Revert comments
nkoenig May 31, 2024
2ddc8cc
Merge branch 'gz-sim7' into nkoenig_download_parallel
nkoenig May 31, 2024
e2db6e3
Revert a few topic name generations
nkoenig Jun 3, 2024
bf259f5
Merge branch 'gz-sim7' into nkoenig_download_parallel
nkoenig Jun 3, 2024
656f6d6
Merged with gz-sim7
nkoenig Jun 26, 2024
7dd2db0
merged with gz-sim7
nkoenig Jul 3, 2024
69c2384
Merge branch 'gz-sim7' into nkoenig_download_parallel
nkoenig Aug 12, 2024
0be35e6
Simplify diff
nkoenig Aug 12, 2024
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
12 changes: 12 additions & 0 deletions include/gz/sim/ServerConfig.hh
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,18 @@ namespace gz
public: const std::chrono::time_point<std::chrono::system_clock> &
Timestamp() const;

/// \brief Set whether asset download should block simulation start.
/// The default value is true.
/// \param[in] _set True to wait while assets download. False will
/// download assets in a background thread.
public: void SetWaitForAssets(bool _set);

/// \brief Get whether asset download should block simulation start.
/// The default value is true.
/// \return True if simulation should wait while assets download. False
/// indicates assets should be downloaded in a separate thread.
public: bool WaitForAssets() const;

/// \brief Get the type of source
/// \return The source type.
public: SourceType Source() const;
Expand Down
2 changes: 1 addition & 1 deletion src/Conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ msgs::Geometry gz::sim::convert(const sdf::Geometry &_in)
}
}
}
else
else if (_in.Type() != sdf::GeometryType::EMPTY)
{
gzerr << "Geometry type [" << static_cast<int>(_in.Type())
<< "] not supported" << std::endl;
Expand Down
70 changes: 35 additions & 35 deletions src/LevelManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ LevelManager::LevelManager(SimulationRunner *_runner, const bool _useLevels)
this->CreatePerformers();

std::string service = transport::TopicUtils::AsValidTopic("/world/" +
this->runner->sdfWorld->Name() + "/level/set_performer");
this->runner->sdfWorld.Name() + "/level/set_performer");
if (service.empty())
{
gzerr << "Failed to generate set_performer topic for world ["
<< this->runner->sdfWorld->Name() << "]" << std::endl;
<< this->runner->sdfWorld.Name() << "]" << std::endl;
return;
}
this->node.Advertise(service, &LevelManager::OnSetPerformer, this);
Expand All @@ -101,15 +101,15 @@ void LevelManager::ReadLevelPerformerInfo()
this->runner->entityCompMgr.CreateComponent(this->worldEntity,
components::World());
this->runner->entityCompMgr.CreateComponent(
this->worldEntity, components::Name(this->runner->sdfWorld->Name()));
this->worldEntity, components::Name(this->runner->sdfWorld.Name()));

this->runner->entityCompMgr.CreateComponent(this->worldEntity,
components::Gravity(this->runner->sdfWorld->Gravity()));
components::Gravity(this->runner->sdfWorld.Gravity()));

auto physics = this->runner->sdfWorld->PhysicsByIndex(0);
auto physics = this->runner->sdfWorld.PhysicsByIndex(0);
if (!physics)
{
physics = this->runner->sdfWorld->PhysicsDefault();
physics = this->runner->sdfWorld.PhysicsDefault();
}
this->runner->entityCompMgr.CreateComponent(this->worldEntity,
components::Physics(*physics));
Expand Down Expand Up @@ -140,7 +140,7 @@ void LevelManager::ReadLevelPerformerInfo()
}

this->runner->entityCompMgr.CreateComponent(this->worldEntity,
components::MagneticField(this->runner->sdfWorld->MagneticField()));
components::MagneticField(this->runner->sdfWorld.MagneticField()));

this->runner->entityCompMgr.CreateComponent(this->worldEntity,
components::PhysicsEnginePlugin(
Expand All @@ -158,41 +158,41 @@ void LevelManager::ReadLevelPerformerInfo()
components::RenderEngineGuiPlugin(
this->runner->serverConfig.RenderEngineGui()));

auto worldElem = this->runner->sdfWorld->Element();
auto worldElem = this->runner->sdfWorld.Element();

// Create Wind
auto windEntity = this->runner->entityCompMgr.CreateEntity();
this->runner->entityCompMgr.CreateComponent(windEntity, components::Wind());
this->runner->entityCompMgr.CreateComponent(
windEntity, components::WorldLinearVelocity(
this->runner->sdfWorld->WindLinearVelocity()));
this->runner->sdfWorld.WindLinearVelocity()));
// Initially the wind linear velocity is used as the seed velocity
this->runner->entityCompMgr.CreateComponent(
windEntity, components::WorldLinearVelocitySeed(
this->runner->sdfWorld->WindLinearVelocity()));
this->runner->sdfWorld.WindLinearVelocity()));

this->entityCreator->SetParent(windEntity, this->worldEntity);

// scene
if (this->runner->sdfWorld->Scene())
if (this->runner->sdfWorld.Scene())
{
this->runner->entityCompMgr.CreateComponent(this->worldEntity,
components::Scene(*this->runner->sdfWorld->Scene()));
components::Scene(*this->runner->sdfWorld.Scene()));
}

// atmosphere
if (this->runner->sdfWorld->Atmosphere())
if (this->runner->sdfWorld.Atmosphere())
{
this->runner->entityCompMgr.CreateComponent(this->worldEntity,
components::Atmosphere(*this->runner->sdfWorld->Atmosphere()));
components::Atmosphere(*this->runner->sdfWorld.Atmosphere()));
}

// spherical coordinates
if (this->runner->sdfWorld->SphericalCoordinates())
if (this->runner->sdfWorld.SphericalCoordinates())
{
this->runner->entityCompMgr.CreateComponent(this->worldEntity,
components::SphericalCoordinates(
*this->runner->sdfWorld->SphericalCoordinates()));
*this->runner->sdfWorld.SphericalCoordinates()));
}

// TODO(anyone) This should probably go somewhere else as it is a global
Expand Down Expand Up @@ -230,16 +230,16 @@ void LevelManager::ReadLevelPerformerInfo()

// Load world plugins.
this->runner->EventMgr().Emit<events::LoadSdfPlugins>(this->worldEntity,
this->runner->sdfWorld->Plugins());
this->runner->sdfWorld.Plugins());

GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
this->runner->EventMgr().Emit<events::LoadPlugins>(this->worldEntity,
this->runner->sdfWorld->Element());
this->runner->sdfWorld.Element());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION

// Store the world's SDF DOM to be used when saving the world to file
this->runner->entityCompMgr.CreateComponent(
worldEntity, components::WorldSdf(*this->runner->sdfWorld));
worldEntity, components::WorldSdf(this->runner->sdfWorld));
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -458,11 +458,11 @@ void LevelManager::ConfigureDefaultLevel()

// Models
for (uint64_t modelIndex = 0;
modelIndex < this->runner->sdfWorld->ModelCount(); ++modelIndex)
modelIndex < this->runner->sdfWorld.ModelCount(); ++modelIndex)
{
// There is no sdf::World::ModelByName so we have to iterate by index and
// check if the model is in this level
auto model = this->runner->sdfWorld->ModelByIndex(modelIndex);
auto model = this->runner->sdfWorld.ModelByIndex(modelIndex);
// If model is a performer, it will be handled separately
if (this->performerMap.find(model->Name()) != this->performerMap.end())
{
Expand All @@ -478,11 +478,11 @@ void LevelManager::ConfigureDefaultLevel()

// Actors
for (uint64_t actorIndex = 0;
actorIndex < this->runner->sdfWorld->ActorCount(); ++actorIndex)
actorIndex < this->runner->sdfWorld.ActorCount(); ++actorIndex)
{
// There is no sdf::World::ActorByName so we have to iterate by index and
// check if the actor is in this level
auto actor = this->runner->sdfWorld->ActorByIndex(actorIndex);
auto actor = this->runner->sdfWorld.ActorByIndex(actorIndex);
// If actor is a performer, it will be handled separately
if (this->performerMap.find(actor->Name()) != this->performerMap.end())
{
Expand All @@ -499,9 +499,9 @@ void LevelManager::ConfigureDefaultLevel()
// Lights
// We assume no performers are lights
for (uint64_t lightIndex = 0;
lightIndex < this->runner->sdfWorld->LightCount(); ++lightIndex)
lightIndex < this->runner->sdfWorld.LightCount(); ++lightIndex)
{
auto light = this->runner->sdfWorld->LightByIndex(lightIndex);
auto light = this->runner->sdfWorld.LightByIndex(lightIndex);
if (this->entityNamesInLevels.find(light->Name()) ==
this->entityNamesInLevels.end())
{
Expand Down Expand Up @@ -531,9 +531,9 @@ void LevelManager::CreatePerformers()
}
// Models
for (uint64_t modelIndex = 0;
modelIndex < this->runner->sdfWorld->ModelCount(); ++modelIndex)
modelIndex < this->runner->sdfWorld.ModelCount(); ++modelIndex)
{
auto model = this->runner->sdfWorld->ModelByIndex(modelIndex);
auto model = this->runner->sdfWorld.ModelByIndex(modelIndex);
if (this->performerMap.find(model->Name()) != this->performerMap.end())
{
Entity modelEntity = this->entityCreator->CreateEntities(model);
Expand All @@ -549,9 +549,9 @@ void LevelManager::CreatePerformers()

// Actors
for (uint64_t actorIndex = 0;
actorIndex < this->runner->sdfWorld->ActorCount(); ++actorIndex)
actorIndex < this->runner->sdfWorld.ActorCount(); ++actorIndex)
{
auto actor = this->runner->sdfWorld->ActorByIndex(actorIndex);
auto actor = this->runner->sdfWorld.ActorByIndex(actorIndex);
if (this->performerMap.find(actor->Name()) != this->performerMap.end())
{
Entity actorEntity = this->entityCreator->CreateEntities(actor);
Expand Down Expand Up @@ -806,11 +806,11 @@ void LevelManager::LoadActiveEntities(const std::set<std::string> &_namesToLoad)

// Models
for (uint64_t modelIndex = 0;
modelIndex < this->runner->sdfWorld->ModelCount(); ++modelIndex)
modelIndex < this->runner->sdfWorld.ModelCount(); ++modelIndex)
{
// There is no sdf::World::ModelByName so we have to iterate by index and
// check if the model is in this level
auto model = this->runner->sdfWorld->ModelByIndex(modelIndex);
auto model = this->runner->sdfWorld.ModelByIndex(modelIndex);
if (_namesToLoad.find(model->Name()) != _namesToLoad.end())
{
Entity modelEntity = this->entityCreator->CreateEntities(model);
Expand All @@ -821,11 +821,11 @@ void LevelManager::LoadActiveEntities(const std::set<std::string> &_namesToLoad)

// Actors
for (uint64_t actorIndex = 0;
actorIndex < this->runner->sdfWorld->ActorCount(); ++actorIndex)
actorIndex < this->runner->sdfWorld.ActorCount(); ++actorIndex)
{
// There is no sdf::World::ActorByName so we have to iterate by index and
// check if the actor is in this level
auto actor = this->runner->sdfWorld->ActorByIndex(actorIndex);
auto actor = this->runner->sdfWorld.ActorByIndex(actorIndex);
if (_namesToLoad.find(actor->Name()) != _namesToLoad.end())
{
Entity actorEntity = this->entityCreator->CreateEntities(actor);
Expand All @@ -836,9 +836,9 @@ void LevelManager::LoadActiveEntities(const std::set<std::string> &_namesToLoad)

// Lights
for (uint64_t lightIndex = 0;
lightIndex < this->runner->sdfWorld->LightCount(); ++lightIndex)
lightIndex < this->runner->sdfWorld.LightCount(); ++lightIndex)
{
auto light = this->runner->sdfWorld->LightByIndex(lightIndex);
auto light = this->runner->sdfWorld.LightByIndex(lightIndex);
if (_namesToLoad.find(light->Name()) != _namesToLoad.end())
{
Entity lightEntity = this->entityCreator->CreateEntities(light);
Expand Down
Loading