Skip to content

Jetson Bridge

JetsonBridge ¤

convert_control_from_agent_to_source(self, control) ¤

Converts control to Throttle and Steering numpy arrays bound between -1 and 1.

Parameters:

Name Type Description Default
control VehicleControl required

Returns:

Type Description
Tuple

Tuple

Source code in Bridges/jetson_bridge.py
def convert_control_from_agent_to_source(self, control: VehicleControl) -> Tuple:
    """
    Converts control to Throttle and Steering numpy arrays bound between -1 and 1.
    Args:
        control ():

    Returns:
        Tuple
    """
    return np.clip(control.throttle, a_min=-1, a_max=1), np.clip(control.steering, a_min=-1, a_max=1)

convert_control_from_source_to_agent(self, source) ¤

Convert Jetson raw vehicle control to VehicleControl(throttle,steering).

Parameters:

Name Type Description Default
source Vehicle required

Returns:

Type Description
VehicleControl

VehicleControl(Throttle, Steering)

Source code in Bridges/jetson_bridge.py
def convert_control_from_source_to_agent(self, source: JetsonVehicle) -> VehicleControl:
    """
    Convert Jetson raw vehicle control to VehicleControl(throttle,steering).
    Args:
        source ():

    Returns:
        VehicleControl(Throttle, Steering)
    """
    return VehicleControl(throttle=source.throttle, steering=source.steering)

convert_depth_from_source_to_agent(self, source) ¤

Convert Jetson raw Image to an Optional with Depth numpy array.

Parameters:

Name Type Description Default
source required

Returns:

Type Description
Optional[ROAR.utilities_module.data_structures_models.DepthData]

DepthData

Source code in Bridges/jetson_bridge.py
def convert_depth_from_source_to_agent(self, source) -> Optional[DepthData]:
    """
    Convert Jetson raw Image to an Optional with Depth numpy array.
    Args:
        source ():

    Returns:
        DepthData
    """
    if source is not None:
        depth_data = DepthData(data=source / np.amax(source))
        return depth_data
    return None

convert_imu_from_source_to_agent(self, source) ¤

Convert Jetson raw IMUData to IMUData(accelerometer, gyroscope).

Parameters:

Name Type Description Default
source required

Returns:

Type Description
IMUData

IMUData(accelerometer, gyroscope)

Source code in Bridges/jetson_bridge.py
def convert_imu_from_source_to_agent(self, source) -> IMUData:
    """
    Convert Jetson raw IMUData to IMUData(accelerometer, gyroscope).
    Args:
        source ():

    Returns:
        IMUData(accelerometer, gyroscope)
    """
    # TODO fill in data here
    return IMUData(
        accelerometer=Vector3D(x=0, y=0, z=0),
        gyroscope=Vector3D(x=0, y=0, z=0),
    )

convert_location_from_source_to_agent(self, source) ¤

Convert Location data from Jetson Vehicle to Agent's location data type.

Parameters:

Name Type Description Default
source ndarray required

Returns:

Type Description
Location

Location(x, y, z)

Source code in Bridges/jetson_bridge.py
def convert_location_from_source_to_agent(self, source:np.ndarray) -> Location:
    """
    Convert Location data from Jetson Vehicle to Agent's location data type.
    Args:
        source ():

    Returns:
        Location(x, y, z)
    """
    return Location(x=source[0], y=source[1], z=source[2])

convert_rgb_from_source_to_agent(self, source) ¤

Convert Jetson raw Image to an Optional with RGB numpy array.

Parameters:

Name Type Description Default
source required

Returns:

Type Description
Optional[ROAR.utilities_module.data_structures_models.RGBData]

RGBData

Source code in Bridges/jetson_bridge.py
def convert_rgb_from_source_to_agent(self, source) -> Optional[RGBData]:
    """
    Convert Jetson raw Image to an Optional with RGB numpy array.
    Args:
        source ():

    Returns:
        RGBData
    """
    if source is not None:
        return RGBData(data=source)
    return None

convert_rotation_from_source_to_agent(self, source) ¤

Convert a Jetson raw rotation to Rotation(pitch=float,yaw=float,roll=float).

Parameters:

Name Type Description Default
source ndarray required

Returns:

Type Description
Rotation

Rotation(pitch, yaw, roll)

Source code in Bridges/jetson_bridge.py
def convert_rotation_from_source_to_agent(self, source: np.ndarray) -> Rotation:
    """
    Convert a Jetson raw rotation to Rotation(pitch=float,yaw=float,roll=float).
    Args:
        source ():

    Returns:
        Rotation(pitch, yaw, roll)
    """
    return Rotation(roll=source[0], pitch=source[1], yaw=source[2])

convert_sensor_data_from_source_to_agent(self, source) ¤

Returns Jetson Sensors Data from raw front RGB, rear RGB, front depth, and IMU Data.

Parameters:

Name Type Description Default
source required

Returns:

Type Description
SensorsData

SensorData(front_RGB, rear_RGB, front_depth, IMU_Data)

Source code in Bridges/jetson_bridge.py
def convert_sensor_data_from_source_to_agent(self, source) -> SensorsData:
    """
    Returns Jetson Sensors Data from raw front RGB, rear RGB, front depth, and IMU Data.
    Args:
        source ():

    Returns:
        SensorData(front_RGB, rear_RGB, front_depth, IMU_Data)
    """
    return SensorsData(
        front_rgb=self.convert_rgb_from_source_to_agent(
            source=source.get("front_rgb", None)
        ),
        rear_rgb=self.convert_rgb_from_source_to_agent(
            source=source.get("rear_rgb", None)
        ),
        front_depth=self.convert_depth_from_source_to_agent(
            source=source.get("front_depth", None)
        ),
        imu_data=self.convert_imu_from_source_to_agent(
            source=source.get("imu", None)
        ),
        location=self.convert_location_from_source_to_agent(
            source=source.get("location", None)),
        rotation=self.convert_rotation_from_source_to_agent(
            source=source.get("rotation", None)),
        velocity=self.convert_location_from_source_to_agent(
            source=source.get("velocity", None))
    )

convert_transform_from_source_to_agent(self, source) ¤

Convert Jetson raw location and rotation to Transform(location,rotation).

Parameters:

Name Type Description Default
source required

Returns:

Type Description
Transform

Transform(Location, Rotation)

Source code in Bridges/jetson_bridge.py
def convert_transform_from_source_to_agent(self, source) -> Transform:
    """
    Convert Jetson raw location and rotation to Transform(location,rotation).
    Args:
        source ():

    Returns:
        Transform(Location, Rotation)
    """
    return Transform(
        location=self.convert_location_from_source_to_agent(source=source.location),
        rotation=self.convert_rotation_from_source_to_agent(source=source.rotation),
    )

convert_vector3d_from_agent_to_source(self, vector3d) ¤

Convert Jetson Vector3D Object to Vector3D data.

Parameters:

Name Type Description Default
vector3d Vector3D required

Returns:

Type Description
Any

Array

Source code in Bridges/jetson_bridge.py
def convert_vector3d_from_agent_to_source(self, vector3d: Vector3D) -> Any:
    """
    Convert Jetson Vector3D Object to Vector3D data.
    Args:
        vector3d ():

    Returns:
        Array
    """
    return [vector3d.x, vector3d.y, vector3d.z]

convert_vector3d_from_source_to_agent(self, source) ¤

Convert Jetson raw Vector3d Data to a Vector3D Object.

Parameters:

Name Type Description Default
source required

Returns:

Type Description
Vector3D

Vector3D(x, y, z)

Source code in Bridges/jetson_bridge.py
def convert_vector3d_from_source_to_agent(self, source) -> Vector3D:
    """
    Convert Jetson raw Vector3d Data to a Vector3D Object.
    Args:
        source ():

    Returns:
        Vector3D(x, y, z)
    """
    return Vector3D(x=source.x, y=source.y, z=source.z)

convert_vehicle_from_source_to_agent(self, source) ¤

Converts Transform, Velocity, Wheel_Base, and Control of JetsonVehicle.

Parameters:

Name Type Description Default
source Vehicle required

Returns:

Type Description
Vehicle

Vehicle(Transform, Velocity, Wheel_Base, Control)

Source code in Bridges/jetson_bridge.py
def convert_vehicle_from_source_to_agent(self, source: JetsonVehicle) -> Vehicle:
    """
    Converts Transform, Velocity, Wheel_Base, and Control of JetsonVehicle.
    Args:
        source ():

    Returns:
        Vehicle(Transform, Velocity, Wheel_Base, Control)
    """
    return Vehicle(wheel_base=0.26,
                   control=self.convert_control_from_source_to_agent(source=source)
    )

convert_vive_tracker_data_from_source_to_agent(self, source) ¤

Converts raw Vive Tracker data to ViveTrackerData(Location, Rotation, Velocity).

Parameters:

Name Type Description Default
source Optional[ROAR_Jetson.vive.models.ViveTrackerMessage] required

Returns:

Type Description
Optional[ROAR.utilities_module.data_structures_models.ViveTrackerData]

ViveTrackerData(Location, Rotation, Velocity)

Source code in Bridges/jetson_bridge.py
def convert_vive_tracker_data_from_source_to_agent(self, source: Optional[ViveTrackerMessage]) -> \
        Optional[ViveTrackerData]:
    """
    Converts raw Vive Tracker data to ViveTrackerData(Location, Rotation, Velocity).
    Args:
        source ():

    Returns:
        ViveTrackerData(Location, Rotation, Velocity)
    """
    if source is not None:
        vive_tracker_data = ViveTrackerData(
            location=Location(
                x=-source.x,
                y=source.y,
                z=-source.z
            ),
            rotation=Rotation(
                roll=-source.roll,
                pitch=source.pitch - 90,  # 不知道为什么有60度的误差
                yaw=-source.yaw
            ),
            velocity=Vector3D(
                x=source.vel_x,
                y=source.vel_y,
                z=source.vel_z
            )
        )
        return vive_tracker_data
    return None