Datasets:
ArXiv:
License:
File size: 1,814 Bytes
cf360b5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 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
|