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 parsing 'type' attibutes in plugins #809

Merged
merged 5 commits into from
Jan 3, 2022
Merged

Conversation

chapulina
Copy link
Contributor

@chapulina chapulina commented Dec 30, 2021

🦟 Bug fix

Summary

The logic added to check for the type attribute has broken use-cases inside ign-gazebo, such as this:

    <plugin filename="ignition-gazebo-triggered-publisher-system" name="ignition::gazebo::systems::TriggeredPublisher">
      <input type="ignition.msgs.Empty" topic="/in_1"/>
      <output type="ignition.msgs.Boolean" topic="/out_1">
          data: true
      </output>
    </plugin>

Which now causes an assertion:

173: Error [Param.cc:768] Unknown parameter type[ignition.msgs.Boolean]
173: Exception [Param.cc:81] SDF ASSERTION                     
173: Invalid parameter
173: In function       : Param
173: Assert expression : this->dataPtr->ValueFromStringImpl( this->dataPtr->typeName, _default, this->dataPtr->defaultValue)

My assumption from #689 is that we only want to parse the /pose@type attributes here, but don't affect the rest, so I added the extra check for "pose". I left a TODO there because I think we should remove the special type handling from that function to a pose-specific function.

I suspect I may be missing some important detail, but tests pass. So I hope this is enough as a band-aid to fix the regression, and I'd like to check with @aaronchongth and @azeey when they're back on making a proper fix.

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 and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸

@chapulina chapulina requested a review from scpeters December 30, 2021 18:26
@github-actions github-actions bot added 🌱 garden Ignition Garden 🏯 fortress Ignition Fortress labels Dec 30, 2021
chapulina added a commit to gazebosim/gz-sim that referenced this pull request Dec 30, 2021
Signed-off-by: Louise Poubel <[email protected]>
Signed-off-by: Louise Poubel <[email protected]>
@@ -186,7 +186,7 @@ TEST(DOMPlugin, LoadWithChildren)
std::string pluginStr = R"(<plugin name='3D View' filename='MinimalScene'>
<ignition-gui>
<title>3D View</title>
<property type='bool' key='showTitleBar'>false</property>
Copy link
Member

Choose a reason for hiding this comment

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

I think the problem is related to unrecognized type values, like ignition.msgs.Boolean in triggered_publisher.sdf

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was just fixing the test failure. With my change, the parser is now converting false into 0.

I haven't touched the parser much before, so I'd appreciate some guidance on the proper fix. My assumption from #689 is that we only want to parse the /pose@type attributes here, but don't affect the rest, that's why I added the extra check for "pose" with a TODO to remove the special type handling from that function to a pose-specific function. But I suspect I may be missing some important detail.

@chapulina chapulina marked this pull request as ready for review December 30, 2021 19:23
@chapulina chapulina requested a review from azeey as a code owner December 30, 2021 19:23
@codecov-commenter
Copy link

codecov-commenter commented Dec 30, 2021

Codecov Report

Merging #809 (27fc0a4) into sdf12 (8785b7a) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            sdf12     #809      +/-   ##
==========================================
- Coverage   90.70%   90.70%   -0.01%     
==========================================
  Files          78       78              
  Lines       12437    12432       -5     
==========================================
- Hits        11281    11276       -5     
  Misses       1156     1156              
Impacted Files Coverage Δ
src/Param.cc 91.29% <100.00%> (+0.01%) ⬆️
src/parser.cc 87.48% <100.00%> (-0.07%) ⬇️

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 8785b7a...27fc0a4. Read the comment docs.

@chapulina
Copy link
Contributor Author

All tests are passing here, so I'm opening this for review. I updated the PR description with more context.

@chapulina
Copy link
Contributor Author

@chapulina chapulina removed the 🌱 garden Ignition Garden label Dec 30, 2021
@scpeters
Copy link
Member

I've added a line in 5fc1571 that reproduces the failure seen in ign-gazebo, caused by an unrecognized type attribute

@scpeters
Copy link
Member

I'd like to see what @aaronchongth thinks about this change

@chapulina
Copy link
Contributor Author

chapulina commented Dec 30, 2021

I've added a line in 5fc1571 that reproduces the failure seen in ign-gazebo, caused by an unrecognized type attribute

It failed similar to the other line:

-    <property type='Ignition.Msgs.Boolean'>false</property>
+    <property type='Ignition.Msgs.Boolean'>0</property>

I'd like to see what @aaronchongth thinks about this change

My intention here is to revert the regression without reverting #689 completely. I don't think this is the final fix, and I hope the original authors come back with a cleaner fix later. I'd just like to fix the broken use cases on ign-gazebo for from-source Fortress users and source/nightly Garden users asap.

Are you concerned we may be breaking something else with this, @scpeters ?

@aaronchongth
Copy link
Collaborator

aaronchongth commented Dec 31, 2021

Hi @chapulina, @scpeters! Thanks for raising this so quickly. My bad for assuming that all the types will still be consistent with what sdformat12 is used to, I guess I didn't quite understand what "custom" means 🤦

The changes to parser.cc in #689, especially checking for the type attribute, was added specifically for this scenario in Plugin_TEST.cc. So there should not be any worry regarding breaking other behaviors within sdformat12.

I have a fix ready #811, let me know what you think. I haven't managed to run this fix against ign-gazebo6 yet as it builds pretty slowly on my available laptop, but I should get some results in a few hours when it's done.

* Reverted changes to parser for custom element with attribute 'type',
  added fix in ParamPrivate::ValueFromStringImpl instead

Signed-off-by: Aaron Chong <[email protected]>
@scpeters scpeters merged commit 6404afd into sdf12 Jan 3, 2022
@scpeters scpeters deleted the chapulina/12/plugin_type branch January 3, 2022 08:51
@osrf-triage
Copy link

This pull request has been mentioned on Gazebo Community. There might be relevant details there:

https://community.gazebosim.org/t/new-ignition-releases-2022-04-13-fortress-edifice/1367/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏯 fortress Ignition Fortress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants