Skip to content

Commit

Permalink
Fixed a division by zero bug in RPM
Browse files Browse the repository at this point in the history
  • Loading branch information
cercata committed Sep 26, 2023
1 parent 880366e commit 03a0cfa
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
25 changes: 13 additions & 12 deletions sim2bhap/baseBHap.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,20 @@ def runCycle(self):
if hasattr(self, "rpm"):
self.rpmPerc = self.rpm/self.maxRpm
if hasattr(self, "rpmPerc"):
if self.rpmPerc < 1.0:
engineVibration = (self.rpmPerc - self.rpmThreshold) / ((1 - self.rpmThreshold) * 6)
else:
engineVibration = 1.0/6 + ((self.rpmPerc - 1.0) *1) / ((1 - self.rpmThreshold) * 2.5)
if (engineVibration > 0.01):
msg += "RPM {} {}\n".format(engineVibration, self.rpmPerc)
if self.fullArms:
self.play("msfs_vrpm", engineVibration * 0.5, "alt8")
self.play("msfs_arpm", engineVibration * 0.8, "alt7")
self.play("car_frpm", engineVibration , "alt21")
if self.rpmThreshold < 1.0:
if self.rpmPerc < 1.0:
engineVibration = (self.rpmPerc - self.rpmThreshold) / ((1 - self.rpmThreshold) * 6)
else:
self.play("msfs_vrpm", engineVibration, "alt8")
self.play("msfs_arpm", engineVibration * 0.6, "alt7")
engineVibration = 1.0/6 + ((self.rpmPerc - 1.0) *1) / ((1 - self.rpmThreshold) * 2.5)
if (engineVibration > 0.01):
msg += "RPM {} {}\n".format(engineVibration, self.rpmPerc)
if self.fullArms:
self.play("msfs_vrpm", engineVibration * 0.5, "alt8")
self.play("msfs_arpm", engineVibration * 0.8, "alt7")
self.play("car_frpm", engineVibration , "alt21")
else:
self.play("msfs_vrpm", engineVibration, "alt8")
self.play("msfs_arpm", engineVibration * 0.6, "alt7")

if hasattr(self, "g"):
gForceVibration = (self.g - self.gfeThreshold) / 8
Expand Down
2 changes: 1 addition & 1 deletion sim2bhap/car_flfw.tact
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"project":{"category":"","tags":[],"uploader":"8wcyzSadgkcgOm7yqHvWsI0JgXC3","mediaFileDuration":3,"name":"car_vlfw","id":"V2IC8wFdakLrebh3LIo2","media":{"name":"","mediaType":"None","description":"","link":"","updateTime":0,"duration":0},"description":"","tracks":[{"enable":true,"effects":[{"name":"Effect 1","offsetTime":304,"startTime":0,"modes":{"FootL":{"dotMode":{"dotConnected":false,"feedback":[{"startTime":0,"endTime":304,"playbackType":"NONE","pointList":[]}]},"pathMode":{"feedback":[{"movingPattern":"CONST_TDM","playbackType":"FADE_IN_OUT","visible":true,"pointList":[{"intensity":0.6,"time":0,"x":0,"y":0.2041847710399737},{"intensity":0.6,"time":304,"x":0.18234377459281584,"y":0.5399586832724038}]}]},"mode":"PATH_MODE"},"FootR":{"dotMode":{"dotConnected":false,"feedback":[{"startTime":0,"endTime":304,"playbackType":"NONE","pointList":[]}]},"pathMode":{"feedback":[{"movingPattern":"CONST_TDM","playbackType":"FADE_IN_OUT","visible":true,"pointList":[{"intensity":0.5,"time":0,"x":0,"y":0.2041847710399737},{"intensity":0.5,"time":304,"x":0.18234377459281584,"y":0.5399586832724038}]}]},"mode":"PATH_MODE"}}}]},{"enable":true,"effects":[]}],"layout":{"name":"TactosyF","type":"Foot","layouts":{"FootL":[{"index":0,"y":0.5,"x":0},{"index":1,"y":0.5,"x":0.5},{"index":2,"y":0.5,"x":1}],"FootR":[{"index":0,"y":0.5,"x":0},{"index":1,"y":0.5,"x":0.5},{"index":2,"y":0.5,"x":1}]}},"createdAt":1695559236939,"updatedAt":1695559269806},"durationMillis":0,"intervalMillis":20,"size":20}
{"project":{"category":"","tags":[],"uploader":"8wcyzSadgkcgOm7yqHvWsI0JgXC3","mediaFileDuration":3,"name":"wheel_shock_absorber_LEFT_FRONT_C","id":"150fHBbPSoshSRVgBBsS","media":{"name":"","mediaType":"None","description":"","link":"","updateTime":0,"duration":0},"description":"","tracks":[{"enable":true,"effects":[{"name":"Effect 1","offsetTime":304,"startTime":0,"modes":{"FootL":{"dotMode":{"dotConnected":false,"feedback":[{"startTime":0,"endTime":304,"playbackType":"NONE","pointList":[]}]},"pathMode":{"feedback":[{"movingPattern":"CONST_TDM","playbackType":"FADE_IN_OUT","visible":true,"pointList":[{"intensity":0.6,"time":0,"x":0,"y":0.2041847710399737},{"intensity":0.6,"time":304,"x":0.18234377459281584,"y":0.5399586832724038}]}]},"mode":"PATH_MODE"},"FootR":{"dotMode":{"dotConnected":false,"feedback":[{"startTime":0,"endTime":304,"playbackType":"NONE","pointList":[]}]},"pathMode":{"feedback":[{"movingPattern":"CONST_TDM","playbackType":"FADE_IN_OUT","visible":true,"pointList":[{"intensity":0.4,"time":0,"x":0,"y":0.2041847710399737},{"intensity":0.4,"time":304,"x":0.18234377459281584,"y":0.5399586832724038}]}]},"mode":"PATH_MODE"}}}]},{"enable":true,"effects":[]}],"layout":{"name":"TactosyF","type":"Foot","layouts":{"FootL":[{"index":0,"y":0.5,"x":0},{"index":1,"y":0.5,"x":0.5},{"index":2,"y":0.5,"x":1}],"FootR":[{"index":0,"y":0.5,"x":0},{"index":1,"y":0.5,"x":0.5},{"index":2,"y":0.5,"x":1}]}},"createdAt":1695720349669,"updatedAt":1695720422841},"durationMillis":0,"intervalMillis":20,"size":20}
2 changes: 1 addition & 1 deletion sim2bhap/car_flrw.tact
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"project":{"category":"","tags":[],"uploader":"8wcyzSadgkcgOm7yqHvWsI0JgXC3","mediaFileDuration":3,"name":"car_vlrw","id":"dAGszVX2GoJVAu7uslaM","media":{"name":"","mediaType":"None","description":"","link":"","updateTime":0,"duration":0},"description":"","tracks":[{"enable":true,"effects":[{"name":"Effect 1","offsetTime":304,"startTime":0,"modes":{"FootL":{"dotMode":{"dotConnected":false,"feedback":[{"startTime":0,"endTime":304,"playbackType":"NONE","pointList":[]}]},"pathMode":{"feedback":[{"movingPattern":"CONST_TDM","playbackType":"FADE_IN_OUT","visible":true,"pointList":[{"intensity":0.6,"time":0,"x":0,"y":0.7958152289600263},{"intensity":0.6,"time":304,"x":0.1823437745928158,"y":0.4600413167275962}]}]},"mode":"PATH_MODE"},"FootR":{"dotMode":{"dotConnected":false,"feedback":[{"startTime":0,"endTime":304,"playbackType":"NONE","pointList":[]}]},"pathMode":{"feedback":[{"movingPattern":"CONST_TDM","playbackType":"FADE_IN_OUT","visible":true,"pointList":[{"intensity":0.5,"time":0,"x":0,"y":0.7958152289600263},{"intensity":0.5,"time":304,"x":0.1823437745928158,"y":0.4600413167275962}]}]},"mode":"PATH_MODE"}}}]},{"enable":true,"effects":[]}],"layout":{"name":"TactosyF","type":"Foot","layouts":{"FootL":[{"index":0,"y":0.5,"x":0},{"index":1,"y":0.5,"x":0.5},{"index":2,"y":0.5,"x":1}],"FootR":[{"index":0,"y":0.5,"x":0},{"index":1,"y":0.5,"x":0.5},{"index":2,"y":0.5,"x":1}]}},"createdAt":1695559236932,"updatedAt":1695559288476},"durationMillis":0,"intervalMillis":20,"size":20}
{"project":{"category":"","tags":[],"uploader":"8wcyzSadgkcgOm7yqHvWsI0JgXC3","mediaFileDuration":3,"name":"wheel_shock_absorber_LEFT_BACK_C","id":"uqDsYuc3nJWmRJTs2XPX","media":{"name":"","mediaType":"None","description":"","link":"","updateTime":0,"duration":0},"description":"","tracks":[{"enable":true,"effects":[{"name":"Effect 1","offsetTime":304,"startTime":0,"modes":{"FootL":{"dotMode":{"dotConnected":false,"feedback":[{"startTime":0,"endTime":304,"playbackType":"NONE","pointList":[]}]},"pathMode":{"feedback":[{"movingPattern":"CONST_TDM","playbackType":"FADE_IN_OUT","visible":true,"pointList":[{"intensity":0.6,"time":0,"x":0,"y":0.7958152289600263},{"intensity":0.6,"time":304,"x":0.1823437745928158,"y":0.4600413167275962}]}]},"mode":"PATH_MODE"},"FootR":{"dotMode":{"dotConnected":false,"feedback":[{"startTime":0,"endTime":304,"playbackType":"NONE","pointList":[]}]},"pathMode":{"feedback":[{"movingPattern":"CONST_TDM","playbackType":"FADE_IN_OUT","visible":true,"pointList":[{"intensity":0.4,"time":0,"x":0,"y":0.7958152289600263},{"intensity":0.4,"time":304,"x":0.1823437745928158,"y":0.4600413167275962}]}]},"mode":"PATH_MODE"}}}]},{"enable":true,"effects":[]}],"layout":{"name":"TactosyF","type":"Foot","layouts":{"FootL":[{"index":0,"y":0.5,"x":0},{"index":1,"y":0.5,"x":0.5},{"index":2,"y":0.5,"x":1}],"FootR":[{"index":0,"y":0.5,"x":0},{"index":1,"y":0.5,"x":0.5},{"index":2,"y":0.5,"x":1}]}},"createdAt":1695720350250,"updatedAt":1695720434375},"durationMillis":0,"intervalMillis":20,"size":20}
2 changes: 1 addition & 1 deletion sim2bhap/car_frfw.tact
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"project":{"category":"","tags":[],"uploader":"8wcyzSadgkcgOm7yqHvWsI0JgXC3","mediaFileDuration":3,"name":"car_vrfw","id":"8NXtsn6XqI2pkpNawpVb","media":{"name":"","mediaType":"None","description":"","link":"","updateTime":0,"duration":0},"description":"","tracks":[{"enable":true,"effects":[{"name":"Effect 1","offsetTime":304,"startTime":0,"modes":{"FootL":{"dotMode":{"dotConnected":false,"feedback":[{"startTime":0,"endTime":304,"playbackType":"NONE","pointList":[]}]},"pathMode":{"feedback":[{"movingPattern":"CONST_TDM","playbackType":"FADE_IN_OUT","visible":true,"pointList":[{"intensity":0.5,"time":0,"x":1,"y":0.2041847710399737},{"intensity":0.5,"time":304,"x":0.8176562254071842,"y":0.5399586832724038}]}]},"mode":"PATH_MODE"},"FootR":{"dotMode":{"dotConnected":false,"feedback":[{"startTime":0,"endTime":304,"playbackType":"NONE","pointList":[]}]},"pathMode":{"feedback":[{"movingPattern":"CONST_TDM","playbackType":"FADE_IN_OUT","visible":true,"pointList":[{"intensity":0.6,"time":0,"x":1,"y":0.2041847710399737},{"intensity":0.6,"time":304,"x":0.8176562254071842,"y":0.5399586832724038}]}]},"mode":"PATH_MODE"}}}]},{"enable":true,"effects":[]}],"layout":{"name":"TactosyF","type":"Foot","layouts":{"FootL":[{"index":0,"y":0.5,"x":0},{"index":1,"y":0.5,"x":0.5},{"index":2,"y":0.5,"x":1}],"FootR":[{"index":0,"y":0.5,"x":0},{"index":1,"y":0.5,"x":0.5},{"index":2,"y":0.5,"x":1}]}},"createdAt":1695559236928,"updatedAt":1695559297616},"durationMillis":0,"intervalMillis":20,"size":20}
{"project":{"category":"","tags":[],"uploader":"8wcyzSadgkcgOm7yqHvWsI0JgXC3","mediaFileDuration":3,"name":"wheel_shock_absorber_RIGHT_FRONT_C","id":"2IRrAwTvh8V9f2zCkwtq","media":{"name":"","mediaType":"None","description":"","link":"","updateTime":0,"duration":0},"description":"","tracks":[{"enable":true,"effects":[{"name":"Effect 1","offsetTime":304,"startTime":0,"modes":{"FootL":{"dotMode":{"dotConnected":false,"feedback":[{"startTime":0,"endTime":304,"playbackType":"NONE","pointList":[]}]},"pathMode":{"feedback":[{"movingPattern":"CONST_TDM","playbackType":"FADE_IN_OUT","visible":true,"pointList":[{"intensity":0.4,"time":0,"x":1,"y":0.2041847710399737},{"intensity":0.4,"time":304,"x":0.8176562254071842,"y":0.5399586832724038}]}]},"mode":"PATH_MODE"},"FootR":{"dotMode":{"dotConnected":false,"feedback":[{"startTime":0,"endTime":304,"playbackType":"NONE","pointList":[]}]},"pathMode":{"feedback":[{"movingPattern":"CONST_TDM","playbackType":"FADE_IN_OUT","visible":true,"pointList":[{"intensity":0.6,"time":0,"x":1,"y":0.2041847710399737},{"intensity":0.6,"time":304,"x":0.8176562254071842,"y":0.5399586832724038}]}]},"mode":"PATH_MODE"}}}]},{"enable":true,"effects":[]}],"layout":{"name":"TactosyF","type":"Foot","layouts":{"FootL":[{"index":0,"y":0.5,"x":0},{"index":1,"y":0.5,"x":0.5},{"index":2,"y":0.5,"x":1}],"FootR":[{"index":0,"y":0.5,"x":0},{"index":1,"y":0.5,"x":0.5},{"index":2,"y":0.5,"x":1}]}},"createdAt":1695720349656,"updatedAt":1695720450526},"durationMillis":0,"intervalMillis":20,"size":20}
2 changes: 1 addition & 1 deletion sim2bhap/car_frrw.tact
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"project":{"category":"","tags":[],"uploader":"8wcyzSadgkcgOm7yqHvWsI0JgXC3","mediaFileDuration":3,"name":"car_vrrw","id":"6TNP5PSXKBlSjG8MaM4o","media":{"name":"","mediaType":"None","description":"","link":"","updateTime":0,"duration":0},"description":"","tracks":[{"enable":true,"effects":[{"name":"Effect 1","offsetTime":304,"startTime":0,"modes":{"FootL":{"dotMode":{"dotConnected":false,"feedback":[{"startTime":0,"endTime":304,"playbackType":"NONE","pointList":[]}]},"pathMode":{"feedback":[{"movingPattern":"CONST_TDM","playbackType":"FADE_IN_OUT","visible":true,"pointList":[{"intensity":0.5,"time":0,"x":1,"y":0.7958152289600263},{"intensity":0.5,"time":304,"x":0.8176562254071842,"y":0.4600413167275962}]}]},"mode":"PATH_MODE"},"FootR":{"dotMode":{"dotConnected":false,"feedback":[{"startTime":0,"endTime":304,"playbackType":"NONE","pointList":[]}]},"pathMode":{"feedback":[{"movingPattern":"CONST_TDM","playbackType":"FADE_IN_OUT","visible":true,"pointList":[{"intensity":0.6,"time":0,"x":1,"y":0.7958152289600263},{"intensity":0.6,"time":304,"x":0.8176562254071842,"y":0.4600413167275962}]}]},"mode":"PATH_MODE"}}}]},{"enable":true,"effects":[]}],"layout":{"name":"TactosyF","type":"Foot","layouts":{"FootL":[{"index":0,"y":0.5,"x":0},{"index":1,"y":0.5,"x":0.5},{"index":2,"y":0.5,"x":1}],"FootR":[{"index":0,"y":0.5,"x":0},{"index":1,"y":0.5,"x":0.5},{"index":2,"y":0.5,"x":1}]}},"createdAt":1695559236944,"updatedAt":1695559256225},"durationMillis":0,"intervalMillis":20,"size":20}
{"project":{"category":"","tags":[],"uploader":"8wcyzSadgkcgOm7yqHvWsI0JgXC3","mediaFileDuration":3,"name":"wheel_shock_absorber_RIGHT_BACK_C","id":"RfUZULBBqjph92RjEzVt","media":{"name":"","mediaType":"None","description":"","link":"","updateTime":0,"duration":0},"description":"","tracks":[{"enable":true,"effects":[{"name":"Effect 1","offsetTime":304,"startTime":0,"modes":{"FootL":{"dotMode":{"dotConnected":false,"feedback":[{"startTime":0,"endTime":304,"playbackType":"NONE","pointList":[]}]},"pathMode":{"feedback":[{"movingPattern":"CONST_TDM","playbackType":"FADE_IN_OUT","visible":true,"pointList":[{"intensity":0.4,"time":0,"x":1,"y":0.7958152289600263},{"intensity":0.4,"time":304,"x":0.8176562254071842,"y":0.4600413167275962}]}]},"mode":"PATH_MODE"},"FootR":{"dotMode":{"dotConnected":false,"feedback":[{"startTime":0,"endTime":304,"playbackType":"NONE","pointList":[]}]},"pathMode":{"feedback":[{"movingPattern":"CONST_TDM","playbackType":"FADE_IN_OUT","visible":true,"pointList":[{"intensity":0.6,"time":0,"x":1,"y":0.7958152289600263},{"intensity":0.6,"time":304,"x":0.8176562254071842,"y":0.4600413167275962}]}]},"mode":"PATH_MODE"}}}]},{"enable":true,"effects":[]}],"layout":{"name":"TactosyF","type":"Foot","layouts":{"FootL":[{"index":0,"y":0.5,"x":0},{"index":1,"y":0.5,"x":0.5},{"index":2,"y":0.5,"x":1}],"FootR":[{"index":0,"y":0.5,"x":0},{"index":1,"y":0.5,"x":0.5},{"index":2,"y":0.5,"x":1}]}},"createdAt":1695720349599,"updatedAt":1695720457186},"durationMillis":0,"intervalMillis":20,"size":20}

0 comments on commit 03a0cfa

Please sign in to comment.