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

write modified link data to output in physics step #223

Merged
merged 12 commits into from
Mar 23, 2021

Conversation

adlarkin
Copy link
Contributor

@adlarkin adlarkin commented Mar 10, 2021

Signed-off-by: Ashton Larkin ashton@openrobotics.org

🎉 New feature

Requires gazebosim/gz-math#196

Possible solution for #219

Summary

As mentioned in #219, downstream libraries that use ign-physics (like ign-gazebo) don't have a way of knowing which links moved in the most recent physics step. This PR takes advantage of a forward step's output by writing changed link poses to the output. The output can then be used by downstream libraries to only operate on modified links (take a look at gazebosim/gz-sim#678 for an example).

Test it

Take a look at the tests added in this PR (files changed tab -> tpe/plugin/src/SimulationFeatures_TEST.cc or dartsim/src/SimulationFeatures_TEST.cc) to see how the modified pose data can be accessed from ignition::physics::ForwardStep::Output.

To get an understanding of how this change can be used/tested in downstream libraries, take a look at gazebosim/gz-sim#678.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • 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

@codecov
Copy link

codecov bot commented Mar 10, 2021

Codecov Report

Merging #223 (3cd0d7b) into main (109de85) will increase coverage by 0.14%.
The diff coverage is 97.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #223      +/-   ##
==========================================
+ Coverage   82.85%   83.00%   +0.14%     
==========================================
  Files         107      107              
  Lines        4119     4159      +40     
==========================================
+ Hits         3413     3452      +39     
- Misses        706      707       +1     
Impacted Files Coverage Δ
tpe/plugin/src/SimulationFeatures.cc 78.33% <95.00%> (+8.33%) ⬆️
dartsim/src/SimulationFeatures.cc 91.22% <100.00%> (+4.74%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 109de85...3cd0d7b. Read the comment docs.

@chapulina chapulina added enhancement New feature or request performance Runtime performance labels Mar 10, 2021
@adlarkin adlarkin added the needs upstream release Blocked by a release of an upstream library label Mar 10, 2021
Copy link
Contributor Author

@adlarkin adlarkin left a comment

Choose a reason for hiding this comment

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

@azeey the implementation is working, but I have a few questions. Would you mind taking a look at the code and addressing my comments below?

dartsim/src/SimulationFeatures.cc Outdated Show resolved Hide resolved
dartsim/src/SimulationFeatures.cc Outdated Show resolved Hide resolved
dartsim/src/SimulationFeatures.cc Outdated Show resolved Hide resolved
dartsim/src/SimulationFeatures.cc Outdated Show resolved Hide resolved
tpe/plugin/src/SimulationFeatures.cc Outdated Show resolved Hide resolved
tpe/plugin/src/SimulationFeatures.cc Outdated Show resolved Hide resolved
tpe/plugin/src/SimulationFeatures.cc Outdated Show resolved Hide resolved
@adlarkin adlarkin requested a review from azeey March 11, 2021 17:54
@adlarkin adlarkin self-assigned this Mar 11, 2021
@adlarkin adlarkin force-pushed the adlarkin/write_step_output_data branch from a9b33c9 to f80f687 Compare March 12, 2021 21:18
@adlarkin adlarkin changed the base branch from ign-physics3 to main March 15, 2021 17:25
@adlarkin adlarkin force-pushed the adlarkin/write_step_output_data branch from f80f687 to e4dea17 Compare March 15, 2021 17:28
@adlarkin adlarkin changed the base branch from main to ign-physics3 March 15, 2021 19:04
@adlarkin adlarkin changed the base branch from ign-physics3 to main March 15, 2021 19:08
Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
@adlarkin adlarkin force-pushed the adlarkin/write_step_output_data branch from e4dea17 to f2febb1 Compare March 15, 2021 19:27
Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
@adlarkin
Copy link
Contributor Author

adlarkin commented Mar 16, 2021

This is now ready for review. I have updated this PR to target Edifice (main branch) based on the discussion that was had in gazebosim/gz-sim#678.

We'll need to make a minor release for ign-math6 so that gazebosim/gz-math#196 can be used.

@adlarkin adlarkin marked this pull request as ready for review March 16, 2021 17:23
@adlarkin adlarkin requested a review from mxgrey as a code owner March 16, 2021 17:23
_poses.entries.push_back(wp);
}

prevLinkPoses[id] = wp.pose;
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need to keep this map up-to-date when links are removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, thanks for catching this. I believe I have handled this in 84b9f4e. Let me know what you think.

dartsim/src/SimulationFeatures.cc Outdated Show resolved Hide resolved
tpe/plugin/src/SimulationFeatures.cc Outdated Show resolved Hide resolved
Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
@chapulina chapulina added beta Targeting beta release of upcoming collection 🏢 edifice Ignition Edifice and removed 🔮 dome Ignition Dome labels Mar 18, 2021
Copy link
Contributor

@azeey azeey left a comment

Choose a reason for hiding this comment

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

Looks pretty good! I left some minor comments.

dartsim/src/SimulationFeatures.cc Outdated Show resolved Hide resolved
dartsim/src/SimulationFeatures.cc Outdated Show resolved Hide resolved
dartsim/src/SimulationFeatures.cc Outdated Show resolved Hide resolved
dartsim/src/SimulationFeatures.cc Show resolved Hide resolved
dartsim/src/SimulationFeatures.cc Outdated Show resolved Hide resolved
_poses.entries.push_back(wp);
}

newPoses[id] = wp.pose;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be inside the if block since it's supposed to be collecting new poses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason why I left this outside of the if block is because of floating point precision. My thought was that I should save the most recent pose in newPoses no matter what each time, since there's a small tolerance (1e-6) in the pose equality check. Since newPoses is used as prevLinkPoses the next time around, this ensures that we are comparing the newest link pose to the actual previous pose, instead of to a pose that is very close to the previous pose. Does that make sense? If you think that leaving this outside of the if block is okay, I can add a comment there that mentions what I just described to you. Otherwise, I can move this to be inside of the if block.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would think you'd want to compare it to the last pose sent to the user though because you want to err on the side of sending too much to the user (eg. ign-gazebo). Consider, for example, if each successive time the pose changes by +1e-7, since you always compare against the previous actual pose, it will always look like there no new pose to send to the user. Over time, this could cause a significant amount of drift.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're definitely correct. I believe that this should now be fixed in 494f6c5

dartsim/src/SimulationFeatures.cc Outdated Show resolved Hide resolved
adlarkin and others added 3 commits March 19, 2021 14:58
Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
@adlarkin
Copy link
Contributor Author

All review feedback has been addressed, so I am opening this for another round of review.

@adlarkin adlarkin requested review from iche033 and azeey March 22, 2021 16:22
@chapulina chapulina mentioned this pull request Mar 22, 2021
7 tasks
@azeey
Copy link
Contributor

azeey commented Mar 22, 2021

@osrf-jenkins run tests please

@adlarkin adlarkin removed the needs upstream release Blocked by a release of an upstream library label Mar 22, 2021
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 🏢 edifice Ignition Edifice enhancement New feature or request performance Runtime performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants