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

Fix TPE Link velocity not being updated and Model velocity not having any effect. #289

Merged
merged 3 commits into from
Aug 31, 2021

Conversation

luca-della-vedova
Copy link
Member

@luca-della-vedova luca-della-vedova commented Aug 30, 2021

🦟 Bug fix

Summary

This PR fixes two separate issues regarding TPE:

The first one was likely introduced in the performance optimization PRs (such as #223). Velocity control of models using TPE now doesn't work anymore. To try it out compare the results of:
ign gazebo /home/luca/ws_edifice/src/ign-gazebo/examples/worlds/velocity_control.sdf --physics-engine ignition-physics-tpe-plugin
and
ign gazebo /home/luca/ws_edifice/src/ign-gazebo/examples/worlds/velocity_control.sdf
The green vehicle does not move under TPE.
My suspicion is that it is due to the fact that instead of sending all the links we now send only updated links and since the velocity is updated at the model level the links themselves are not updated.
The fix I came up with involves iterating over the models in the update step (skipping static models) and, when a model had its pose updated, add all its links to the output of Step so that Gazebo will correctly update them. This fix makes the example work again, I'm not sure about the performance overhead but hopefully because of the static check it shouldn't be too large for worlds with a lot of static objects.

The second issue has probably always been there. As part of ign-gazebo #966, I have been trying to implement velocity control using LinearVelocity and AngularVelocity components, however it seems velocity was always read as 0 in TPE.
I noticed that in KinematicsFeature velocity is updated for models. However, in the physics update step we only send link information, not model information.
As a consequence I decided to also calculate and send Link velocity information in the global frame, this fixes the ign-gazebo issue (that can be tested with the luca/linVelCmdTest in ign-gazebo), as far as TPE is concerned.

I only managed to add a test for the second issue, a simple velocity loopback that fails before the PR and succeeds afterwards, I think the test for the last issue is a bit more complex since it involves the data being passed to ign-gazebo.

Checklist

  • Signed all commits for DCO
  • Added tests
  • 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

Signed-off-by: Luca Della Vedova <luca@openrobotics.org>
Signed-off-by: Luca Della Vedova <luca@openrobotics.org>
@codecov
Copy link

codecov bot commented Aug 30, 2021

Codecov Report

Merging #289 (1f949e4) into ign-physics4 (f38120b) will increase coverage by 0.10%.
The diff coverage is 96.77%.

Impacted file tree graph

@@               Coverage Diff                @@
##           ign-physics4     #289      +/-   ##
================================================
+ Coverage         75.75%   75.86%   +0.10%     
================================================
  Files               125      125              
  Lines              5503     5531      +28     
================================================
+ Hits               4169     4196      +27     
- Misses             1334     1335       +1     
Impacted Files Coverage Δ
tpe/plugin/src/SimulationFeatures.cc 82.71% <95.83%> (+4.38%) ⬆️
tpe/plugin/src/KinematicsFeatures.cc 70.00% <100.00%> (+9.13%) ⬆️

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 f38120b...1f949e4. Read the comment docs.

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.

nice, thanks for catching this. Confirms that the vehicles now move with vel cmds. Got a comment about potential duplicate link entries and vector size.

tpe/plugin/src/SimulationFeatures.cc Show resolved Hide resolved
tpe/plugin/src/SimulationFeatures.cc Outdated Show resolved Hide resolved
Signed-off-by: Luca Della Vedova <luca@openrobotics.org>
@luca-della-vedova
Copy link
Member Author

Fixed both the comments here. I changed the variable name to prevEntityPoses and added a unordered_set containing the id of links that have already been pushed to the vector to avoid adding duplicated entries.

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.

looks good to me.

@iche033 iche033 merged commit 7960d50 into ign-physics4 Aug 31, 2021
@iche033 iche033 deleted the fix/tpe_link_velocity branch August 31, 2021 17:36
@adlarkin
Copy link
Contributor

Thanks for the fixes, @luca-della-vedova! From what I recall with my recent testing on DART, these issues did not exist on DART - I believe that they only existed with TPE. Did you by chance test these things with DART to make sure that these issues do not exist with DART? If there are no issues with DART, then I believe we can close gazebosim/gz-sim#966 once we get some feedback on gazebosim/gz-sim#966 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🏢 edifice Ignition Edifice TPE Trivial Physics Engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants