fixed incorrect numbering of Forza unpacked data
This commit is contained in:
parent
84da201ed8
commit
81e704cf7a
6 changed files with 4405 additions and 212 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
/build
|
/build
|
||||||
/dist
|
/dist
|
||||||
OutGaugeInterpreter.spec
|
OutGaugeInterpreter.spec
|
||||||
|
dataOut.csv
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import struct
|
import struct
|
||||||
#####FROZA_DATA_FORMAT = '<iIfffffffffffffffffffffffffffffffffffffffffffffffffffiiiiifffffffffffffffffHBBBBBBbbb'
|
|
||||||
FORZA_DATA_FORMAT = '<iIfffffffffffffffffffffffffffiiiiffffffffffffffffffffiiiiifffffffffffffffffHBBBBBBbbbffffi'
|
FORZA_DATA_FORMAT = '<iIfffffffffffffffffffffffffffiiiiffffffffffffffffffffiiiiifffffffffffffffffHBBBBBBbbbffffi'
|
||||||
####FORZA_DATA_FORMAT = '<iI27f4i20f5i17fH6B3bi19fH6B4b'
|
|
||||||
|
|
||||||
def unpackData(unpackedData):
|
def unpackData(unpackedData):
|
||||||
carData = {
|
carData = {
|
||||||
|
|
@ -50,128 +49,69 @@ def unpackData(unpackedData):
|
||||||
"WheelInPuddleDepthFrontLeft": unpackedData[33],
|
"WheelInPuddleDepthFrontLeft": unpackedData[33],
|
||||||
"WheelInPuddleDepthFrontRight": unpackedData[34],
|
"WheelInPuddleDepthFrontRight": unpackedData[34],
|
||||||
"WheelInPuddleDepthRearLeft": unpackedData[35],
|
"WheelInPuddleDepthRearLeft": unpackedData[35],
|
||||||
"WheelInPuddleDepthRearRight": unpackedData[35],
|
"WheelInPuddleDepthRearRight": unpackedData[36],
|
||||||
#// Non-dimensional surface rumble values passed to controller force feedback
|
#// Non-dimensional surface rumble values passed to controller force feedback
|
||||||
"SurfaceRumbleFrontLeft": unpackedData[36],
|
"SurfaceRumbleFrontLeft": unpackedData[37],
|
||||||
"SurfaceRumbleFrontRight": unpackedData[37],
|
"SurfaceRumbleFrontRight": unpackedData[38],
|
||||||
"SurfaceRumbleRearLeft": unpackedData[38],
|
"SurfaceRumbleRearLeft": unpackedData[39],
|
||||||
"SurfaceRumbleRearRight": unpackedData[39],
|
"SurfaceRumbleRearRight": unpackedData[40],
|
||||||
#// Tire normalized slip angle, = 0 means 100% grip and |angle| > 1.0 means loss of grip.
|
#// Tire normalized slip angle, = 0 means 100% grip and |angle| > 1.0 means loss of grip.
|
||||||
"TireSlipAngleFrontLeft": unpackedData[40],
|
"TireSlipAngleFrontLeft": unpackedData[41],
|
||||||
"TireSlipAngleFrontRight": unpackedData[41],
|
"TireSlipAngleFrontRight": unpackedData[42],
|
||||||
"TireSlipAngleRearLeft": unpackedData[42],
|
"TireSlipAngleRearLeft": unpackedData[43],
|
||||||
"TireSlipAngleRearRight": unpackedData[43],
|
"TireSlipAngleRearRight": unpackedData[44],
|
||||||
#// Tire normalized combined slip, = 0 means 100% grip and |slip| > 1.0 means loss of grip.
|
#// Tire normalized combined slip, = 0 means 100% grip and |slip| > 1.0 means loss of grip.
|
||||||
"TireCombinedSlipFrontLeft": unpackedData[44],
|
"TireCombinedSlipFrontLeft": unpackedData[45],
|
||||||
"TireCombinedSlipFrontRight": unpackedData[45],
|
"TireCombinedSlipFrontRight": unpackedData[46],
|
||||||
"TireCombinedSlipRearLeft": unpackedData[46],
|
"TireCombinedSlipRearLeft": unpackedData[47],
|
||||||
"TireCombinedSlipRearRight": unpackedData[47],
|
"TireCombinedSlipRearRight": unpackedData[48],
|
||||||
#// Actual suspension travel in meters
|
#// Actual suspension travel in meters
|
||||||
"SuspensionTravelMetersFrontLeft": unpackedData[48],
|
"SuspensionTravelMetersFrontLeft": unpackedData[49],
|
||||||
"SuspensionTravelMetersFrontRight": unpackedData[49],
|
"SuspensionTravelMetersFrontRight": unpackedData[50],
|
||||||
"SuspensionTravelMetersRearLeft": unpackedData[50],
|
"SuspensionTravelMetersRearLeft": unpackedData[51],
|
||||||
"SuspensionTravelMetersRearRight": unpackedData[51],
|
"SuspensionTravelMetersRearRight": unpackedData[52],
|
||||||
#// Unique ID of the car make/model
|
#// Unique ID of the car make/model
|
||||||
"CarOrdinal": unpackedData[52],
|
"CarOrdinal": unpackedData[53],
|
||||||
#// Between 0 (D -- worst cars) and 7 (X class -- best cars) inclusive
|
#// Between 0 (D -- worst cars) and 7 (X class -- best cars) inclusive
|
||||||
"CarClass": unpackedData[53],
|
"CarClass": unpackedData[54],
|
||||||
#// Between 100 (worst car) and 999 (best car) inclusive
|
#// Between 100 (worst car) and 999 (best car) inclusive
|
||||||
"CarPerformanceIndex": unpackedData[54],
|
"CarPerformanceIndex": unpackedData[55],
|
||||||
#// 0 = FWD, 1 = RWD, 2 = AWD
|
#// 0 = FWD, 1 = RWD, 2 = AWD
|
||||||
"DrivetrainType": unpackedData[55],
|
"DrivetrainType": unpackedData[56],
|
||||||
#// Number of cylinders in the engine
|
#// Number of cylinders in the engine
|
||||||
"NumCylinders": unpackedData[56],
|
"NumCylinders": unpackedData[57],
|
||||||
"PositionX": unpackedData[57],
|
"PositionX": unpackedData[58],
|
||||||
"PositionY": unpackedData[58],
|
"PositionY": unpackedData[59],
|
||||||
"PositionZ": unpackedData[59],
|
"PositionZ": unpackedData[60],
|
||||||
"Speed": unpackedData[60],
|
"Speed": unpackedData[61],
|
||||||
"Power": unpackedData[61],
|
"Power": unpackedData[62],
|
||||||
"Torque": unpackedData[62],
|
"Torque": unpackedData[63],
|
||||||
"TireTempFrontLeft": unpackedData[63],
|
"TireTempFrontLeft": unpackedData[64],
|
||||||
"TireTempFrontRight": unpackedData[64],
|
"TireTempFrontRight": unpackedData[65],
|
||||||
"TireTempRearLeft": unpackedData[65],
|
"TireTempRearLeft": unpackedData[66],
|
||||||
"TireTempRearRight": unpackedData[66],
|
"TireTempRearRight": unpackedData[67],
|
||||||
"Boost": unpackedData[67],
|
"Boost": unpackedData[68],
|
||||||
"Fuel": unpackedData[68],
|
"Fuel": unpackedData[69],
|
||||||
"DistanceTraveled": unpackedData[69],
|
"DistanceTraveled": unpackedData[70],
|
||||||
"BestLap": unpackedData[70],
|
"BestLap": unpackedData[71],
|
||||||
"LastLap": unpackedData[71],
|
"LastLap": unpackedData[72],
|
||||||
"CurrentLap": unpackedData[72],
|
"CurrentLap": unpackedData[73],
|
||||||
"CurrentRaceTime": unpackedData[73],
|
"CurrentRaceTime": unpackedData[74],
|
||||||
"LapNumber": unpackedData[74],
|
"LapNumber": unpackedData[75],
|
||||||
"RacePosition": unpackedData[75],
|
"RacePosition": unpackedData[76],
|
||||||
"Accel": unpackedData[76],
|
"Accel": unpackedData[77],
|
||||||
"Brake": unpackedData[77],
|
"Brake": unpackedData[78],
|
||||||
"Clutch": unpackedData[78],
|
"Clutch": unpackedData[79],
|
||||||
"HandBrake": unpackedData[79],
|
"HandBrake": unpackedData[80],
|
||||||
"Gear": unpackedData[80],
|
"Gear": unpackedData[81],
|
||||||
"Steer": unpackedData[81],
|
"Steer": unpackedData[82],
|
||||||
"NormalizedDrivingLine": unpackedData[82],
|
"NormalizedDrivingLine": unpackedData[83],
|
||||||
"NormalizedAIBrakeDifference": unpackedData[83],
|
"NormalizedAIBrakeDifference": unpackedData[84],
|
||||||
"TireWearFrontLeft": unpackedData[84],
|
"TireWearFrontLeft": unpackedData[85],
|
||||||
"TireWearFrontRight": unpackedData[85],
|
"TireWearFrontRight": unpackedData[86],
|
||||||
"TireWearRearLeft": unpackedData[86],
|
"TireWearRearLeft": unpackedData[87],
|
||||||
"TireWearRearRight": unpackedData[87],
|
"TireWearRearRight": unpackedData[88],
|
||||||
#// ID for track
|
#// ID for track
|
||||||
"TrackOrdinal": unpackedData[88]
|
"TrackOrdinal": unpackedData[89]
|
||||||
}
|
}
|
||||||
return carData
|
return carData
|
||||||
|
|
||||||
data_types = {}
|
|
||||||
with open('data_format.txt', 'r') as f:
|
|
||||||
lines = f.read().split('\n')
|
|
||||||
for line in lines:
|
|
||||||
data_types[line.split()[1]] = line.split()[0]
|
|
||||||
|
|
||||||
|
|
||||||
#assigning sizes in bytes to each variable type
|
|
||||||
jumps={
|
|
||||||
's32': 4, #Signed 32bit int, 4 bytes of size
|
|
||||||
'u32': 4, #Unsigned 32bit int
|
|
||||||
'f32': 4, #Floating point 32bit
|
|
||||||
'u16': 2, #Unsigned 16bit int
|
|
||||||
'u8': 1, #Unsigned 8bit int
|
|
||||||
's8': 1, #Signed 8bit int
|
|
||||||
'hzn': 12 #Unknown, 12 bytes of.. something
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_data(data):
|
|
||||||
return_dict={}
|
|
||||||
|
|
||||||
#additional var
|
|
||||||
passed_data = data
|
|
||||||
|
|
||||||
for i in data_types:
|
|
||||||
d_type = data_types[i]#checks data type (s32, u32 etc.)
|
|
||||||
jump=jumps[d_type]#gets size of data
|
|
||||||
current = passed_data[:jump]#gets data
|
|
||||||
|
|
||||||
decoded = 0
|
|
||||||
#complicated decoding for each type of data
|
|
||||||
if d_type == 's32':
|
|
||||||
decoded = int.from_bytes(current, byteorder='little', signed = True)
|
|
||||||
elif d_type == 'u32':
|
|
||||||
decoded = int.from_bytes(current, byteorder='little', signed=False)
|
|
||||||
elif d_type == 'f32':
|
|
||||||
decoded = struct.unpack('f', current)[0]
|
|
||||||
elif d_type == 'u16':
|
|
||||||
decoded = struct.unpack('H', current)[0]
|
|
||||||
elif d_type == 'u8':
|
|
||||||
decoded = struct.unpack('B', current)[0]
|
|
||||||
elif d_type == 's8':
|
|
||||||
decoded = struct.unpack('b', current)[0]
|
|
||||||
|
|
||||||
#adds decoded data to the dict
|
|
||||||
return_dict[i] = decoded
|
|
||||||
|
|
||||||
|
|
||||||
#removes already read bytes from the variable
|
|
||||||
passed_data = passed_data[jump:]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#returns the dict
|
|
||||||
return return_dict
|
|
||||||
Binary file not shown.
|
|
@ -78,7 +78,7 @@ while True:
|
||||||
unpackedData = struct.unpack(FORZA_METHODS.FORZA_DATA_FORMAT,data)
|
unpackedData = struct.unpack(FORZA_METHODS.FORZA_DATA_FORMAT,data)
|
||||||
carData = FORZA_METHODS.unpackData(unpackedData)
|
carData = FORZA_METHODS.unpackData(unpackedData)
|
||||||
#carData = FORZA_METHODS.get_data(data)
|
#carData = FORZA_METHODS.get_data(data)
|
||||||
kmh = carData["Power"]*3.6
|
kmh = carData["Speed"]*3.6
|
||||||
if csvOut == True:
|
if csvOut == True:
|
||||||
if firstRun == True:
|
if firstRun == True:
|
||||||
out=""
|
out=""
|
||||||
|
|
|
||||||
4337
dataOut.csv
4337
dataOut.csv
File diff suppressed because it is too large
Load diff
|
|
@ -1,85 +0,0 @@
|
||||||
s32 IsRaceOn
|
|
||||||
u32 TimestampMS
|
|
||||||
f32 EngineMaxRpm
|
|
||||||
f32 EngineIdleRpm
|
|
||||||
f32 CurrentEngineRpm
|
|
||||||
f32 AccelerationX
|
|
||||||
f32 AccelerationY
|
|
||||||
f32 AccelerationZ
|
|
||||||
f32 VelocityX
|
|
||||||
f32 VelocityY
|
|
||||||
f32 VelocityZ
|
|
||||||
f32 AngularVelocityX
|
|
||||||
f32 AngularVelocityY
|
|
||||||
f32 AngularVelocityZ
|
|
||||||
f32 Yaw
|
|
||||||
f32 Pitch
|
|
||||||
f32 Roll
|
|
||||||
f32 NormalizedSuspensionTravelFrontLeft
|
|
||||||
f32 NormalizedSuspensionTravelFrontRight
|
|
||||||
f32 NormalizedSuspensionTravelRearLeft
|
|
||||||
f32 NormalizedSuspensionTravelRearRight
|
|
||||||
f32 TireSlipRatioFrontLeft
|
|
||||||
f32 TireSlipRatioFrontRight
|
|
||||||
f32 TireSlipRatioRearLeft
|
|
||||||
f32 TireSlipRatioRearRight
|
|
||||||
f32 WheelRotationSpeedFrontLeft
|
|
||||||
f32 WheelRotationSpeedFrontRight
|
|
||||||
f32 WheelRotationSpeedRearLeft
|
|
||||||
f32 WheelRotationSpeedRearRight
|
|
||||||
s32 WheelOnRumbleStripFrontLeft
|
|
||||||
s32 WheelOnRumbleStripFrontRight
|
|
||||||
s32 WheelOnRumbleStripRearLeft
|
|
||||||
s32 WheelOnRumbleStripRearRight
|
|
||||||
f32 WheelInPuddleDepthFrontLeft
|
|
||||||
f32 WheelInPuddleDepthFrontRight
|
|
||||||
f32 WheelInPuddleDepthRearLeft
|
|
||||||
f32 WheelInPuddleDepthRearRight
|
|
||||||
f32 SurfaceRumbleFrontLeft
|
|
||||||
f32 SurfaceRumbleFrontRight
|
|
||||||
f32 SurfaceRumbleRearLeft
|
|
||||||
f32 SurfaceRumbleRearRight
|
|
||||||
f32 TireSlipAngleFrontLeft
|
|
||||||
f32 TireSlipAngleFrontRight
|
|
||||||
f32 TireSlipAngleRearLeft
|
|
||||||
f32 TireSlipAngleRearRight
|
|
||||||
f32 TireCombinedSlipFrontLeft
|
|
||||||
f32 TireCombinedSlipFrontRight
|
|
||||||
f32 TireCombinedSlipRearLeft
|
|
||||||
f32 TireCombinedSlipRearRight
|
|
||||||
f32 SuspensionTravelMetersFrontLeft
|
|
||||||
f32 SuspensionTravelMetersFrontRight
|
|
||||||
f32 SuspensionTravelMetersRearLeft
|
|
||||||
f32 SuspensionTravelMetersRearRight
|
|
||||||
s32 CarOrdinal
|
|
||||||
s32 CarClass
|
|
||||||
s32 CarPerformanceIndex
|
|
||||||
s32 DrivetrainType
|
|
||||||
s32 NumCylinders
|
|
||||||
f32 PositionX
|
|
||||||
f32 PositionY
|
|
||||||
f32 PositionZ
|
|
||||||
f32 Speed
|
|
||||||
f32 Power
|
|
||||||
f32 Torque
|
|
||||||
f32 TireTempFrontLeft
|
|
||||||
f32 TireTempFrontRight
|
|
||||||
f32 TireTempRearLeft
|
|
||||||
f32 TireTempRearRight
|
|
||||||
f32 Boost
|
|
||||||
f32 Fuel
|
|
||||||
f32 DistanceTraveled
|
|
||||||
f32 BestLap
|
|
||||||
f32 LastLap
|
|
||||||
f32 CurrentLap
|
|
||||||
f32 CurrentRaceTime
|
|
||||||
u16 LapNumber
|
|
||||||
u8 RacePosition
|
|
||||||
u8 Accel
|
|
||||||
u8 Brake
|
|
||||||
u8 Clutch
|
|
||||||
u8 HandBrake
|
|
||||||
u8 Gear
|
|
||||||
s8 Steer
|
|
||||||
s8 NormalizedDrivingLine
|
|
||||||
s8 NormalizedAIBrakeDifference
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue