Skip to content

Vehicle

Vehicle pydantic-model ¤

Encodes the Vehicle's state at the last tick

control: VehicleControl pydantic-field required ¤

transform: Transform pydantic-field ¤

velocity: Vector3D pydantic-field required ¤

wheel_base: float pydantic-field ¤

Default to tesla model 3's wheel base

__config__ ¤

__json_encoder__(obj) special staticmethod ¤

get_speed(vehicle) staticmethod ¤

Compute speed of a vehicle in Km/h.

Parameters:

Name Type Description Default
vehicle

the vehicle for which speed is calculated

required

Returns:

Type Description
float

speed as a float in Km/h

Source code in ROAR_simulation/roar_autonomous_system/utilities_module/vehicle_models.py
49
50
51
52
53
54
55
56
57
58
59
60
@staticmethod
def get_speed(vehicle) -> float:
    """
    Compute speed of a vehicle in Km/h.
    Args:
        vehicle: the vehicle for which speed is calculated

    Returns:
        speed as a float in Km/h
    """
    vel = vehicle.velocity
    return 3.6 * math.sqrt(vel.x ** 2 + vel.y ** 2 + vel.z ** 2)

VehicleControl pydantic-model ¤

steering: float pydantic-field ¤

throttle: float pydantic-field ¤

__config__ ¤

__json_encoder__(obj) special staticmethod ¤

clamp(n, minn, maxn) staticmethod ¤

Source code in ROAR_simulation/roar_autonomous_system/utilities_module/vehicle_models.py
14
15
16
@staticmethod
def clamp(n, minn, maxn):
    return max(min(maxn, n), minn)

get_steering(self) ¤

Steering between -1, 1

Returns:

Type Description
float

float between 01, 1

Source code in ROAR_simulation/roar_autonomous_system/utilities_module/vehicle_models.py
26
27
28
29
30
31
32
def get_steering(self) -> float:
    """
    Steering between -1, 1
    Returns:
        float between 01, 1
    """
    return self.clamp(self.steering, -1, 1)

get_throttle(self) ¤

throttle it between -1 and 1

Returns:

Type Description
float

float between -1, 1

Source code in ROAR_simulation/roar_autonomous_system/utilities_module/vehicle_models.py
18
19
20
21
22
23
24
def get_throttle(self) -> float:
    """
    throttle it between -1  and 1
    Returns:
        float between -1, 1
    """
    return self.clamp(self.throttle, -1, 1)