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

sdformat: Should ensure filename / lineno is included in diagnostic mechanism #17053

Closed
EricCousineau-TRI opened this issue Apr 27, 2022 · 9 comments
Assignees
Labels
component: multibody parsing Loading models into MultibodyPlant priority: medium

Comments

@EricCousineau-TRI
Copy link
Contributor

Context: #16784 (comment)

FYI @azeey - you think this is something we can do in next ~month? (hopefully low-hanging fruit)

@jwnimmer-tri
Copy link
Collaborator

FYI in Drake's URDF parser, we have a sugar class to assist with reporting line numbers: detail_tinyxml2_diagnostic.h.

\CC @rpoyner-tri for any other thoughts

@rpoyner-tri
Copy link
Contributor

Having not actually re-read all of the sdformat parser code, I suspect we can do something very similar, or even extend/rework some of the existing urdf solution.

@sammy-tri
Copy link
Contributor

@azeey
Copy link
Contributor

azeey commented Apr 28, 2022

@EricCousineau-TRI , yes, we can queue this up, unless @sammy-tri's work resolves this.

@sammy-tri
Copy link
Contributor

I certainly don't mind working on it while I'm in there adding the other diagnostic stuff. Feel free to reassign to me.

@jwnimmer-tri jwnimmer-tri added component: multibody parsing Loading models into MultibodyPlant and removed component: multibody plant MultibodyPlant and supporting code unused team: manipulation labels May 2, 2022
@EricCousineau-TRI EricCousineau-TRI assigned azeey and unassigned sammy-tri Oct 20, 2022
@EricCousineau-TRI
Copy link
Contributor Author

EricCousineau-TRI commented Oct 20, 2022

@marcoag said he has this en queue, assigning @azeey as proxy. Thanks!

@marcoag Can you comment on this issue so we can assign you?

@marcoag
Copy link
Contributor

marcoag commented Nov 17, 2022

Sorry missed the ping.

This issue might benefit on the completion of gazebosim/sdformat#820.

Adding some examples on the current status of the SDF side so we can further discuss:

  • Some error/warnings produced at the detail_sdf_parser.cc level do not include filename/lineno. I.e. this python code. It throws:

error: An axis must be specified for joint 'slider'

ERROR:drake:SDFormat Error [Param.cc:404] Unknown error. Unable to set value ['' ] for key[xyz]
Traceback (most recent call last):
  File "filename_lineno_diagnostic_test.py", line 34, in <module>
    sys.exit(main())
  File "filename_lineno_diagnostic_test.py", line 31, in main
    parser.AddModelFromString(notknownelement, 'sdf');
RuntimeError: <data-string>:10: error: At XML path /sdf/model[@name="robot2"]/joint[@name="slider"]/axis/xyz: Error reading element <xyz>
ERROR:drake:SDFormat Error [parser.cc:834] Error parsing XML from string: Error=XML_ERROR_EMPTY_DOCUMENT ErrorID=15 (0xf) Line number=0
Traceback (most recent call last):
  File "filename_lineno_diagnostic_test.py", line 19, in <module>
    sys.exit(main())
  File "filename_lineno_diagnostic_test.py", line 16, in main
    parser.AddModelFromString(notknownelement, 'sdf');
RuntimeError: error: Unable to read SDF string: 

RuntimeError: error: Joint type of nontknowntype is invalid. Refer to the SDF documentation for a list of valid joint types

I'm a bit unsure of the scope of the issue is it to ensure that if a filename/lineno is reported then it's included in the diagnostic mechanism? is it to make sure SDFormat always reports filename/lineno? do we also want it from the errors at the detail_sdf_parser.cc level?

@azeey azeey assigned marcoag and unassigned azeey Nov 28, 2022
@EricCousineau-TRI
Copy link
Contributor Author

FTR, just reflecting VC:
Yeah, it would be nice to root-cause why the two XML-valid but SDFormat-invalid wrong things fail (bad joint axis, bad joint type), and see if we can fix those.

For the "Unable to read SDF string", it would be nice to somehow make it clear that it is a clear string. Suggestion was to surround in quotes if string is only whitespace or empty; otherwise, just print string in following line.

@EricCousineau-TRI
Copy link
Contributor Author

Resolved by #18462

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: multibody parsing Loading models into MultibodyPlant priority: medium
Projects
None yet
Development

No branches or pull requests

6 participants