Tweak tyres, fix asymmetry in pacejka formula

This commit is contained in:
sergeypdev 2025-03-20 00:46:50 +04:00
parent b6866f53f3
commit 22c2224dea
4 changed files with 58 additions and 39 deletions

View File

@ -320,7 +320,7 @@ update_runtime_world :: proc(runtime_world: ^Runtime_World, dt: f32) {
wheel_extent_x := f32(1.7)
wheel_y := f32(-0.5)
rest := f32(1)
natural_frequency := f32(0.3)
natural_frequency := f32(0.4)
damping := f32(0.08)
radius := f32(0.6)
wheel_front_z := f32(3.05)
@ -393,7 +393,7 @@ update_runtime_world :: proc(runtime_world: ^Runtime_World, dt: f32) {
front_wheels := turn_wheels
back_wheels := drive_wheels
DRIVE_IMPULSE :: 2000
DRIVE_IMPULSE :: 3000
BRAKE_IMPULSE :: 500
TURN_ANGLE :: -f32(30) * math.RAD_PER_DEG
// 68% front, 32% rear

View File

@ -4,7 +4,7 @@ import "core:math"
Pacejka96_Params :: [11]f32
DEFAULT_PACEJKA96_PARAMS :: Pacejka96_Params{1.65, 1, 1750, 0, 229, 0.0, 0, 0, -12, 0, 0}
DEFAULT_PACEJKA96_PARAMS :: Pacejka96_Params{1.65, -200, 1900, 0, 229, 0.0, 0, 0, 0, 0, 0}
// X is slip ratio percentage [-100, 100] or slip angle in degrees, where positive angle is turning left
// Output is the friction coefficient
@ -12,7 +12,7 @@ pacejka_96 :: proc(b: Pacejka96_Params, x: f32, f_z: f32, s_v: f32 = 0) -> f32 {
C := b[0]
D := (b[1] * f_z + b[2]) * f_z
B := ((b[3] * f_z * f_z + b[4] * f_z) * math.exp(-b[5] * f_z)) / (C * D)
E := -(1 - (b[6] * f_z * f_z + b[7] * f_z + b[8]))
E := (b[6] * f_z * f_z + b[7] * f_z + b[8])
s_h := b[9] * f_z + b[10]
X := x + s_h

View File

@ -550,7 +550,6 @@ pgs_solve_suspension :: proc(sim_state: ^Sim_State, config: Solver_Config, dt: f
apply_velocity_correction(body, incremental_impulse * dir, wheel_world_pos)
}
body_right := body_local_to_world_vec(body, Vec3{1, 0, 0})
right := wheel_get_right_vec(body, v)
// Positive means spinning forward
@ -638,7 +637,7 @@ pgs_solve_suspension :: proc(sim_state: ^Sim_State, config: Solver_Config, dt: f
applied_impulse := new_total_impulse - v.lateral_impulse
v.lateral_impulse = new_total_impulse
apply_velocity_correction(body, applied_impulse * body_right, v.hit_point)
apply_velocity_correction(body, applied_impulse * right, v.hit_point)
}
} else {
v.lateral_impulse = 0
@ -693,7 +692,7 @@ pgs_substep :: proc(sim_state: ^Sim_State, config: Solver_Config, dt: f32, inv_d
p := body_local_to_world(body, s.rel_pos)
hit_p := body_local_to_world(body, s.rel_pos + s.rel_dir * s.hit_t)
forward := wheel_get_forward_vec(body, s)
right := body_local_to_world_vec(body, Vec3{1, 0, 0})
right := wheel_get_right_vec(body, s)
apply_velocity_correction(
body,

File diff suppressed because one or more lines are too long