Search code examples
drake

Specify background color in Scenario/ Camera Config yaml


I would like to use a scenario yaml file for defining my cameras. However, I'm getting RuntimeError: The fields ['_tag'] were unknown to the schema when trying to parse the CameraConfig portion of my scenario file.

I'm trying to achieve it with the following:

@dc.dataclass
class Scenario:
    cameras: typing.Mapping[str, CameraConfig] = dc.field(default_factory=dict)

scenario = yaml_load_typed(
        schema=Scenario, filename=..., defaults=Scenario()
    )

My yaml file looks something like this:

cameras:
  camera0:
    name: camera0
    background: !Rgba { rgba: [0, 0, 0, 1] }

The issue seems to be with the !Rgba not being recognized. However, this seems to be the correct class based on the CameraConfig class.

Note: The Drake Blender Example makes playing with this easy.

What am I doing wrong here?


Solution

  • It requires a very special/bespoke spelling.

    cameras:
      camera0:
        name: camera0
        background:
          rgba: [0, 0, 0, 1]