challenge_data / robot_description /chassis_transform.py
challenge-2026's picture
Upload folder using huggingface_hub
cf360b5 verified
Raw History Blame Contribute Delete
1.81 kB
import numpy as np
def CalcChassisVelocityFromWheels(wheel_vel):
"""
Compute chassis body-frame velocity from three wheel angular velocities for a
three-wheel omnidirectional chassis.
Input
-----
wheel_vel : np.ndarray, shape (..., 3), float
Wheel angular velocity array (unit: rad/s).
Order: [wheel_front_left_velocity, wheel_front_right_velocity, wheel_rear_velocity]
Output
------
chassis_vel : np.ndarray, shape (..., 3), float
Chassis body‑frame velocity vector [v_x, v_y, omega_z].
- v_x: body‑frame linear velocity along x axis (m/s)
- v_y: body‑frame linear velocity along y axis (m/s)
- omega_z: body‑frame angular velocity around z axis (rad/s)
Output shape matches input batch dimensions.
Constants
---------
SQRT3_OVER_2 : float
√3 / 2 ≈ 0.8660254037844386, geometric coefficient for wheel layout.
RWHEEL : float
Wheel radius, unit: meter.
RCHASSIS : float
Distance from chassis center to each wheel mounting point, unit: meter.
"""
SQRT3_OVER_2 = 0.8660254037844386
RWHEEL = 0.101555
RCHASSIS = 0.32485
# Initialize output array with same batch dimensions as input
chassis_vel = np.zeros_like(wheel_vel)
# Body‑frame v_x (m/s)
chassis_vel[..., 0] = (
(wheel_vel[..., 0] - wheel_vel[..., 1]) * RWHEEL / (2.0 * SQRT3_OVER_2)
)
# Body‑frame v_y (m/s)
chassis_vel[..., 1] = (
(2.0 * wheel_vel[..., 2] - wheel_vel[..., 0] - wheel_vel[..., 1]) * RWHEEL / 3.0
)
# Body‑frame angular velocity omega_z (rad/s)
chassis_vel[..., 2] = (
-(wheel_vel[..., 0] + wheel_vel[..., 1] + wheel_vel[..., 2])
* RWHEEL
/ (3.0 * RCHASSIS)
)
return chassis_vel