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

Specify System::PreUpdate, Update execution order #2487

Merged
merged 7 commits into from
Aug 1, 2024

Conversation

scpeters
Copy link
Member

🎉 New feature

Part of #2268 and #2391, second attempt at #2394

Summary

While the PreUpdate, Update, and PostUpdate phases of gz-sim systems allow some control over the order in which code is executed, there are cases in which more control is desired. For example, as noted in #2268 and #2391, sensor systems currently update their data during PostUpdate (after the Update step of the physics system) but can't write their data to the ECM since PostUpdate has read-only access to the ECM. Moving sensor updates to Update would allow writing to the ECM, but would require ensuring that the sensor systems execute their Update step after the physics Update. Alternatively, if one wanted to implement a hierarchical cascade of systems acting on data sequentially, rather than adding PrePreUpdate and PrePrePreUpdate phases, one could specify the system priority during PreUpdate for the relevant systems instead.

This feature is used by specifying an integer value in a <gz:system_priority> tag for a system that will control the order in which System PreUpdate and Update callbacks are executed, with smaller priority values executing first.

Test it

Follow the README instructions to build and run the PriorityPrinter example plugin to illustrate the feature.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Specifying an integer value in a <gz:system_priority> tag
for a system will control the order in which System PreUpdate
and Update callbacks are executed, with lower values executing
first.

The PriorityPrinter example plugin is added to illustrate
the feature.

Signed-off-by: Steve Peters <[email protected]>
@scpeters scpeters requested a review from mjcarroll as a code owner July 20, 2024 00:11
@github-actions github-actions bot added the 🏛️ ionic Gazebo Ionic label Jul 20, 2024
Copy link
Contributor

@iche033 iche033 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested running example world and works as intended. Just a few minor comments.

examples/plugin/priority_printer_plugin/README.md Outdated Show resolved Hide resolved
[Msg] Update: Iteration 5, system priority 10, system label second
[Msg] Update: Iteration 5, system priority 100, system label first
[Msg] Update: Iteration 5, system priority 100, system label seventh
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe how priority numbers work, i.e. the lower the number the higher the priority? and also unset means default priority of 0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I'll add this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I improved the description in d4b161b

examples/plugin/priority_printer_plugin/README.md Outdated Show resolved Hide resolved
Signed-off-by: Steve Peters <[email protected]>
@azeey azeey added the beta Targeting beta release of upcoming collection label Jul 29, 2024
@scpeters scpeters merged commit 4499157 into main Aug 1, 2024
8 of 9 checks passed
@scpeters scpeters deleted the scpeters/system_execution_order_ionic branch August 1, 2024 21:05
scpeters added a commit that referenced this pull request Aug 19, 2024
Specifying an integer value in a <gz:system_priority> tag
for a system will control the order in which System PreUpdate
and Update callbacks are executed, with lower values executing
first.

The PriorityPrinter example plugin is added to illustrate
the feature.

Signed-off-by: Steve Peters <[email protected]>
scpeters added a commit that referenced this pull request Aug 19, 2024
Specifying an integer value in a <gz:system_priority> tag
for a system will control the order in which System PreUpdate
and Update callbacks are executed, with lower values executing
first.

The PriorityPrinter example plugin is added to illustrate
the feature.

Signed-off-by: Steve Peters <[email protected]>
scpeters added a commit that referenced this pull request Aug 20, 2024
Specifying an integer value in a <gz:system_priority> tag
for a system will control the order in which System PreUpdate
and Update callbacks are executed, with lower values executing
first.

The PriorityPrinter example plugin is added to illustrate
the feature.

Signed-off-by: Steve Peters <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Targeting beta release of upcoming collection 🏛️ ionic Gazebo Ionic
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants