Returns an OrderedDict of observables belonging to this Entity. The returned observables will include any added using the _add_observable method, as well as any generated by a method decorated with the @define.observable annotation. Args: fully_qualified: (bool) Whether the d
(self, fully_qualified=True)
| 91 | return self._keys_helper |
| 92 | |
| 93 | def as_dict(self, fully_qualified=True): |
| 94 | """Returns an OrderedDict of observables belonging to this Entity. |
| 95 | |
| 96 | The returned observables will include any added using the _add_observable |
| 97 | method, as well as any generated by a method decorated with the |
| 98 | @define.observable annotation. |
| 99 | |
| 100 | Args: |
| 101 | fully_qualified: (bool) Whether the dict keys should be prefixed with the |
| 102 | parent entity's full model identifier. |
| 103 | """ |
| 104 | |
| 105 | if fully_qualified: |
| 106 | # We need to make sure that this property doesn't raise an AttributeError, |
| 107 | # otherwise __getattr__ is executed and we get a very funky error. |
| 108 | try: |
| 109 | model_identifier = self._entity.mjcf_model.full_identifier |
| 110 | except AttributeError as exc: |
| 111 | raise ValueError( |
| 112 | 'Cannot retrieve the full identifier of mjcf_model.') from exc |
| 113 | |
| 114 | return collections.OrderedDict( |
| 115 | [(os.path.join(model_identifier, name), observable) |
| 116 | for name, observable in self._observables.items()]) |
| 117 | else: |
| 118 | # Return a copy to prevent dict being edited. |
| 119 | return self._observables.copy() |
| 120 | |
| 121 | def get_observable(self, name, name_fully_qualified=False): |
| 122 | """Returns the observable with the given name. |