vehicle_common.mode#
Classes#
Base class for UAV operational modes within a ROS 2 node. |
Module Contents#
- class Mode[VehicleT: vehicle_common.vehicle.Vehicle, ParamsT: pydantic.BaseModel]#
Bases:
abc.ABCBase class for UAV operational modes within a ROS 2 node. Provides a structured template for implementing autonomous behaviors.
- transition_labels: ClassVar[tuple[str, ...]] = ()#
- active = False#
- abstractmethod initialize(node: rclpy.node.Node, vehicle: VehicleT, params: ParamsT) None#
Abstract method for initializing a mode
- Parameters:
node – The ROS 2 node that gets passed into the mode
vehicle – The vehicle instance that the current mode has control over
params – A validated pydantic params model that the mode class has defined
- classmethod declared_transition_labels() tuple[str, ...]#
- on_enter() None#
Logic executed when this mode is activated. Should include any initialization required for the mode.
- on_exit() None#
Logic executed when this mode is deactivated. Should include any cleanup required for the mode.
- abstractmethod on_update(time_delta: float) None#
Periodic logic executed while the mode is active. This should implement the mode’s core behavior.
- Parameters:
time_delta (float) – Time in seconds since the last update.
- abstractmethod check_status() str#
Check if the mode should deactivate.
- activate() None#
Activate the mode. Calls the on_enter method.
- deactivate() None#
Deactivate the mode. Calls the on_exit method.
- update(time_delta: float) None#
Update the mode if it is active. Calls the on_update method.
- Parameters:
time_delta (float) – Time in seconds since the last update.
- log(message: str) None#
Log a message using the ROS 2 node’s logger.
- Parameters:
message (str) – The message to log.