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

[Garden] Download models in the background #1484

Closed
wants to merge 83 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
11e029a
SystemInternal and WorldControl into own headers
mjcarroll Feb 15, 2022
56f28bd
Move System interaction to SystemManager
mjcarroll Feb 15, 2022
c35e3ce
Adjustments for Fortress
mjcarroll Feb 16, 2022
8266e73
Address reviewer feedback
mjcarroll Feb 17, 2022
ca91023
Introduce System::Reset API
mjcarroll Feb 8, 2022
85cb36e
SimulationRunner Reset implementation
mjcarroll Feb 8, 2022
144556d
Simulation Reset implementation in Physics system
mjcarroll Feb 8, 2022
4b023fa
Simulation reset example plugin
mjcarroll Feb 8, 2022
75e57fb
Add integration test for resetting physics
mjcarroll Feb 8, 2022
e3368e5
Fix diff test and add documentation
mjcarroll Feb 15, 2022
63ec622
Fix build and test errors after merge, some documentation and cleanup.
azeey Feb 24, 2022
222695d
Merge branch 'reset' into reset_physics
azeey Feb 24, 2022
e5f01bc
Merge branch 'main' into reset_physics
mjcarroll Mar 23, 2022
859df32
Bump year
mjcarroll Mar 29, 2022
8c669b0
Merge branch 'main' into reset_physics
mjcarroll Mar 29, 2022
749daca
Fix merge from main
mjcarroll Mar 29, 2022
371d8ce
Fix CI platform
mjcarroll Mar 29, 2022
d1fabbe
Update test/integration/reset.cc
mjcarroll Mar 30, 2022
8ddb739
Merge branch 'main' into reset_physics
mjcarroll Apr 4, 2022
32d21f5
Merge branch 'main' into reset_physics
chapulina Apr 8, 2022
a766933
Merge branch 'main' into reset_physics
mjcarroll Apr 18, 2022
c8ab4d5
Address reviewer feedback
mjcarroll Apr 18, 2022
0c52ab3
Reset sensors and scenebroadcaster implementation
mjcarroll Feb 22, 2022
825c280
Remove debug outputs
mjcarroll Mar 31, 2022
68f6f85
Address reviewer feedback
mjcarroll Mar 31, 2022
0bd1d6b
Merge branch 'main' into reset_physics
mjcarroll May 2, 2022
3799ff3
Adjust randomized range to account for limits
mjcarroll May 3, 2022
fbf6d0e
Fix header for new location
mjcarroll May 3, 2022
383006f
Merge branch 'reset_physics' into reset_sensors
mjcarroll May 3, 2022
5cff795
Merge branch 'main' into reset_physics
mjcarroll May 10, 2022
a519149
Fixup CMake dependencies for reset_plugin
mjcarroll May 10, 2022
bf2ea81
Download models in the background
ahcorde May 13, 2022
dc0cdbb
Merge branch 'main' into reset_sensors
mjcarroll May 17, 2022
e1acbb0
Address reviewer feedback
mjcarroll May 17, 2022
934c115
Merge remote-tracking branch 'origin/main' into ahcorde/garden/downlo…
ahcorde May 20, 2022
f91188d
improve implementation
ahcorde May 20, 2022
110c6a8
cleanup
ahcorde May 23, 2022
60ea603
Merge branch 'main' into reset_sensors
mjcarroll May 24, 2022
443ac22
updated method name
ahcorde May 26, 2022
093ca37
Merge branch 'main' into reset_sensors
mjcarroll May 31, 2022
4770dc7
Updates for main and add topic test
mjcarroll May 31, 2022
2286ec5
Fix interaction with log playback static variable
mjcarroll May 31, 2022
7e9245a
Also disable on Mac where OGRE2 doesn't load
mjcarroll Jun 1, 2022
0c4a4c5
Address reviewer feedback.
mjcarroll Jun 7, 2022
f717c96
Merge branch 'main' into reset_sensors
mjcarroll Jun 7, 2022
e096731
Merge branch 'main' into reset_sensors
mjcarroll Jun 13, 2022
d22f655
Merge branch 'main' into reset_sensors
chapulina Jun 14, 2022
ae3d076
Apply suggestions from code review
mjcarroll Jun 14, 2022
df6cc36
Better logging for reset in-memory systems
mjcarroll Jun 14, 2022
768aee2
Impove sensor reset logging and drop cast
mjcarroll Jun 14, 2022
26d7396
More informative warning on systems not implementing reset
mjcarroll Jun 14, 2022
b211196
Prune headers in reset_sensors test
mjcarroll Jun 14, 2022
101654a
Update LogPlayback reset functionality
mjcarroll Jun 14, 2022
4294d49
Merge remote-tracking branch 'origin/main' into ahcorde/garden/downlo…
ahcorde Jun 17, 2022
23ccdf3
Fixed merge
ahcorde Jun 17, 2022
a466957
Merge remote-tracking branch 'origin/main' into ahcorde/garden/downlo…
ahcorde Jun 23, 2022
b3e88e9
Improved implmentation
ahcorde Jun 24, 2022
c1b3e4e
Merge branch 'main' into reset_sensors
mjcarroll Jun 27, 2022
0a841e5
Merge remote-tracking branch 'origin/main' into ahcorde/garden/downlo…
ahcorde Jun 27, 2022
ec890ef
Fixed SystemPlugin loader
ahcorde Jun 28, 2022
5d3cdce
Clean code
ahcorde Jun 28, 2022
9e7f5c3
Merge remote-tracking branch 'origin/reset_sensors' into ahcorde/gard…
ahcorde Jun 28, 2022
7db60c5
fix merge
ahcorde Jun 28, 2022
4248294
Fix
ahcorde Jun 28, 2022
5cb7630
make linters happy
ahcorde Jun 28, 2022
5465f27
make linters happy
ahcorde Jun 28, 2022
33a1578
update worldname method
ahcorde Jun 29, 2022
09f4ce7
Merge remote-tracking branch 'origin/main' into ahcorde/garden/downlo…
ahcorde Jun 29, 2022
557d2b7
Added feedback
ahcorde Jun 29, 2022
ff6d575
Merge branch 'main' into ahcorde/garden/download_parallel
mjcarroll Jun 30, 2022
45c64c6
Reduce diff
ahcorde Jun 30, 2022
b9b015b
Reduce diff
ahcorde Jun 30, 2022
2ca8584
Reduce diff
ahcorde Jun 30, 2022
836cd82
Added logic to remove system plugins
ahcorde Jul 7, 2022
d0ae285
make linters happy
ahcorde Jul 7, 2022
6873c32
Merge branch 'main' into ahcorde/garden/download_parallel
mjcarroll Jul 8, 2022
29e0a8a
update method name
ahcorde Jul 8, 2022
46e707c
Merge branch 'ahcorde/garden/download_parallel' of https://github.com…
ahcorde Jul 8, 2022
0ffd80d
Merge branch 'main' into ahcorde/garden/download_parallel
ahcorde Jul 14, 2022
bdf5d18
Merge remote-tracking branch 'origin/main' into ahcorde/garden/downlo…
ahcorde Jul 18, 2022
78dd5bc
Added feedback
ahcorde Jul 18, 2022
cc16394
Merge branch 'ahcorde/garden/download_parallel' of https://github.com…
ahcorde Jul 18, 2022
a89161d
merged with gz-sim7
Aug 24, 2022
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
153 changes: 58 additions & 95 deletions examples/worlds/fuel.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -17,72 +17,35 @@
name="gz::sim::systems::SceneBroadcaster">
</plugin>

<light type="directional" name="sun">
<cast_shadows>true</cast_shadows>
<pose>0 0 10 0 0 0</pose>
<diffuse>0.8 0.8 0.8 1</diffuse>
<specular>0.2 0.2 0.2 1</specular>
<attenuation>
<range>1000</range>
<constant>0.9</constant>
<linear>0.01</linear>
<quadratic>0.001</quadratic>
</attenuation>
<direction>-0.5 0.1 -0.9</direction>
</light>
<include>
<uri>https://fuel.gazebosim.org/1.0/OpenRobotics/models/Sun</uri>
</include>

<model name="ground_plane">
<static>true</static>
<link name="link">
<collision name="collision">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>100 100</size>
</plane>
</geometry>
</collision>
<visual name="visual">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>100 100</size>
</plane>
</geometry>
<material>
<ambient>0.8 0.8 0.8 1</ambient>
<diffuse>0.8 0.8 0.8 1</diffuse>
<specular>0.8 0.8 0.8 1</specular>
</material>
</visual>
</link>
</model>
<include>
<uri>https://fuel.gazebosim.org/1.0/OpenRobotics/models/Ground Plane</uri>
</include>

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

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

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

<!-- Included actor with meshes using relative paths -->
<include>
<name>Actor Test</name>
<pose>0 0 0 0 0 0</pose>
<uri>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/actor - relative paths</uri>
<uri>https://fuel.gazebosim.org/1.0/OpenRobotics/models/actor - relative paths</uri>
</include>

<!-- Model with meshes -->
Expand All @@ -93,14 +56,14 @@
<collision name="collision">
<geometry>
<mesh>
<uri>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Radio/4/files/meshes/Radio.dae</uri>
<uri>https://fuel.gazebosim.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>
<uri>https://fuel.gazebosim.org/1.0/OpenRobotics/models/Radio/4/files/meshes/Radio.dae</uri>
</mesh>
</geometry>
</visual>
Expand All @@ -109,52 +72,52 @@

<!-- Heightmap referring to assets from another model -->
<model name="fortress_heightmap">
jennuine marked this conversation as resolved.
Show resolved Hide resolved
<static>true</static>
<link name="link">
<visual name="visual">
<geometry>
<heightmap>
<use_terrain_paging>false</use_terrain_paging>
<texture>
<diffuse>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Fortress heightmap/tip/files/materials/textures/dirt_diffusespecular.png</diffuse>
<normal>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Fortress heightmap/tip/files/materials/textures/flat_normal.png</normal>
<size>10</size>
</texture>
<texture>
<diffuse>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Fortress heightmap/tip/files/materials/textures/grass_diffusespecular.png</diffuse>
<normal>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Fortress heightmap/tip/files/materials/textures/flat_normal.png</normal>
<size>10</size>
</texture>
<texture>
<diffuse>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Fortress heightmap/tip/files/materials/textures/fungus_diffusespecular.png</diffuse>
<normal>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Fortress heightmap/tip/files/materials/textures/flat_normal.png</normal>
<size>10</size>
</texture>
<blend>
<min_height>28</min_height>
<fade_dist>6</fade_dist>
</blend>
<blend>
<min_height>35</min_height>
<fade_dist>18</fade_dist>
</blend>
<uri>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Fortress heightmap/tip/files/materials/textures/fortress_heightmap.png</uri>
<size>257 257 50</size>
<pos>0 0 -28</pos>
</heightmap>
</geometry>
</visual>
<collision name="collision">
<geometry>
<heightmap>
<uri>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Fortress heightmap/tip/files/materials/textures/fortress_heightmap.png</uri>
<size>257 257 50</size>
<pos>0 0 -28</pos>
</heightmap>
</geometry>
</collision>
</link>
</model>
<static>true</static>
<link name="link">
<visual name="visual">
<geometry>
<heightmap>
<use_terrain_paging>false</use_terrain_paging>
<texture>
<diffuse>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Fortress heightmap/tip/files/materials/textures/dirt_diffusespecular.png</diffuse>
<normal>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Fortress heightmap/tip/files/materials/textures/flat_normal.png</normal>
<size>10</size>
</texture>
<texture>
<diffuse>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Fortress heightmap/tip/files/materials/textures/grass_diffusespecular.png</diffuse>
<normal>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Fortress heightmap/tip/files/materials/textures/flat_normal.png</normal>
<size>10</size>
</texture>
<texture>
<diffuse>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Fortress heightmap/tip/files/materials/textures/fungus_diffusespecular.png</diffuse>
<normal>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Fortress heightmap/tip/files/materials/textures/flat_normal.png</normal>
<size>10</size>
</texture>
<blend>
<min_height>28</min_height>
<fade_dist>6</fade_dist>
</blend>
<blend>
<min_height>35</min_height>
<fade_dist>18</fade_dist>
</blend>
<uri>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Fortress heightmap/tip/files/materials/textures/fortress_heightmap.png</uri>
<size>257 257 50</size>
<pos>0 0 -28</pos>
</heightmap>
</geometry>
</visual>
<collision name="collision">
<geometry>
<heightmap>
<uri>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Fortress heightmap/tip/files/materials/textures/fortress_heightmap.png</uri>
<size>257 257 50</size>
<pos>0 0 -28</pos>
</heightmap>
</geometry>
</collision>
</link>
</model>

</world>
</sdf>
7 changes: 7 additions & 0 deletions include/gz/sim/Server.hh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ namespace gz
/// \brief Destructor
public: ~Server();

/// \brief Initialize server
private: void Init();

/// \brief Download models from the sdf
/// \return True if everything was fine False otherwise
private: bool DownloadModels();

/// \brief Set the update period. The update period is the wall-clock time
/// between ECS updates.
/// Note that this is different from the simulation update rate. ECS
Expand Down
19 changes: 19 additions & 0 deletions include/gz/sim/ServerConfig.hh
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,25 @@ namespace gz
/// an UpdateRate has not been set.
public: std::optional<double> UpdateRate() const;

/// \brief Set the run option
/// \param[in] _run True if the server should run on start,
/// false otherwise
public: void SetRunOption(bool _run);

/// \brief Get the run option
/// \return True if the server should run on start, false otherwise
public: bool RunOption() const;

/// \brief True if the models are downloaded in a thread false otherwise
/// \param[in] _downloadInParallel True if the models are downloaded in a
/// thread false otherwise
public: void SetDownloadInParallel(bool _downloadInParallel);

/// \brief Return True if the models are downloaded in a thread false
/// otherwise
/// \return True if the models are downloaded in a thread false otherwise
public: bool DownloadInParallel() const;

/// \brief Get whether the server is using the level system
/// \return True if the server is set to use the level system
public: bool UseLevels() const;
Expand Down
6 changes: 6 additions & 0 deletions src/LevelManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,12 @@ void LevelManager::ConfigureDefaultLevel()
this->entityCreator->SetParent(defaultLevel, this->worldEntity);
}

/////////////////////////////////////////////////
void LevelManager::AddWorld(const sdf::World *_world)
{
this->entityCreator->CreateEntities(_world);
}

/////////////////////////////////////////////////
void LevelManager::CreatePerformers()
{
Expand Down
5 changes: 4 additions & 1 deletion src/LevelManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ namespace gz
/// every update cycle
public: void UpdateLevelsState();

/// \brief This will add a world to the scene
/// \param[in] _world SDF world to add to the scene
public: void AddWorld(const sdf::World *_world);

/// \brief Load entities that have been marked for loading.
/// \param[in] _namesToLoad List of of entity names to load
private: void LoadActiveEntities(
Expand Down Expand Up @@ -184,4 +188,3 @@ namespace gz
}
// GZ_SIM_LEVELMANAGER_HH
#endif

27 changes: 21 additions & 6 deletions src/SdfEntityCreator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,28 @@ Entity SdfEntityCreator::CreateEntities(const sdf::World *_world)
{
GZ_PROFILE("SdfEntityCreator::CreateEntities(sdf::World)");

// World entity
Entity worldEntity = this->dataPtr->ecm->CreateEntity();
Entity worldEntity = kNullEntity;
this->dataPtr->ecm->Each<components::Name, components::World>(
[&](const Entity &_entity,
const components::Name *_name,
const components::World *)->bool
{
if (_world->Name() == _name->Data())
{
worldEntity = _entity;
return false;
jennuine marked this conversation as resolved.
Show resolved Hide resolved
}
return true;
});

// World components
this->dataPtr->ecm->CreateComponent(worldEntity, components::World());
this->dataPtr->ecm->CreateComponent(worldEntity,
components::Name(_world->Name()));
if (worldEntity == kNullEntity)
{
worldEntity = this->dataPtr->ecm->CreateEntity();
// World components
this->dataPtr->ecm->CreateComponent(worldEntity, components::World());
this->dataPtr->ecm->CreateComponent(worldEntity,
components::Name(_world->Name()));
}

// scene
if (_world->Scene())
Expand Down
Loading