Skip to content

Commit

Permalink
Merge pull request #5 from GeekyDeaks/feature-gt7-port
Browse files Browse the repository at this point in the history
Feature gt7 port
  • Loading branch information
GeekyDeaks authored May 31, 2023
2 parents 021502c + fb3e078 commit 9dc0f99
Show file tree
Hide file tree
Showing 11 changed files with 221 additions and 63 deletions.
1 change: 1 addition & 0 deletions ams2.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
}

sg.change_look_and_feel('Default1')
sg.set_options(font="Arial 12")

BUTTON_DISABLED = (sg.theme_background_color(), sg.theme_background_color())
BUTTON_ENABLED = (sg.theme_button_color_text(), sg.theme_background_color())
Expand Down
2 changes: 2 additions & 0 deletions gt7-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def main():
parser.add_argument("--session", type=str, default="", help="Session e.g. Practice, Qualify, Race")
parser.add_argument("--vehicle", type=str, default="", help="Override name of vehicle")
parser.add_argument("--venue", type=str, default="", help="Venue/Track name, MoTeC will not generate a track map without this")
parser.add_argument("--replay", action="store_true", help="log replay telemetry")
parser.add_argument("--freq", type=int, default=60, help="frequency to collect samples, currently ignored")
parser.add_argument("--saveraw", help="save raw samples to an sqlite3 db for later analysis", action="store_true")
parser.add_argument("--loadraw", help="load raw samples from an sqlite3 db", action="store_true")
Expand All @@ -41,6 +42,7 @@ def main():
rawfile=rawfile,
sampler=sampler,
filetemplate=filetemplate,
replay=args.replay,
driver=args.driver,
session=args.session,
vehicle=args.vehicle,
Expand Down
27 changes: 20 additions & 7 deletions gt7.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,30 @@
# try and load the sate
STATE_FILE = "gt7.cfg"

state = {
"IP": "192.168.1.100",
"PORT": 33740,
"REPLAY": False,
"DRIVER": "",
"SESSION": ""
}

try:
with open(STATE_FILE) as f:
state = json.load(f)
state.update(json.load(f))
except Exception as e:
state = {
"IP": "192.168.1.100",
"DRIVER": "",
"SESSION": ""
}
pass

sg.change_look_and_feel('Default1')
sg.set_options(font="Arial 12")

BUTTON_DISABLED = (sg.theme_background_color(), sg.theme_background_color())
BUTTON_ENABLED = (sg.theme_button_color_text(), sg.theme_background_color())

labels = [
[sg.Text("PS IP Address")],
[sg.Text("Local UDP Port")],
[sg.Text("Capture Replays")],
[sg.Text("Driver")],
[sg.Text("Session")],
[sg.Text("Log File")],
Expand All @@ -38,6 +45,8 @@

values = [
[sg.Input(state["IP"], key="IP", size=(15,1), enable_events=True)],
[sg.Input(state["PORT"], key="PORT", size=(15,1), enable_events=True), sg.Text("Only change this if using a UDP relay", font="arial 12 italic")],
[sg.Checkbox("", state["REPLAY"], key="REPLAY", enable_events=True)],
[sg.Input(state["DRIVER"], key="DRIVER", size=(15,1), enable_events=True )],
[sg.Input(state["SESSION"], key="SESSION", size=(15,1), enable_events=True )],
[sg.Text("Not Started",key="LOGFILE" )],
Expand Down Expand Up @@ -82,6 +91,9 @@
if event == "IP" and len(values['IP']) and values['IP'][-1] not in ('.1234567890'):
window["IP"].update(values['IP'][:-1])

if event == "PORT" and len(values['PORT']) and values['PORT'][-1] not in ('1234567890'):
window["PORT"].update(values['PORT'][:-1])

if event in state:
state[event] = values[event]

Expand All @@ -95,8 +107,9 @@

logger = GT7Logger(
rawfile=rawfile,
sampler=GT7Sampler(addr=values['IP'], freq=60),
sampler=GT7Sampler(addr=values["IP"], port=values["PORT"], freq=60),
filetemplate=filetemplate,
replay=values["REPLAY"],
driver=values["DRIVER"],
session=values["SESSION"]
)
Expand Down
14 changes: 12 additions & 2 deletions stm/ams2/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ class AMS2Logger(BaseLogger):
'throttle', 'brake', 'steer', 'speed',
'lat', 'long',
'glat', 'gvert', 'glong', # g forces
'suspfl', 'suspfr', 'susprl', 'susprr', # suspension
'suspfl', 'suspfr', 'susprl', 'susprr', # suspension travel
'suspvelfl', 'suspvelfr', 'suspvelrl', 'suspvelrr', # suspension velocity
'tyretempfl', 'tyretempfr', 'tyretemprl', 'tyretemprr', # combined tyre temp
'braketempfl', 'braketempfr', 'braketemprl', 'braketemprr', # brake temp
'tyretempflo', 'tyretempfro', # outer temp
'tyretempflc', 'tyretempfrc', # center temp
'tyretempfli', 'tyretempfri', # inner temp
#'wheelslipfl', 'wheelslipfr', 'wheelsliprl', 'wheelsliprr', # wheel slip
'rideheightfl', 'rideheightfr', 'rideheightrl', 'rideheightrr',
'tyrepresfl', 'tyrepresfr', 'tyrepresrl', 'tyrepresrr', # mAirPressure
'turbopres',
'brakebias',
'enginetorque',
'lap', 'laptime',
'racestate', # AMS2 race status
]
Expand Down Expand Up @@ -102,14 +107,19 @@ def process_packet(self, timestamp, p, lastp):
glat,
gvert,
-glong,
*p.mSuspensionTravel,
*[sp * 100 for sp in p.mSuspensionTravel],
*p.mSuspensionVelocity,
*p.mTyreTemp,
*p.mBrakeTempCelsius,
p.mTyreTempLeft.fl, p.mTyreTempRight.fr, # outer
p.mTyreTempCenter.fl, p.mTyreTempCenter.fr, # centre
p.mTyreTempRight.fl, p.mTyreTempLeft.fr, # inner
#*[s * 2.23693629 for s in p.mTyreSlipSpeed], # wheel slip m/s -> mph
*p.mRideHeight,
*p.mAirPressure,
p.mTurboBoostPressure,
p.mBrakeBias,
p.mEngineTorque,
p.driver.mCurrentLap,
p.mCurrentTime,
p.mRaceState.value,
Expand Down
7 changes: 5 additions & 2 deletions stm/ams2/shmem.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ class AMS2SharedMemory:
"i" # mSequenceNumber
"16x" # mWheelLocalPositionY
"4f" # mSuspensionTravel
"16x" # mSuspensionVelocity
"4f" # mSuspensionVelocity
"4f" # mAirPressure
"4x" # mEngineSpeed
"4x" # mEngineTorque
"f" # mEngineTorque
"2f" # mWings
"4x" # mHandBrake
"256x" # mCurrentSector1Times
Expand Down Expand Up @@ -248,7 +248,9 @@ def __init__(self, buf):
btfl, btfr, btrl, btrr, # mBrakeTempCelsius
self.mSequenceNumber,
stfl, stfr, strl, sttrr, # mSuspensionTravel
svfl, svfr, svrl, svrr, # mSuspensionVelocity
apfl, apfr, aprl, aprr, # mAirPressure,
self.mEngineTorque,
wf, wr, # mWings
mTranslatedTrackLocation,
mTranslatedTrackVariation,
Expand Down Expand Up @@ -279,6 +281,7 @@ def __init__(self, buf):
self.mTyreTemp = Wheels(ttfl, ttfr, ttrl, ttrr)
self.mBrakeTempCelsius = Wheels(btfl, btfr, btrl, btrr)
self.mSuspensionTravel = Wheels(stfl, stfr, strl, sttrr)
self.mSuspensionVelocity = Wheels(svfl, svfr, svrl, svrr)
self.mAirPressure = Wheels(apfl, apfr, aprl, aprr)
self.mWings = Wings(wf, wr)
self.mTyreTempLeft = Wheels(ttlfl, ttlfr, ttlrl, ttlrr)
Expand Down
Loading

0 comments on commit 9dc0f99

Please sign in to comment.