-
Notifications
You must be signed in to change notification settings - Fork 277
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
iterate through changed links only in UpdateSim #678
Conversation
ba6fc7f
to
bebb175
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At a high level, my main concern is that this changes the requirement on the ign-physics plugin such that the ForwardStep::World::Step
function now has to return the world poses. We have been trying not to require features in a released version and this feels like we're breaking that. I'd like to hear @chapulina's thoughts on this.
A possible workaround to maintain backward compatibility would be to populate stepOutput
in ign-gazebo if the return of ForwardStep::World::Step
doesn't contain any world poses.
+1, we should be mindful of not introducing new required APIs that may break existing 3rd party physics engines.
That sounds like a good idea. Another thing to consider is working on this feature on top of Edifice so that we're free to change requirements and implement the feature in the ideal way. Once that's settled, we can think of how to backport it. |
Thanks for the comments, @azeey and @chapulina. I am going to update this PR and gazebosim/gz-physics#223 to target Edifice, and then we can determine the next best steps. |
4942e42
to
2e844bf
Compare
2e844bf
to
9a3aaa8
Compare
This is now ready for review, and targets Edifice ( As I mentioned in the PR description, this change eliminates the need for #669, which is something to keep in mind when we make the next forward-port. We'll need to make a minor release for |
I just updated this branch to include the changes in #695, and resolved conflicts to use the changes in this PR instead of the changes in #669: 1074b5a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@osrf-jenkins run tests please |
I'm making one last change that will make this new physics output optional (if poses aren't a part of |
Conflicts have been resolved in dca0f66, but it looks like there's a new test failure that I need to resolve ( @azeey, I had to make a few changes to the physics system when resolving merge conflicts in order to support the work you did in #685. The main difference that was made was including a To give more insight into the benefits of 2571923, here are the profiler results before this commit using the same testing methodology described in the PR description (static models world with TPE). As we can see, the After applying the changes made in 2571923, the It's interesting to see how much faster the Testing the optional behavior To revert to the old behavior of using the diff --git a/dartsim/src/SimulationFeatures.cc b/dartsim/src/SimulationFeatures.cc
index 2c4ef89..e7aa863 100644
--- a/dartsim/src/SimulationFeatures.cc
+++ b/dartsim/src/SimulationFeatures.cc
@@ -59,7 +59,7 @@ void SimulationFeatures::WorldForwardStep(
// TODO(MXG): Parse input
world->step();
- this->Write(_h.Get<ChangedWorldPoses>());
+ //this->Write(_h.Get<ChangedWorldPoses>());
// TODO(MXG): Fill in state
}
diff --git a/tpe/plugin/src/SimulationFeatures.cc b/tpe/plugin/src/SimulationFeatures.cc
index 30db7b4..10992c3 100644
--- a/tpe/plugin/src/SimulationFeatures.cc
+++ b/tpe/plugin/src/SimulationFeatures.cc
@@ -62,7 +62,7 @@ void SimulationFeatures::WorldForwardStep(
}
}
world->Step();
- this->Write(_h.Get<ChangedWorldPoses>());
+ //this->Write(_h.Get<ChangedWorldPoses>());
} You can also add some print statements inside the |
Removing from beta, this can come in a minor release. |
8c9da97
to
4f44bfc
Compare
I fixed the failure in 4f44bfc. The issue was that since we are now only updating the simulation if a pose change greater than
I increased the amount of wind force applied so that the object has a higher velocity, which results in more frequent physics updates after the wind force is no longer applied. This ensures that we don't see any velocity jumps after applying the wind force in the |
I have addressed all review feedback and updated this PR with the latest updates from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!!
Codecov Report
@@ Coverage Diff @@
## ign-gazebo5 #678 +/- ##
==============================================
Coverage ? 65.32%
==============================================
Files ? 240
Lines ? 17624
Branches ? 0
==============================================
Hits ? 11513
Misses ? 6111
Partials ? 0 Continue to review full report at Codecov.
|
Now that Edifice has been released, should I change the base branch to |
Signed-off-by: Ashton Larkin <[email protected]>
2c24f9d
to
0b61cb1
Compare
Signed-off-by: Ashton Larkin <[email protected]>
0b61cb1
to
1924de9
Compare
* 🎈 3.8.0 (#688) Signed-off-by: Louise Poubel <[email protected]> * Make it so joint state publisher is quieter (#696) Signed-off-by: Michael Carroll <[email protected]> * [BULLET] Making GetContactsFromLastStepFeature optional in Collision Features (#690) * GetContactsFromLastStepFeature made optional Signed-off-by: Tomas Lorente <[email protected]> Co-authored-by: Addisu Z. Taddese <[email protected]> * Add test for thermal object temperatures below 0 kelvin (#621) Signed-off-by: Ashton Larkin <[email protected]> * Scenebroadcaster sensors (#698) * Add sensors to scene broadcaster Signed-off-by: Nate Koenig <[email protected]> * Update src/systems/scene_broadcaster/SceneBroadcaster.cc Co-authored-by: Michael Carroll <[email protected]> * Fix codecheck Signed-off-by: Nate Koenig <[email protected]> Co-authored-by: Nate Koenig <[email protected]> Co-authored-by: Michael Carroll <[email protected]> * Fix diffuse and ambient values for ackermann example (#707) Signed-off-by: Ammaar Solkar <[email protected]> * 🎈 5.0.0 (#731) Signed-off-by: Louise Poubel <[email protected]> * Support configuring particle scatter ratio in particle emitter system (#674) * set particle scatter ratio through sdf Signed-off-by: Ian Chen <[email protected]> * address feedback Signed-off-by: Ian Chen <[email protected]> * add todo note about merging forward Signed-off-by: Ian Chen <[email protected]> Co-authored-by: Ashton Larkin <[email protected]> * Update PlaybackScrubber description (#733) Signed-off-by: Ammaar Solkar <[email protected]> * Iterate through changed links only in UpdateSim (#678) Signed-off-by: Ashton Larkin <[email protected]> * Do not pass -Wno-unused-parameter to MSVC compiler (#716) Signed-off-by: Silvio Traversaro <[email protected]> * Use Protobuf_IMPORT_DIRS instead of PROTOBUF_IMPORT_DIRS for compatibility with Protobuf CMake config (#715) Signed-off-by: Silvio Traversaro <[email protected]> * Fix component inspector shutdown crash (#724) Signed-off-by: Louise Poubel <[email protected]> Co-authored-by: Alejandro Hernández Cordero <[email protected]> * Validate step size and RTF parameters (#740) Only set them if they are strictly positive. Signed-off-by: Luca Della Vedova <[email protected]> * Fix compute_rtfs arguments (#737) Signed-off-by: Caio Amaral <[email protected]> * Fixed collision visual bounding boxes (#746) Signed-off-by: Jenn Nguyen <[email protected]> * Fix CMakelists.txt merge Signed-off-by: Nate Koenig <[email protected]> * ECM's ChangedState gets message with modified components (#742) * ecm's ChangedState to contain modified components Signed-off-by: Jenn Nguyen <[email protected]> * updated log_system test Signed-off-by: Jenn Nguyen <[email protected]> * removed unnecessary calls Signed-off-by: Jenn Nguyen <[email protected]> Co-authored-by: Ian Chen <[email protected]> * fixed particle emitter forward playback (#745) Signed-off-by: Jenn Nguyen <[email protected]> * Merge pull request #730 from ignitionrobotics/particle_emitter Particle emitter based on SDF * 4 7 0 prep (#755) * Prepare for 4.7.0 Signed-off-by: Nate Koenig <[email protected]> * Added placeholder Signed-off-by: Nate Koenig <[email protected]> Co-authored-by: Nate Koenig <[email protected]> * Fix 'invalid animation update data' msg for actors (#754) Signed-off-by: Ashton Larkin <[email protected]> * Update benchmark comparison instructions (#766) (#766) Signed-off-by: Ashton Larkin <[email protected]> * [DiffDrive] add enable/disable (#772) * add enable/disable diffdrive Signed-off-by: Guillaume Doisy <[email protected]> * remove debug Signed-off-by: Guillaume Doisy <[email protected]> * do not subscribe to enable if topic is empty Signed-off-by: Guillaume Doisy <[email protected]> * add test Signed-off-by: Guillaume Doisy <[email protected]> * lint and style Signed-off-by: Guillaume Doisy <[email protected]> * change enable type to bool and renamed to enabled Signed-off-by: Guillaume Doisy <[email protected]> * Add odometry publisher system (#547) * Create Initial Odometry Publisher system plugin Add code for initial plugin that gets position from Pose component and calculates velocities based on rolling mean from displacement data. Signed-off-by: Maganty Rushyendra <[email protected]> * Remove Linear and Angular Velocity components Also renames frames in Odometry msg to include model name, and makes various style changes. Signed-off-by: Maganty Rushyendra <[email protected]> * Get World pose instead of pose of robot base frame Signed-off-by: Maganty Rushyendra <[email protected]> * Add documentation for variables and functions Includes minor stylistic changes. Signed-off-by: Maganty Rushyendra <[email protected]> * Check for valid odomTopic and update copyright year Signed-off-by: Maganty Rushyendra <[email protected]> * Add tests for OdometryPublisherSystem and fix velocity calculation bug Swap X and Y linear velocities when calculating odometry velocities relative to robotBaseFrame. Signed-off-by: Maganty Rushyendra <[email protected]> Co-authored-by: ahcorde <[email protected]> * Patch particle emitter2 service (#777) * Patch particle emitter2 service Signed-off-by: Nate Koenig <[email protected]> * Remove condition variable Signed-off-by: Nate Koenig <[email protected]> * Set emitter frame and relative pose Signed-off-by: Nate Koenig <[email protected]> Co-authored-by: Nate Koenig <[email protected]> * Preparing for 4.8.0 release (#780) Signed-off-by: Nate Koenig <[email protected]> Co-authored-by: Nate Koenig <[email protected]> * 👩🌾 Enable Focal CI (#646) Signed-off-by: Louise Poubel <[email protected]> Co-authored-by: Michael Carroll <[email protected]> * [TPE] Support setting individual link velocity (#427) Signed-off-by: claireyywang <[email protected]> Signed-off-by: Ian Chen <[email protected]> Co-authored-by: Ian Chen <[email protected]> Co-authored-by: Louise Poubel <[email protected]> * Don't store duplicate ComponentTypeId in ECM (#751) Signed-off-by: Louise Poubel <[email protected]> * Feature/hydrodynamics (#749) Implement hydrodynamics and thruster plugin. Signed-off-by: Arjo Chakravarty <[email protected]> Co-authored-by: Mabel Zhang <[email protected]> Co-authored-by: Carlos Agüero <[email protected]> * Fix macOS build: components::Name in benchmark (#784) Signed-off-by: Louise Poubel <[email protected]> Co-authored-by: Steve Peters <[email protected]> * Fix ColladaExporter submesh index bug (#763) Signed-off-by: Jorge Perez <[email protected]> * 👩🌾 Fix Windows build and some warnings (#782) Signed-off-by: Louise Poubel <[email protected]> Co-authored-by: Alejandro Hernández Cordero <[email protected]> * Prevent crash on Plotting plugin with mutex (#747) Signed-off-by: Louise Poubel <[email protected]> * Bump ign-physics version to 3.2 (#792) Signed-off-by: Louise Poubel <[email protected]> * Bump to ign-msgs 7.1 / sdformat 11.1, Windows fixes (#758) Signed-off-by: Louise Poubel <[email protected]> * Util: Use public API from libsdformat for detecting non-file source (#794) Signed-off-by: Eric Cousineau <[email protected]> * Fix included nested model expansion in SDF generation (#768) * fixed included nested model expansion Signed-off-by: Jenn Nguyen <[email protected]> * added resource path to test Signed-off-by: Jenn Nguyen <[email protected]> * use orig URIs & support multi level nesting Signed-off-by: Jenn Nguyen <[email protected]> * save fuel version when enabled Signed-off-by: Jenn Nguyen <[email protected]> * retrieve uri from map Signed-off-by: Jenn Nguyen <[email protected]> * copy included element Signed-off-by: Jenn Nguyen <[email protected]> * clear attributes before copying include element Signed-off-by: Jenn Nguyen <[email protected]> * Map canonical links to their models (#736) Signed-off-by: Ashton Larkin <[email protected]> * ColladaExporter, export submesh selected (#802) * Export only submesh if selected * Add test case for the PR * Attempting a unified solution Signed-off-by: Jorge Perez <[email protected]> Co-authored-by: Nate Koenig <[email protected]> Co-authored-by: Michael Carroll <[email protected]> Co-authored-by: Jose Tomas Lorente <[email protected]> Co-authored-by: Addisu Z. Taddese <[email protected]> Co-authored-by: Ashton Larkin <[email protected]> Co-authored-by: Nate Koenig <[email protected]> Co-authored-by: Nate Koenig <[email protected]> Co-authored-by: Ammaar Solkar <[email protected]> Co-authored-by: Ian Chen <[email protected]> Co-authored-by: Ashton Larkin <[email protected]> Co-authored-by: Silvio Traversaro <[email protected]> Co-authored-by: Alejandro Hernández Cordero <[email protected]> Co-authored-by: Luca Della Vedova <[email protected]> Co-authored-by: Caio Amaral <[email protected]> Co-authored-by: Jenn Nguyen <[email protected]> Co-authored-by: G.Doisy <[email protected]> Co-authored-by: Rushyendra Maganty <[email protected]> Co-authored-by: Claire Wang <[email protected]> Co-authored-by: Arjo Chakravarty <[email protected]> Co-authored-by: Mabel Zhang <[email protected]> Co-authored-by: Carlos Agüero <[email protected]> Co-authored-by: Steve Peters <[email protected]> Co-authored-by: Jorge Perez <[email protected]> Co-authored-by: Eric Cousineau <[email protected]> Co-authored-by: Jorge Perez <[email protected]>
Signed-off-by: Ashton Larkin [email protected]
🎉 New feature
requires:
related to gazebosim/gz-physics#219
Summary
As mentioned in gazebosim/gz-physics#219,
UpdateSim
in theign-gazebo
physics system iterates over all links, because it has no way of knowing which links have moved. gazebosim/gz-physics#223 and gazebosim/gz-physics#238 should resolve this issue, so this PR uses each of theseign-physics
PRs (and gazebosim/gz-math#196) to haveUpdateSim
iterate over just the links that have moved.As a result of this change, the link pose caching that was done in #669 is no longer needed if a physics engine is being used that writes output pose data (we still need the caching done in #656 regardless of whether the physics engine being used writes output pose data or not). I also had to add some functionality to the
EntityFeatureMap
class (introduced in #586) that maps physics link entity IDs (std::size_t
) to the corresponding entity inign-gazebo
(the link data thatign-gazebo
gets fromign-physics
contains a link's pose and link ID).This new behavior is optional. In other words, if a physics engine is being used that writes output pose data, then the output pose data will be used to update the simulation state. If a physics engine is being used that does not write output pose data, then the approach for updating the simulation state remains unchanged (getting all link poses from the latest step via
ECM
).Test it
Testing this PR can follow the testing approach taken in #656 and #669, which involves profiling a world as follows:
Profiling the world above can be done with both DART and TPE physics engines. In the comparisons below, the metrics being compared to (i.e., before this PR) are being done on commit 2bf29c2 of
ign-gazebo
, and commit gazebosim/gz-physics@54d2a44 ofign-physics
.TPE
Static
Before this PR:
UpdateSim
time: 3msAfter this PR:
UpdateSim
time: 0.67msNon-Static
Before this PR:
UpdateSim
time: 13.6msAfter this PR:
UpdateSim
time: 0.8msDART
Static
Before this PR:
UpdateSim
time: 4.1msAfter this PR:
UpdateSim
time: 1.1msNon-Static
Before this PR:
UpdateSim
time: 15.6msAfter this PR:
UpdateSim
time: 2.8msTakeaways
The TPE performance improvement is noticeable (2x RTF increase for static shapes, and 3x RTF increase for non-static shapes). The performance improvement for DART is not as noticeable (1.5x RTF increase for static shapes, and no real change in RTF for non-static shapes), probably because
UpdateSim
is a small part of theUpdate
in the physics system - for DART, most of the work in the physics systemUpdate
comes from the physics step itself, which we probably don't have a ton of control over when it comes to optimization.Future Work
Although there are noticeable performance improvements here, there are a few things that I'd like to do next to create even more performance improvements:
UpdateSim
is taken up byModels
, which is a loop that updates model poses if necessary. Since we now only have the links that have changed after each physics step, it would be nice to make a bi-directional mapping between models and their canonical links (currently, we only have a mapping from a model to its canonical link - see Support individual canonical links for nested models #685). That way, we can loop through all of the changed links and update the models that have this link as its canonical link instead of looping through all of the models and seeing if a model's canonical link has changed pose. I believe that this would decrease theModel
block time significantly.EntityComponentManager::Each
call. As I mentioned in iterate through changed links only in UpdateSim #678 (comment), reducing the number of components used in theecm.Each
call sped up the time for theecm.Each
call to complete by approximately 3x (wow!). Considering how often we useecm.Each
inign-gazebo
, I imagine that optimizing this function call would result in a massive performance benefit. I have created an issue for this so that it can be tracked: Improve the performance of EntityComponentManager::Each #711Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge