vehicle_common.mode_loader#
Classes#
Wrapper around BaseModel that every Mode's Params Type should inherit from |
|
!!! abstract "Usage Documentation" |
|
!!! abstract "Usage Documentation" |
Functions#
|
|
|
Class decorator that registers a Mode in the Mode Registry. |
Module Contents#
- class ParamsBase(/, **data: Any)#
Bases:
pydantic.BaseModelWrapper around BaseModel that every Mode’s Params Type should inherit from
- class RegisteredMode(/, **data: Any)#
Bases:
pydantic.BaseModel- !!! abstract “Usage Documentation”
[Models](../concepts/models.md)
A base class for creating Pydantic models.
- __class_vars__#
The names of the class variables defined on the model.
- __private_attributes__#
Metadata about the private attributes of the model.
- __signature__#
The synthesized __init__ [Signature][inspect.Signature] of the model.
- __pydantic_complete__#
Whether model building is completed, or if there are still undefined fields.
- __pydantic_core_schema__#
The core schema of the model.
- __pydantic_custom_init__#
Whether the model has a custom __init__ function.
- __pydantic_decorators__#
Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
- __pydantic_generic_metadata__#
A dictionary containing metadata about generic Pydantic models. The origin and args items map to the [__origin__][genericalias.__origin__] and [__args__][genericalias.__args__] attributes of [generic aliases][types-genericalias], and the parameter item maps to the __parameter__ attribute of generic classes.
- __pydantic_parent_namespace__#
Parent namespace of the model, used for automatic rebuilding of models.
- __pydantic_post_init__#
The name of the post-init method for the model, if defined.
- __pydantic_root_model__#
Whether the model is a [RootModel][pydantic.root_model.RootModel].
- __pydantic_serializer__#
The pydantic-core SchemaSerializer used to dump instances of the model.
- __pydantic_validator__#
The pydantic-core SchemaValidator used to validate instances of the model.
- __pydantic_fields__#
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
- __pydantic_computed_fields__#
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
- __pydantic_extra__#
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’.
- __pydantic_fields_set__#
The names of fields explicitly set during instantiation.
- __pydantic_private__#
Values of private attributes set on the model instance.
- model_config#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- id: str#
- mode_cls: type[vehicle_common.mode.Mode]#
- params_cls: type[ParamsBase]#
- targets: list[type[vehicle_common.vehicle.Vehicle]] = []#
- required_vision_nodes: list[type[vehicle_common.base.VisionNode]] = []#
- peer_vehicle_names: list[str] = []#
- requires_camera: bool = False#
- transition_labels: list[str] = []#
- serialize_mode_cls(value: type[vehicle_common.mode.Mode]) str#
- serialize_params_cls(value: type[ParamsBase]) str#
- serialize_targets(value: list[type[vehicle_common.vehicle.Vehicle]]) list[str]#
- serialize_vision_nodes(value: list[type[vehicle_common.base.VisionNode]]) list[str]#
- classmethod deserialize_mode_cls(path) type[vehicle_common.mode.Mode]#
- classmethod deserialize_params_cls(path) type[ParamsBase]#
- classmethod deserialize_targets(paths) list[type[vehicle_common.vehicle.Vehicle]]#
- classmethod deserialize_vision_nodes(paths) list[type[vehicle_common.base.VisionNode]]#
- __str__() str#
- names(types)#
- class ModeRegistry(/, **data: Any)#
Bases:
pydantic.BaseModel- !!! abstract “Usage Documentation”
[Models](../concepts/models.md)
A base class for creating Pydantic models.
- __class_vars__#
The names of the class variables defined on the model.
- __private_attributes__#
Metadata about the private attributes of the model.
- __signature__#
The synthesized __init__ [Signature][inspect.Signature] of the model.
- __pydantic_complete__#
Whether model building is completed, or if there are still undefined fields.
- __pydantic_core_schema__#
The core schema of the model.
- __pydantic_custom_init__#
Whether the model has a custom __init__ function.
- __pydantic_decorators__#
Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
- __pydantic_generic_metadata__#
A dictionary containing metadata about generic Pydantic models. The origin and args items map to the [__origin__][genericalias.__origin__] and [__args__][genericalias.__args__] attributes of [generic aliases][types-genericalias], and the parameter item maps to the __parameter__ attribute of generic classes.
- __pydantic_parent_namespace__#
Parent namespace of the model, used for automatic rebuilding of models.
- __pydantic_post_init__#
The name of the post-init method for the model, if defined.
- __pydantic_root_model__#
Whether the model is a [RootModel][pydantic.root_model.RootModel].
- __pydantic_serializer__#
The pydantic-core SchemaSerializer used to dump instances of the model.
- __pydantic_validator__#
The pydantic-core SchemaValidator used to validate instances of the model.
- __pydantic_fields__#
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
- __pydantic_computed_fields__#
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
- __pydantic_extra__#
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’.
- __pydantic_fields_set__#
The names of fields explicitly set during instantiation.
- __pydantic_private__#
Values of private attributes set on the model instance.
- modes: dict[str, RegisteredMode]#
- _pending: ClassVar[list[RegisteredMode]] = []#
- _instance: ClassVar[ModeRegistry | None] = None#
- classmethod get() ModeRegistry#
- get_registered_mode(id: str) RegisteredMode#
- write_json(path: pathlib.Path) None#
- discover_modes(modules: list[str] = ['uav.modes', 'payload.modes'])#
Import every submodule under the given packages to trigger mode registration.
Recursively imports the passed in modules. Importing a file with @register_mode(…)-decorated classes populates them into the _pending list, which this then commits into self.modes.
- Parameters:
modules – Dotted package paths to walk and import submodules from. Defaults to the UAV and payload mode packages.
- register_mode(id: str, targets: list[type[vehicle_common.vehicle.Vehicle]], params_cls: type[ParamsBase] = ParamsBase, required_vision_nodes: list[type[vehicle_common.base.VisionNode]] = [], peer_vehicle_names: list[str] = [], requires_camera: bool = False, transition_labels: list[str] = [])#
Class decorator that registers a Mode in the Mode Registry. Class decorators can only run once, so the registered mode is put into a global pending list in ModeRegistry. A ModeRegistry instance only picks it up once its own discover_modes() runs.
- Parameters:
id – used as main key to store and retrieve RegisteredMode objects
targets – Vehicle types this mode is valid for
required_vision_nodes – Vision node types that must be running for this mode to be usable.
peer_vehicle_names – Names of peer vehicles this mode depends on
requires_camera – Whether this mode requires a camera to operate.
transition_labels – Labels describing valid transitions into/out of this mode, used by whatever drives mode switching.
- Returns:
A decorator that registers the given Mode subclass and returns it unchanged.