-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancements and New Features #32
Open
GustavoBitten
wants to merge
6
commits into
snipem:main
Choose a base branch
from
GustavoBitten:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
from datetime import timedelta | ||
import json | ||
import struct | ||
|
||
|
||
class GTData: | ||
def __init__(self, ddata): | ||
if not ddata: | ||
ddata = bytearray(0x124 + 4) | ||
|
||
self.package_id = struct.unpack('i', ddata[0x70:0x70 + 4])[0] | ||
self.best_lap = struct.unpack('i', ddata[0x78:0x78 + 4])[0] | ||
self.last_lap = struct.unpack('i', ddata[0x7C:0x7C + 4])[0] | ||
self.current_lap = struct.unpack('h', ddata[0x74:0x74 + 2])[0] | ||
self.current_gear = struct.unpack('B', ddata[0x90:0x90 + 1])[0] & 0b00001111 | ||
self.suggested_gear = struct.unpack('B', ddata[0x90:0x90 + 1])[0] >> 4 | ||
self.fuel_capacity = struct.unpack('f', ddata[0x48:0x48 + 4])[0] | ||
self.current_fuel = struct.unpack('f', ddata[0x44:0x44 + 4])[0] # fuel | ||
self.boost = struct.unpack('f', ddata[0x50:0x50 + 4])[0] - 1 | ||
|
||
self.tyre_diameter_FL = struct.unpack('f', ddata[0xB4:0xB4 + 4])[0] | ||
self.tyre_diameter_FR = struct.unpack('f', ddata[0xB8:0xB8 + 4])[0] | ||
self.tyre_diameter_RL = struct.unpack('f', ddata[0xBC:0xBC + 4])[0] | ||
self.tyre_diameter_RR = struct.unpack('f', ddata[0xC0:0xC0 + 4])[0] | ||
|
||
self.type_speed_FL = abs(3.6 * self.tyre_diameter_FL * struct.unpack('f', ddata[0xA4:0xA4 + 4])[0]) | ||
self.type_speed_FR = abs(3.6 * self.tyre_diameter_FR * struct.unpack('f', ddata[0xA8:0xA8 + 4])[0]) | ||
self.type_speed_RL = abs(3.6 * self.tyre_diameter_RL * struct.unpack('f', ddata[0xAC:0xAC + 4])[0]) | ||
self.tyre_speed_RR = abs(3.6 * self.tyre_diameter_RR * struct.unpack('f', ddata[0xB0:0xB0 + 4])[0]) | ||
|
||
self.car_speed = 3.6 * struct.unpack('f', ddata[0x4C:0x4C + 4])[0] | ||
|
||
self.tyre_slip_ratio_FL = 0 | ||
self.tyre_slip_ratio_FR = 0 | ||
self.tyre_slip_ratio_RL = 0 | ||
self.tyre_slip_ratio_RR = 0 | ||
|
||
if self.car_speed > 0: | ||
self.tyre_slip_ratio_FL = '{:6.2f}'.format(self.type_speed_FL / self.car_speed) | ||
self.tyre_slip_ratio_FR = '{:6.2f}'.format(self.type_speed_FR / self.car_speed) | ||
self.tyre_slip_ratio_RL = '{:6.2f}'.format(self.type_speed_RL / self.car_speed) | ||
self.tyre_slip_ratio_RR = '{:6.2f}'.format(self.tyre_speed_RR / self.car_speed) | ||
|
||
self.time_on_track = timedelta( | ||
seconds=round(struct.unpack('i', ddata[0x80:0x80 + 4])[0] / 1000)) # time of day on track | ||
|
||
self.total_laps = struct.unpack('h', ddata[0x76:0x76 + 2])[0] # total laps | ||
|
||
self.current_position = struct.unpack('h', ddata[0x84:0x84 + 2])[0] # current position | ||
self.total_positions = struct.unpack('h', ddata[0x86:0x86 + 2])[0] # total positions | ||
|
||
self.car_id = struct.unpack('i', ddata[0x124:0x124 + 4])[0] # car id | ||
|
||
self.throttle = struct.unpack('B', ddata[0x91:0x91 + 1])[0] / 2.55 # throttle | ||
self.rpm = struct.unpack('f', ddata[0x3C:0x3C + 4])[0] # rpm | ||
self.rpm_rev_warning = struct.unpack('H', ddata[0x88:0x88 + 2])[0] # rpm rev warning | ||
|
||
self.brake = struct.unpack('B', ddata[0x92:0x92 + 1])[0] / 2.55 # brake | ||
|
||
self.boost = struct.unpack('f', ddata[0x50:0x50 + 4])[0] - 1 # boost | ||
|
||
self.rpm_rev_limiter = struct.unpack('H', ddata[0x8A:0x8A + 2])[0] # rpm rev limiter | ||
|
||
self.estimated_top_speed = struct.unpack('h', ddata[0x8C:0x8C + 2])[0] # estimated top speed | ||
|
||
self.clutch = struct.unpack('f', ddata[0xF4:0xF4 + 4])[0] # clutch | ||
self.clutch_engaged = struct.unpack('f', ddata[0xF8:0xF8 + 4])[0] # clutch engaged | ||
self.rpm_after_clutch = struct.unpack('f', ddata[0xFC:0xFC + 4])[0] # rpm after clutch | ||
|
||
self.oil_temp = struct.unpack('f', ddata[0x5C:0x5C + 4])[0] # oil temp | ||
self.water_temp = struct.unpack('f', ddata[0x58:0x58 + 4])[0] # water temp | ||
|
||
self.oil_pressure = struct.unpack('f', ddata[0x54:0x54 + 4])[0] # oil pressure | ||
self.ride_height = 1000 * struct.unpack('f', ddata[0x38:0x38 + 4])[0] # ride height | ||
|
||
self.tyre_temp_FL = struct.unpack('f', ddata[0x60:0x60 + 4])[0] # tyre temp FL | ||
self.tyre_temp_FR = struct.unpack('f', ddata[0x64:0x64 + 4])[0] # tyre temp FR | ||
|
||
self.suspension_fl = struct.unpack('f', ddata[0xC4:0xC4 + 4])[0] # suspension FL | ||
self.suspension_fr = struct.unpack('f', ddata[0xC8:0xC8 + 4])[0] # suspension FR | ||
|
||
self.tyre_temp_rl = struct.unpack('f', ddata[0x68:0x68 + 4])[0] # tyre temp RL | ||
self.tyre_temp_rr = struct.unpack('f', ddata[0x6C:0x6C + 4])[0] # tyre temp RR | ||
|
||
self.suspension_rl = struct.unpack('f', ddata[0xCC:0xCC + 4])[0] # suspension RL | ||
self.suspension_rr = struct.unpack('f', ddata[0xD0:0xD0 + 4])[0] # suspension RR | ||
|
||
self.gear_1 = struct.unpack('f', ddata[0x104:0x104 + 4])[0] # 1st gear | ||
self.gear_2 = struct.unpack('f', ddata[0x108:0x108 + 4])[0] # 2nd gear | ||
self.gear_3 = struct.unpack('f', ddata[0x10C:0x10C + 4])[0] # 3rd gear | ||
self.gear_4 = struct.unpack('f', ddata[0x110:0x110 + 4])[0] # 4th gear | ||
self.gear_5 = struct.unpack('f', ddata[0x114:0x114 + 4])[0] # 5th gear | ||
self.gear_6 = struct.unpack('f', ddata[0x118:0x118 + 4])[0] # 6th gear | ||
self.gear_7 = struct.unpack('f', ddata[0x11C:0x11C + 4])[0] # 7th gear | ||
self.gear_8 = struct.unpack('f', ddata[0x120:0x120 + 4])[0] # 8th gear | ||
|
||
# self.struct.unpack('f', ddata[0x100:0x100+4])[0] # ??? gear | ||
|
||
self.position_x = struct.unpack('f', ddata[0x04:0x04 + 4])[0] # pos X | ||
self.position_y = struct.unpack('f', ddata[0x08:0x08 + 4])[0] # pos Y | ||
self.position_z = struct.unpack('f', ddata[0x0C:0x0C + 4])[0] # pos Z | ||
|
||
self.velocity_x = struct.unpack('f', ddata[0x10:0x10 + 4])[0] # velocity X | ||
self.velocity_y = struct.unpack('f', ddata[0x14:0x14 + 4])[0] # velocity Y | ||
self.velocity_z = struct.unpack('f', ddata[0x18:0x18 + 4])[0] # velocity Z | ||
|
||
self.rotation_pitch = struct.unpack('f', ddata[0x1C:0x1C + 4])[0] # rot Pitch | ||
self.rotation_yaw = struct.unpack('f', ddata[0x20:0x20 + 4])[0] # rot Yaw | ||
self.rotation_roll = struct.unpack('f', ddata[0x24:0x24 + 4])[0] # rot Roll | ||
|
||
self.angular_velocity_x = struct.unpack('f', ddata[0x2C:0x2C + 4])[0] # angular velocity X | ||
self.angular_velocity_y = struct.unpack('f', ddata[0x30:0x30 + 4])[0] # angular velocity Y | ||
self.angular_velocity_z = struct.unpack('f', ddata[0x34:0x34 + 4])[0] # angular velocity Z | ||
|
||
self.is_paused = bin(struct.unpack('B', ddata[0x8E:0x8E + 1])[0])[-2] == '1' | ||
self.in_race = bin(struct.unpack('B', ddata[0x8E:0x8E + 1])[0])[-1] == '1' | ||
|
||
# struct.unpack('f', ddata[0x28:0x28+4])[0] # rot ??? | ||
|
||
# bin(struct.unpack('B', ddata[0x8E:0x8E+1])[0])[2:] # various flags (see https://github.com/Nenkai/PDTools/blob/master/PDTools.SimulatorInterface/SimulatorPacketG7S0.cs) | ||
# bin(struct.unpack('B', ddata[0x8F:0x8F+1])[0])[2:] # various flags (see https://github.com/Nenkai/PDTools/blob/master/PDTools.SimulatorInterface/SimulatorPacketG7S0.cs) | ||
# bin(struct.unpack('B', ddata[0x93:0x93+1])[0])[2:] # 0x93 = ??? | ||
|
||
# struct.unpack('f', ddata[0x94:0x94+4])[0] # 0x94 = ??? | ||
# struct.unpack('f', ddata[0x98:0x98+4])[0] # 0x98 = ??? | ||
# struct.unpack('f', ddata[0x9C:0x9C+4])[0] # 0x9C = ??? | ||
# struct.unpack('f', ddata[0xA0:0xA0+4])[0] # 0xA0 = ??? | ||
|
||
# struct.unpack('f', ddata[0xD4:0xD4+4])[0] # 0xD4 = ??? | ||
# struct.unpack('f', ddata[0xD8:0xD8+4])[0] # 0xD8 = ??? | ||
# struct.unpack('f', ddata[0xDC:0xDC+4])[0] # 0xDC = ??? | ||
# struct.unpack('f', ddata[0xE0:0xE0+4])[0] # 0xE0 = ??? | ||
|
||
# struct.unpack('f', ddata[0xE4:0xE4+4])[0] # 0xE4 = ??? | ||
# struct.unpack('f', ddata[0xE8:0xE8+4])[0] # 0xE8 = ??? | ||
# struct.unpack('f', ddata[0xEC:0xEC+4])[0] # 0xEC = ??? | ||
# struct.unpack('f', ddata[0xF0:0xF0+4])[0] # 0xF0 = ??? | ||
|
||
def to_json(self): | ||
return json.dumps(self, indent=4, sort_keys=True, default=str) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import bokeh | ||
from bokeh.layouts import layout | ||
from bokeh.models import ColumnDataSource, Label, Scatter, Column, Line, TableColumn, DataTable, Range1d | ||
from bokeh.models import ColumnDataSource, Label, Scatter, Column, Line, TableColumn, DataTable, Range1d, WheelZoomTool, PanTool | ||
from bokeh.plotting import figure | ||
|
||
from gt7dashboard import gt7helper | ||
|
@@ -39,6 +39,7 @@ def get_throttle_braking_race_line_diagram(): | |
data={"raceline_z_throttle": [], "raceline_x_throttle": []} | ||
), | ||
) | ||
|
||
breaking_line = s_race_line.line( | ||
x="raceline_x_braking", | ||
y="raceline_z_braking", | ||
|
@@ -185,6 +186,8 @@ def __init__(self, width=400): | |
# This is the number of default laps, | ||
# last lap, best lap and median lap | ||
self.number_of_default_laps = 3 | ||
self.wheel_zoom_x = WheelZoomTool(dimensions='width') | ||
self.x_pan = PanTool(dimensions='width') | ||
|
||
|
||
tooltips = [ | ||
|
@@ -220,8 +223,11 @@ def __init__(self, width=400): | |
width=width, | ||
height=250, | ||
tooltips=tooltips, | ||
active_drag="box_zoom", | ||
active_drag="auto" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this change in behaviour? |
||
) | ||
self.f_speed.add_tools(self.wheel_zoom_x,self.x_pan) | ||
self.f_speed.toolbar.active_scroll = self.wheel_zoom_x | ||
self.f_speed.toolbar.active_drag = self.x_pan | ||
|
||
self.f_speed_variance = figure( | ||
y_axis_label="Spd.Dev.", | ||
|
@@ -230,8 +236,11 @@ def __init__(self, width=400): | |
width=width, | ||
height=int(self.f_speed.height / 4), | ||
tooltips=self.tooltips_speed_variance, | ||
active_drag="box_zoom", | ||
active_drag="auto", | ||
) | ||
self.f_speed_variance.add_tools(self.wheel_zoom_x,self.x_pan) | ||
self.f_speed_variance.toolbar.active_scroll = self.wheel_zoom_x | ||
self.f_speed_variance.toolbar.active_drag = self.x_pan | ||
|
||
self.f_time_diff = figure( | ||
title="Time Diff - Last, Reference", | ||
|
@@ -240,79 +249,107 @@ def __init__(self, width=400): | |
width=width, | ||
height=int(self.f_speed.height / 2), | ||
tooltips=tooltips_timedelta, | ||
active_drag="box_zoom", | ||
active_drag="auto" | ||
) | ||
self.f_time_diff.add_tools(self.wheel_zoom_x,self.x_pan) | ||
self.f_time_diff.toolbar.active_scroll = self.wheel_zoom_x | ||
self.f_time_diff.toolbar.active_drag = self.x_pan | ||
|
||
self.f_throttle = figure( | ||
x_range=self.f_speed.x_range, | ||
y_axis_label="Throttle", | ||
width=width, | ||
height=int(self.f_speed.height / 2), | ||
tooltips=tooltips, | ||
active_drag="box_zoom", | ||
active_drag="auto" | ||
) | ||
self.f_throttle.add_tools(self.wheel_zoom_x,self.x_pan) | ||
self.f_throttle.toolbar.active_scroll = self.wheel_zoom_x | ||
self.f_throttle.toolbar.active_drag = self.x_pan | ||
|
||
self.f_braking = figure( | ||
x_range=self.f_speed.x_range, | ||
y_axis_label="Braking", | ||
width=width, | ||
height=int(self.f_speed.height / 2), | ||
tooltips=tooltips, | ||
active_drag="box_zoom", | ||
active_drag="auto" | ||
) | ||
self.f_braking.add_tools(self.wheel_zoom_x,self.x_pan) | ||
self.f_braking.toolbar.active_scroll = self.wheel_zoom_x | ||
self.f_braking.toolbar.active_drag = self.x_pan | ||
|
||
self.f_coasting = figure( | ||
x_range=self.f_speed.x_range, | ||
y_axis_label="Coasting", | ||
width=width, | ||
height=int(self.f_speed.height / 2), | ||
tooltips=tooltips, | ||
active_drag="box_zoom", | ||
active_drag="auto", | ||
) | ||
self.f_coasting.add_tools(self.wheel_zoom_x,self.x_pan) | ||
self.f_coasting.toolbar.active_scroll = self.wheel_zoom_x | ||
self.f_coasting.toolbar.active_drag = self.x_pan | ||
|
||
self.f_tires = figure( | ||
x_range=self.f_speed.x_range, | ||
y_axis_label="Tire Spd / Car Spd", | ||
width=width, | ||
height=int(self.f_speed.height / 2), | ||
tooltips=tooltips, | ||
active_drag="box_zoom", | ||
active_drag="auto", | ||
) | ||
self.f_tires.add_tools(self.wheel_zoom_x,self.x_pan) | ||
self.f_tires.toolbar.active_scroll = self.wheel_zoom_x | ||
self.f_tires.toolbar.active_drag = self.x_pan | ||
|
||
self.f_rpm = figure( | ||
x_range=self.f_speed.x_range, | ||
y_axis_label="RPM", | ||
width=width, | ||
height=int(self.f_speed.height / 2), | ||
tooltips=tooltips, | ||
active_drag="box_zoom", | ||
active_drag="auto", | ||
) | ||
self.f_rpm.add_tools(self.wheel_zoom_x,self.x_pan) | ||
self.f_rpm.toolbar.active_scroll = self.wheel_zoom_x | ||
self.f_rpm.toolbar.active_drag = self.x_pan | ||
|
||
self.f_gear = figure( | ||
x_range=self.f_speed.x_range, | ||
y_axis_label="Gear", | ||
width=width, | ||
height=int(self.f_speed.height / 2), | ||
tooltips=tooltips, | ||
active_drag="box_zoom", | ||
active_drag="auto", | ||
) | ||
self.f_gear.add_tools(self.wheel_zoom_x,self.x_pan) | ||
self.f_gear.toolbar.active_scroll = self.wheel_zoom_x | ||
self.f_gear.toolbar.active_drag = self.x_pan | ||
|
||
self.f_boost = figure( | ||
x_range=self.f_speed.x_range, | ||
y_axis_label="Boost", | ||
width=width, | ||
height=int(self.f_speed.height / 2), | ||
tooltips=tooltips, | ||
active_drag="box_zoom", | ||
active_drag="auto", | ||
) | ||
self.f_boost.add_tools(self.wheel_zoom_x,self.x_pan) | ||
self.f_boost.toolbar.active_scroll = self.wheel_zoom_x | ||
self.f_boost.toolbar.active_drag = self.x_pan | ||
|
||
self.f_yaw_rate = figure( | ||
x_range=self.f_speed.x_range, | ||
y_axis_label="Yaw Rate / Second", | ||
width=width, | ||
height=int(self.f_speed.height / 2), | ||
tooltips=tooltips, | ||
active_drag="box_zoom", | ||
active_drag="auto", | ||
) | ||
self.f_yaw_rate.add_tools(self.wheel_zoom_x,self.x_pan) | ||
self.f_yaw_rate.toolbar.active_scroll = self.wheel_zoom_x | ||
self.f_yaw_rate.toolbar.active_drag = self.x_pan | ||
|
||
self.f_speed.toolbar.autohide = True | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect this is just reorganised to a different file?