leads.data#

Module Contents#

Classes#

Functions#

dlat2meters

meters2dlat

dlon2meters

meters2dlon

distance_between

Calculate the distance between two locations on the Earth. :param lat_0: the latitude of the first location :param lon_0: the longitude of the first location :param lat: the latitude of the second location :param lon: the longitude of the second location :return:

format_duration

Wrap the duration into a formatted string. :param duration: the duration in seconds :return: the formatted string

API#

class leads.data.Serializable[source]#

Bases: object

to_dict() dict[str, Any][source]#
class leads.data.DataContainer(voltage: float = 0, speed: float = 0, front_wheel_speed: float = 0, rear_wheel_speed: float = 0, yaw: float = 0, pitch: float = 0, roll: float = 0, forward_acceleration: float = 0, lateral_acceleration: float = 0, vertical_acceleration: float = 0, front_proximity: float = -1, left_proximity: float = -1, right_proximity: float = -1, rear_proximity: float = -1, mileage: float = 0, gps_valid: bool = False, gps_ground_speed: float = 0, latitude: float = 0, longitude: float = 0, steering_position: float = 0, throttle: float = 0, brake: float = 0, **kwargs)[source]#

Bases: leads.data.Serializable

Initialization

__str__() str[source]#
reset_time_stamp() None[source]#

Reset the data’s time stamp to now.

time_stamp() int[source]#

Get the data’s time stamp. :return: the time stamp (ms)

to_dict() dict[str, Any][source]#

Convert the data into a dictionary. :return: a dictionary that contains all custom attributes of the container

encode() bytes[source]#

Encode the data into bytes for network transaction purposes. :return: JSON in bytes

class leads.data.VisualDataContainer(voltage: float = 0, speed: float = 0, front_wheel_speed: float = 0, rear_wheel_speed: float = 0, yaw: float = 0, pitch: float = 0, roll: float = 0, forward_acceleration: float = 0, lateral_acceleration: float = 0, vertical_acceleration: float = 0, front_proximity: float = -1, left_proximity: float = -1, right_proximity: float = -1, rear_proximity: float = -1, mileage: float = 0, gps_valid: bool = False, gps_ground_speed: float = 0, latitude: float = 0, longitude: float = 0, steering_position: float = 0, throttle: float = 0, brake: float = 0, front_view_base64: str = '', front_view_latency: int = 0, left_view_base64: str = '', left_view_latency: int = 0, right_view_base64: str = '', right_view_latency: int = 0, rear_view_base64: str = '', rear_view_latency: int = 0, **kwargs)[source]#

Bases: leads.data.DataContainer

Initialization

leads.data.dlat2meters(dlat: float) float[source]#
leads.data.meters2dlat(meters: float) float[source]#
leads.data.dlon2meters(dlon: float, lat: float) float[source]#
leads.data.meters2dlon(meters: float, lat: float) float[source]#
leads.data.distance_between(lat_0: float, lon_0: float, lat: float, lon: float) float[source]#

Calculate the distance between two locations on the Earth. :param lat_0: the latitude of the first location :param lon_0: the longitude of the first location :param lat: the latitude of the second location :param lon: the longitude of the second location :return:

leads.data.format_duration(duration: float) str[source]#

Wrap the duration into a formatted string. :param duration: the duration in seconds :return: the formatted string