@@ -11,6 +11,7 @@ use crate::OcypodeError;
1111use super :: { SessionInfo , TelemetryPoint , TireInfo } ;
1212
1313const CONN_RETRY_WAIT_MS : u64 = 200 ;
14+ const MAX_STEERING_ANGLE_DEFAULT : f32 = std:: f32:: consts:: PI ;
1415pub ( crate ) const CONN_RETRY_MAX_WAIT_S : u64 = 600 ;
1516
1617pub trait SimplifiedTelemetryAccess {
@@ -187,7 +188,6 @@ impl TelemetryProducer for IRacingTelemetryProducer {
187188 description : "Could not retrieve telemetry" ,
188189 }
189190 } ) ?;
190-
191191 Ok ( SessionInfo {
192192 track_name : ir_session_info. weekend . track_name ,
193193 max_steering_angle : telemetry. get_float ( "SteeringWheelAngleMax" ) . unwrap_or ( 0. ) ,
@@ -212,6 +212,15 @@ impl TelemetryProducer for IRacingTelemetryProducer {
212212 }
213213 } ) ?;
214214
215+ let steering_pct = if telemetry. get_float ( "SteeringWheelAngle" ) . unwrap_or ( 0. )
216+ > MAX_STEERING_ANGLE_DEFAULT
217+ {
218+ telemetry. get_float ( "SteeringWheelAngle" ) . unwrap_or ( 0. )
219+ / telemetry. get_float ( "SteeringWheelAngleMax" ) . unwrap_or ( 0. )
220+ } else {
221+ telemetry. get_float ( "SteeringWheelAngle" ) . unwrap_or ( 0. ) / MAX_STEERING_ANGLE_DEFAULT
222+ } ;
223+
215224 let measurement = TelemetryPoint {
216225 point_no : self . point_no ,
217226 lap_dist : telemetry. get_float ( "LapDist" ) . unwrap_or ( 0. ) ,
@@ -226,6 +235,8 @@ impl TelemetryProducer for IRacingTelemetryProducer {
226235 throttle : telemetry. get_float ( "Throttle" ) . unwrap_or ( 0. ) ,
227236 brake : telemetry. get_float ( "BrakeRaw" ) . unwrap_or ( 0. ) ,
228237 steering : telemetry. get_float ( "SteeringWheelAngle" ) . unwrap_or ( 0. ) ,
238+ // this might result in an unhappy division by 0. Do we want to panic in this case because it's unexpected?
239+ steering_pct,
229240 abs_active : telemetry. get_bool ( "BrakeABSactive" ) . unwrap_or ( false ) ,
230241 lat : telemetry. get_float ( "Lat" ) . unwrap_or ( 0. ) ,
231242 lon : telemetry. get_float ( "Lon" ) . unwrap_or ( 0. ) ,
0 commit comments