fh5-common submodule

This commit is contained in:
Alex Janka 2022-08-09 15:15:09 +10:00
parent 1ddf29dfbd
commit 73ff726109
5 changed files with 17 additions and 124 deletions

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "fh5-common"]
path = fh5-common
url = g://italicsjenga/fh5-common

8
Cargo.lock generated
View file

@ -126,6 +126,13 @@ dependencies = [
"instant",
]
[[package]]
name = "fh5-common"
version = "0.1.0"
dependencies = [
"serde",
]
[[package]]
name = "hashbrown"
version = "0.11.2"
@ -335,6 +342,7 @@ dependencies = [
"chrono",
"clap",
"csv",
"fh5-common",
"serde",
"tempfile",
]

View file

@ -12,3 +12,4 @@ bincode = "1.3"
csv = "1.1"
chrono = "0.4"
tempfile = "3.3"
fh5-common = { path = "fh5-common", version="0.1" }

1
fh5-common Submodule

@ -0,0 +1 @@
Subproject commit 5c51da0747206cc8e404fc566a95b5befa94911c

View file

@ -1,3 +1,6 @@
extern crate fh5_common;
use fh5_common::Telemetry;
use std::fs::OpenOptions;
use std::net::UdpSocket;
#[cfg(target_family = "unix")]
@ -8,7 +11,6 @@ use std::{fs, net};
use bincode;
use chrono::Local;
use clap::Parser;
use serde::{Deserialize, Serialize};
use tempfile::tempfile;
#[derive(Parser, Debug)]
@ -24,128 +26,6 @@ struct Args {
verbose: bool,
}
#[derive(Serialize, Deserialize, Debug)]
struct Telemetry {
is_race_on: i32,
time_stamp_ms: u32,
engine_max_rpm: f32,
engine_idle_rpm: f32,
current_engine_rpm: f32,
acceleration_x: f32, // local space: X = right, Y = up, Z = forward
acceleration_y: f32,
acceleration_z: f32,
velocity_x: f32, // local space: X = right, Y = up, Z = forward
velocity_y: f32,
velocity_z: f32,
angular_velocity_x: f32, // local space: X = pitch, Y = yaw, Z = roll
angular_velocity_y: f32,
angular_velocity_z: f32,
yaw: f32,
pitch: f32,
roll: f32,
normalized_suspension_travel_front_left: f32, // Suspension travel normalized: 0.0f = max stretch; 1.0 = max compression
normalized_suspension_travel_front_right: f32,
normalized_suspension_travel_rear_left: f32,
normalized_suspension_travel_rear_right: f32,
tire_slip_ratio_front_left: f32, // Tire normalized slip ratio, = 0 means 100% grip and |ratio| > 1.0 means loss of grip.
tire_slip_ratio_front_right: f32,
tire_slip_ratio_rear_left: f32,
tire_slip_ratio_rear_right: f32,
wheel_rotation_speed_front_left: f32, // Wheel rotation speed radians/sec.
wheel_rotation_speed_front_right: f32,
wheel_rotation_speed_rear_left: f32,
wheel_rotation_speed_rear_right: f32,
wheel_on_rumble_strip_front_left: i32, // = 1 when wheel is on rumble strip, = 0 when off.
wheel_on_rumble_strip_front_right: i32,
wheel_on_rumble_strip_rear_left: i32,
wheel_on_rumble_strip_rear_right: i32,
wheel_in_puddle_depth_front_left: f32, // = from 0 to 1, where 1 is the deepest puddle
wheel_in_puddle_depth_front_right: f32,
wheel_in_puddle_depth_rear_left: f32,
wheel_in_puddle_depth_rear_right: f32,
surface_rumble_front_left: f32, // Non-dimensional surface rumble values passed to controller force feedback
surface_rumble_front_right: f32,
surface_rumble_rear_left: f32,
surface_rumble_rear_right: f32,
tire_slip_angle_front_left: f32, // Tire normalized slip angle, = 0 means 100% grip and |angle| > 1.0 means loss of grip.
tire_slip_angle_front_right: f32,
tire_slip_angle_rear_left: f32,
tire_slip_angle_rear_right: f32,
tire_combined_slip_front_left: f32, // Tire normalized combined slip, = 0 means 100% grip and |slip| > 1.0 means loss of grip.
tire_combined_slip_front_right: f32,
tire_combined_slip_rear_left: f32,
tire_combined_slip_rear_right: f32,
suspension_travel_meters_front_left: f32, // Actual suspension travel in meters
suspension_travel_meters_front_right: f32,
suspension_travel_meters_rear_left: f32,
suspension_travel_meters_rear_right: f32,
car_ordinal: i32,
car_class: i32,
car_performance_index: i32,
drivetraintype: i32, // 0 = FWD, 1 = RWD, 2 = AWD
num_cylinders: i32,
car_type: i32,
unknown1: u8,
unknown2: u8,
unknown3: u8,
unknown4: u8,
unknown5: u8,
unknown6: u8,
unknown7: u8,
unknown8: u8,
position_x: f32, // meters
position_y: f32,
position_z: f32,
speed: f32, // meters per second
power: f32, // watts
torque: f32, // newton meters
tire_temp_front_left: f32,
tire_temp_front_right: f32,
tire_temp_rear_left: f32,
tire_temp_rear_right: f32,
boost: f32,
fuel: f32,
distance_traveled: f32,
best_lap: f32,
last_lap: f32,
current_lap: f32,
current_race_time: f32,
lap_number: i16,
race_position: u8,
accel: u8,
brake: u8,
clutch: u8,
handbrake: u8,
gear: u8,
steer: i8,
normalized_driving_line: i8,
normalized_ai_brake_difference: i8,
}
struct Status {
inrace: bool,
position: u8,