pymavswarm.utils package#
Submodules#
pymavswarm.utils.event module#
- class pymavswarm.utils.event.Event#
Bases:
object
Interface used to represent events and signal event listeners.
- add_listener(function: Callable) None #
Add a listener to the list of listeners.
- Parameters
fn (function) – Function to call on event
- property listeners: list#
List of methods that are called on the event.
- Returns
callback functions
- Return type
list
- notify(*args, **kwargs: Any) None #
Notify all listeners that the event was triggered.
- remove_listener(function: Callable) None #
Remove a listener from the list of listeners.
- Parameters
fn (function) – Function to remove
pymavswarm.utils.logging module#
- class pymavswarm.utils.logging.FileLogger(filename: Optional[str] = None)#
Bases:
object
File logging handler.
- pymavswarm.utils.logging.init_logger(name: str, log_level: int = 20) Logger #
Initialize the logger with the desired debug levels.
- Parameters
name (str) – The name of the logger
log_level (int, optional) – The log level to display, defaults to logging.INFO
- Returns
A newly configured logger
- Return type
logging.Logger
- pymavswarm.utils.logging.parse_log_file(logfile: str, message_type: Optional[str] = None) pandas.core.frame.DataFrame | dict[str, pandas.core.frame.DataFrame] #
Parse a pymavswarm log file.
- Parameters
logfile (str) – logfile to parse (including its path)
message_type (str | None, optional) – specific message type to get, defaults to None
- Returns
messages received of the specified type or a dictionary with all messages with their respective types as keys
- Return type
pd.DataFrame | dict[str, pd.DataFrame]
pymavswarm.utils.notifier_dict module#
- class pymavswarm.utils.notifier_dict.NotifierDict(event: Event, *args, **kwargs)#
Bases:
MutableMapping
Dictionary that notifies on add and del.
Dictionary-like object implemented to enable calling events when elements are added and removed from the dictionary.
This has been inspired by the following source: https://stackoverflow.com/questions/3387691/how-to-perfectly-override-a-dict
Module contents#
- pymavswarm.utils.latitude_conversion(latitude: float, offset: float) float #
Compute a new latitude given a reference position and a desired offset.
- Parameters
latitude (float) – latitude to update
offset (float) – distance from the previous latitude and the new latitude [m]
- Returns
updated latitude
- Return type
float
- pymavswarm.utils.longitude_conversion(latitude: float, longitude: float, offset: float) float #
Compute a new longitude given a reference position and a desired offset.
- Parameters
latitude (float) – latitude used to compute the updated longitude
longitude – longitude to reference for the updated longitude
offset (float) – distance from the previous longitude and the new longitude [m]
- Returns
updated longitude
- Return type
float