Vehicle Telemetry#
Getting the State of the Wheels#
The wheel states are made available in a list using the following constants for indices.
from omni.physx.bindings._physx import (
VEHICLE_WHEEL_STATE_LOCAL_POSE_POSITION,
VEHICLE_WHEEL_STATE_LOCAL_POSE_QUATERNION,
VEHICLE_WHEEL_STATE_ROTATION_SPEED,
VEHICLE_WHEEL_STATE_ROTATION_ANGLE,
VEHICLE_WHEEL_STATE_STEER_ANGLE,
VEHICLE_WHEEL_STATE_GROUND_PLANE,
VEHICLE_WHEEL_STATE_GROUND_ACTOR,
VEHICLE_WHEEL_STATE_GROUND_SHAPE,
VEHICLE_WHEEL_STATE_GROUND_MATERIAL,
VEHICLE_WHEEL_STATE_GROUND_HIT_POSITION,
VEHICLE_WHEEL_STATE_SUSPENSION_JOUNCE,
VEHICLE_WHEEL_STATE_SUSPENSION_FORCE,
VEHICLE_WHEEL_STATE_IS_ON_GROUND,
VEHICLE_WHEEL_STATE_TIRE_FRICTION,
VEHICLE_WHEEL_STATE_TIRE_LONGITUDINAL_SLIP,
VEHICLE_WHEEL_STATE_TIRE_LATERAL_SLIP,
VEHICLE_WHEEL_STATE_TIRE_LONGITUDINAL_DIRECTION,
VEHICLE_WHEEL_STATE_TIRE_LATERAL_DIRECTION,
VEHICLE_WHEEL_STATE_TIRE_FORCE
)
You get the state of a specific wheel by calling get_wheel_state
from the physx_interface
, as shown in the example below.
In this example code you can determine if the wheel is on the ground and what material it’s contacting. You can then use this to feed smoke/dirt visual effects and audio sounds like tire skidding.
from omni.physx import get_physx_interface
# typical 4 wheel vehicle defaults
wheel_list = [ "/LeftWheel1References",
"/RightWheel1References",
"/LeftWheel2References",
"/RightWheel2References"]
# loop through all of the wheels
_physx_interface = omni.physx.get_physx_interface()
for current_wheel in wheel_list:
wheel_path = vehicle_prim_path + current_wheel
wheel_state = _physx_interface.get_wheel_state(wheel_path)
if wheel_state:
# get the material the wheel is touching (None if off ground)
wheel_mat = wheel_state[VEHICLE_WHEEL_STATE_GROUND_MATERIAL]
# is the wheel touching the ground?
wheel_on_ground = wheel_state[VEHICLE_WHEEL_STATE_IS_ON_GROUND]
Getting the State of the Drivetrain#
from omni.physx.bindings._physx import (
VEHICLE_AUTOMATIC_TRANSMISSION_GEAR_VALUE,
VEHICLE_DRIVE_STATE_ACCELERATOR,
VEHICLE_DRIVE_STATE_BRAKE0,
VEHICLE_DRIVE_STATE_BRAKE1,
VEHICLE_DRIVE_STATE_STEER,
VEHICLE_DRIVE_STATE_CLUTCH,
VEHICLE_DRIVE_STATE_CURRENT_GEAR,
VEHICLE_DRIVE_STATE_TARGET_GEAR,
VEHICLE_DRIVE_STATE_GEAR_SWITCH_TIME,
VEHICLE_DRIVE_STATE_AUTOBOX_TIME_SINCE_LAST_SHIFT,
VEHICLE_DRIVE_STATE_ENGINE_ROTATION_SPEED,
VEHICLE_DRIVE_STATE_AUTOMATIC_TRANSMISSION
)
You can get the state of the Drive Train by calling get_vehicle_drive_state
from the physx_interface
, as shown in the example below.
from omni.physx import get_physx_interface
# get the engine's current RPM
drive_state = self.physx_interface.get_vehicle_drive_state(self.vehicle_prim_path)
rpm = drive_state[VEHICLE_DRIVE_STATE_ENGINE_ROTATION_SPEED]