RobotLocomotion / drake

Model-based design and verification for robotics.
https://drake.mit.edu
Other
3.34k stars 1.26k forks source link

sdformat: Should attempt migration from model directives; if sufficient, deprecate model directives #15948

Open EricCousineau-TRI opened 3 years ago

EricCousineau-TRI commented 3 years ago

As follow-up from #15522. My plan is that this would happen after #15613 (and perhaps a more general version of that issue).

Suggested steps:

FYI @jwnimmer-tri @ggould-tri

aaronchongth commented 2 years ago

After some experiments with the tests in multibody/parsing/test/process_model_directives_test, there have been some findings,

aaronchongth commented 2 years ago

The key question here would be, how critical it is to support an unscoped include into a top level world?

EricCousineau-TRI commented 2 years ago

explicitly resolving a frame by namespacing its name is not supported and not needed, hence they will be commented out

Sounds good!

however when parsing just add_scoped_sub.sdf in drake, the number of bodies is no longer 2, as there is the overarching model add_scoped_sub which contains the model instances simple_model and extra_model

Do you mean 2 model instances, not bodies?

At the moment, it seems that sdformat is unable to replicate an unscoped include, [...] The key question here would be, how critical it is to support an unscoped include into a top level world?

For the unscoped include, is it possible to achieve this using SDFormat's //include/@merge? https://github.com/ignitionrobotics/sdformat/pull/659

azeey commented 2 years ago

For the unscoped include, is it possible to achieve this using SDFormat's //include/@merge?

//include/@merge is currently only supported for //model/include, not //world/include because merging-including a model into a world is ill-defined since the model may contain links or joints, which are not valid children of //world.

EricCousineau-TRI commented 2 years ago

Gotcha. In this case, perhaps it's best to simply relax the world constraint (both in terms of the frame, and where it'll be included from).

EricCousineau-TRI commented 2 years ago

Per f2f

Clarified - this is still an issue; solution would be to try and relax the constraint where //world/include/@merge is allowed if the included model's elements can live inside of //world.

Alternative is to teach Drake how to properly scope models (vs. just coloring via ModelInstanceIndex). That may be more difficult.

aaronchongth commented 2 years ago

Thanks for the updates!

Some other findings, I'm stuck on an error when parsing a world/model that is including another model with includes. I've created a minimal example to reproduce this, https://github.com/aaronchongth/drake/commit/004bb41af829b52febc61ac05635d5270461e369

With a model hierarchy like this

world
|__include -> weld_robots
    |__include -> simple_robot1
    |__include -> simple_robot2

It can't seem to find the models simple_robot1 or simple_robot2.

While parsing just weld_robots directly, doesn't introduce any errors, and works as expected.

weld_robots
|__ include -> simple_robot1
|__ include -> simple_robot2

test failure log: https://gist.github.com/aaronchongth/b3c641cb785030b00552d497db2b05af

I'm currently looking into it, but just thought I'd share here just in case I'm missing something or making any glaring mistakes.

Edit: https://github.com/aaronchongth/drake/blob/aaron/test-nested-include/multibody/parsing/test/process_model_directives_test.cc#L198-L213 uses the parser instead of building the package map manually, but the error still occurs. The test files are located here

EricCousineau-TRI commented 2 years ago

(accidental close from merge of https://github.com/ignitionrobotics/sdformat/pull/824)

EricCousineau-TRI commented 2 years ago

For additional discussion (from above topics and more), see Aaron's overrview in #16431

EricCousineau-TRI commented 2 years ago

@marcoag will be picking up on Aaron's conversion script prototype in https://github.com/aaronchongth/drake/pull/1