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

Schema accessor #1393

Open
wants to merge 23 commits into
base: sdf14
Choose a base branch
from
Open

Conversation

aagrawal05
Copy link

@aagrawal05 aagrawal05 commented Apr 5, 2024

🎉 New feature

Closes #1376

Summary

  1. I've created a script format_sdf.py which reads from the /sdf/1.11 folder and generates/updates the source for all the relevant classes in the src/ and include/ directories as per the suggested implementation.
  2. There were DOM elements navsat.sdf and forcetorque.sdf for which the script does not work and I had to manually edit the script because their naming convention did not match the camel-case conversion (they would need to be nav_sat.sdf and force_torque.sdf respectively to function correctly with the script) This may be undesirable from a code style perspective but may be a breaking change—this is a minor point but I just wanted to point it out.
  3. The code builds successfully, I have not thoroughly tested it but it does seem to work.
  4. I can add tests for the SchemaFile in all the DOM element tests but I thought it might be overkill because the names are hardcoded in the method anyways. I can add it easily with the script if needed.

Test it

Tests can be done manually as mentioned by the OP in #1376 in his code example.
I could also add tests in the DOM element unit tests, but that might be overkill because the values are hard-coded.

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.

@github-actions github-actions bot added the 🎵 harmonic Gazebo Harmonic label Apr 5, 2024
Copy link
Collaborator

@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.

Thanks for working on this! I have a few comments that should be easy to address.

Regarding testing, I don't think we should create new tests for this, but one way we can make sure it's working is by using SchemaFile() instead of hard coded file names in ToElement functions. Perhaps you can update your script to make that change as well?

.DS_Store Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this file

src/Actor.cc Outdated
{
static const std::string* kSchemaFile = new std::string("actor.sdf");
return *kSchemaFile;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

src/Actor.cc Outdated
Comment on lines 824 to 828
const std::string& Actor::SchemaFile()
{
static const std::string* kSchemaFile = new std::string("actor.sdf");
return *kSchemaFile;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

According to our style guide, this is sort of a last resort way to create variables with static storage. After reading through https://abseil.io/tips/140#string-view-mistake, I think the recommended way is:

Suggested change
const std::string& Actor::SchemaFile()
{
static const std::string* kSchemaFile = new std::string("actor.sdf");
return *kSchemaFile;
}
inline std::string_view Actor::SchemaFile()
{
static const char kSchemaFile[] = "actor.sdf";
return kSchemaFile;
}

@aagrawal05 aagrawal05 requested a review from azeey May 19, 2024 15:00
@azeey azeey added the beta Targeting beta release of upcoming collection label Jul 29, 2024
@azeey
Copy link
Collaborator

azeey commented Aug 6, 2024

@aagrawal05 Looks like there are some style issues and a DCO error. Mind fixing them?

@aagrawal05
Copy link
Author

@aagrawal05 Looks like there are some style issues and a DCO error. Mind fixing them?

Hey @azeey sure let me take a look. The style issues look fairly straightforward and I'll shortly submit changes to fix this. Please let me know if anything further is to be done in terms of functionality.

@aagrawal05 aagrawal05 force-pushed the schema_accessor branch 2 times, most recently from 6817d40 to 2215b16 Compare August 16, 2024 03:32
aagrawal05 and others added 19 commits August 16, 2024 11:55
Signed-off-by: Aditya Agrawal <[email protected]>
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Co-authored-by: Ian Chen <[email protected]>
The `gz sdf` tests are fixed by 
* fixing dll path issue with Ruby on windows
* Setting home path

---------

Signed-off-by: Addisu Z. Taddese <[email protected]>
* Fix trivial warning on 24.04 for JointAxis_TEST.cc

---------

Signed-off-by: Jose Luis Rivero <[email protected]>
Co-authored-by: Steve Peters <[email protected]>
* Enable 24.04 CI, remove distutils dependency (gazebosim#1408)
  distutils is no longer required since this branch requires a
 new enough version of cmake.

Signed-off-by: Steve Peters <[email protected]>
Signed-off-by: Jorge Perez <[email protected]>
Co-authored-by: Steve Peters <[email protected]>
Currently errors are generated when adding an attribute
containing an empty string to a <plugin> block or as a
custom attribute. This adds failing tests to confirm the bug
and fixes the errors in by setting `_required == 0` when
calling Element::AddAttribute. This also changes
Element::ToString to print empty custom attributes.

Fixes gazebosim#725.

Signed-off-by: Steve Peters <[email protected]>
scpeters and others added 4 commits August 16, 2024 11:57
Update test to confirm that gazebosim#54 is fixed.

Signed-off-by: Steve Peters <[email protected]>
* Backport:  Add cone shape to SDFormat spec (gazebosim#1418)

Signed-off-by: Benjamin Perseghetti <[email protected]>
Co-authored-by: Steve Peters <[email protected]>

Signed-off-by: Jose Luis Rivero <[email protected]>
Signed-off-by: Steve Peters <[email protected]>
Co-authored-by: Steve Peters <[email protected]>
Signed-off-by: Aditya Agrawal <[email protected]>
@aagrawal05
Copy link
Author

Hey @azeey in attempting to resolve the DCO error through a rebase, it appears that I have accidentally re-committed all the 23 commits from my first changes before the merge to my latest changes...

I believe it may be a bit complicated for me to proceed accurately to revert this from this point. I feel it might be easier to just close PR and create a new PR on a new branch with a single commit (this also has the added benefit of being merged with the latest changes in sdf14).

With regards to the style I believe the errors should be resolved but I need to test with the linter using the workflow.

Please let me know how to proceed.

@azeey azeey removed the beta Targeting beta release of upcoming collection label Sep 26, 2024
@azeey
Copy link
Collaborator

azeey commented Dec 19, 2024

@aagrawal05 yes, I think I new PR would be cleaner. It would be ideal if you can target sdf15 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎵 harmonic Gazebo Harmonic
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

Add schema file name accessor to each DOM type C++ class
9 participants