@@ -712,9 +712,16 @@ void fs_ai_api_ai2vcu_set_data(fs_ai_api_ai2vcu *data) {
712
712
float t_AI2VCU_FRONT_BRAKE_PRESS_REQUEST_pct = 0 ;
713
713
float t_AI2VCU_REAR_BRAKE_PRESS_REQUEST_pct = 0 ;
714
714
715
- float t_FRONT_AXLE_TORQUE_MAX = (0.1f * VCU2AI_FRONT_AXLE_TORQUE_MAX_raw );
716
- float t_REAR_AXLE_TORQUE_MAX = (0.1f * VCU2AI_REAR_AXLE_TORQUE_MAX_raw );
717
- float t_STEER_ANGLE_MAX = (0.1f * VCU2AI_STEER_ANGLE_MAX_raw );
715
+ float t_FRONT_AXLE_TORQUE_MAX_Nm = (0.1f * VCU2AI_FRONT_AXLE_TORQUE_MAX_raw );
716
+ float t_REAR_AXLE_TORQUE_MAX_Nm = (0.1f * VCU2AI_REAR_AXLE_TORQUE_MAX_raw );
717
+ float t_STEER_ANGLE_MAX_deg = (0.1f * VCU2AI_STEER_ANGLE_MAX_raw );
718
+
719
+ uint16_t t_fastest_wheel_rpm = 0 ;
720
+
721
+ if (VCU2AI_FL_WHEEL_SPEED_rpm > t_fastest_wheel_rpm ) { t_fastest_wheel_rpm = VCU2AI_FL_WHEEL_SPEED_rpm ; }
722
+ if (VCU2AI_FR_WHEEL_SPEED_rpm > t_fastest_wheel_rpm ) { t_fastest_wheel_rpm = VCU2AI_FR_WHEEL_SPEED_rpm ; }
723
+ if (VCU2AI_RL_WHEEL_SPEED_rpm > t_fastest_wheel_rpm ) { t_fastest_wheel_rpm = VCU2AI_RL_WHEEL_SPEED_rpm ; }
724
+ if (VCU2AI_RR_WHEEL_SPEED_rpm > t_fastest_wheel_rpm ) { t_fastest_wheel_rpm = VCU2AI_RR_WHEEL_SPEED_rpm ; }
718
725
719
726
t_AI2VCU_MISSION_STATUS = data -> AI2VCU_MISSION_STATUS ;
720
727
t_AI2VCU_DIRECTION_REQUEST = data -> AI2VCU_DIRECTION_REQUEST ;
@@ -728,20 +735,38 @@ void fs_ai_api_ai2vcu_set_data(fs_ai_api_ai2vcu *data) {
728
735
t_AI2VCU_FRONT_BRAKE_PRESS_REQUEST_pct = data -> AI2VCU_BRAKE_PRESS_REQUEST_pct ;
729
736
t_AI2VCU_REAR_BRAKE_PRESS_REQUEST_pct = data -> AI2VCU_BRAKE_PRESS_REQUEST_pct ;
730
737
738
+ // additional torque limit to maintain constant electrical power and minimise risk of over-current trip
739
+ if (t_fastest_wheel_rpm > 700 ) {
740
+ if (t_FRONT_AXLE_TORQUE_MAX_Nm > 50.0f ) { t_FRONT_AXLE_TORQUE_MAX_Nm = 50.0f ; }
741
+ if (t_REAR_AXLE_TORQUE_MAX_Nm > 50.0f ) { t_REAR_AXLE_TORQUE_MAX_Nm = 50.0f ; }
742
+ } else if (t_fastest_wheel_rpm > 600 ) {
743
+ if (t_FRONT_AXLE_TORQUE_MAX_Nm > 85.0f ) { t_FRONT_AXLE_TORQUE_MAX_Nm = 85.0f ; }
744
+ if (t_REAR_AXLE_TORQUE_MAX_Nm > 85.0f ) { t_REAR_AXLE_TORQUE_MAX_Nm = 85.0f ; }
745
+ } else if (t_fastest_wheel_rpm > 500 ) {
746
+ if (t_FRONT_AXLE_TORQUE_MAX_Nm > 100.0f ) { t_FRONT_AXLE_TORQUE_MAX_Nm = 100.0f ; }
747
+ if (t_REAR_AXLE_TORQUE_MAX_Nm > 100.0f ) { t_REAR_AXLE_TORQUE_MAX_Nm = 100.0f ; }
748
+ } else if (t_fastest_wheel_rpm > 400 ) {
749
+ if (t_FRONT_AXLE_TORQUE_MAX_Nm > 120.0f ) { t_FRONT_AXLE_TORQUE_MAX_Nm = 120.0f ; }
750
+ if (t_REAR_AXLE_TORQUE_MAX_Nm > 120.0f ) { t_REAR_AXLE_TORQUE_MAX_Nm = 120.0f ; }
751
+ } else if (t_fastest_wheel_rpm > 300 ) {
752
+ if (t_FRONT_AXLE_TORQUE_MAX_Nm > 150.0f ) { t_FRONT_AXLE_TORQUE_MAX_Nm = 150.0f ; }
753
+ if (t_REAR_AXLE_TORQUE_MAX_Nm > 150.0f ) { t_REAR_AXLE_TORQUE_MAX_Nm = 150.0f ; }
754
+ }
755
+
731
756
// validate the 'float' requests
732
- if (t_AI2VCU_STEER_ANGLE_REQUEST_deg > t_STEER_ANGLE_MAX ) { t_AI2VCU_STEER_ANGLE_REQUEST_deg = t_STEER_ANGLE_MAX ; }
733
- if (t_AI2VCU_STEER_ANGLE_REQUEST_deg < (-1.0f * t_STEER_ANGLE_MAX )) { t_AI2VCU_STEER_ANGLE_REQUEST_deg = (-1.0f * t_STEER_ANGLE_MAX ); }
757
+ if (t_AI2VCU_STEER_ANGLE_REQUEST_deg > t_STEER_ANGLE_MAX_deg ) { t_AI2VCU_STEER_ANGLE_REQUEST_deg = t_STEER_ANGLE_MAX_deg ; }
758
+ if (t_AI2VCU_STEER_ANGLE_REQUEST_deg < (-1.0f * t_STEER_ANGLE_MAX_deg )) { t_AI2VCU_STEER_ANGLE_REQUEST_deg = (-1.0f * t_STEER_ANGLE_MAX_deg ); }
734
759
735
760
if (t_AI2VCU_FRONT_MOTOR_SPEED_REQUEST_rpm > MOTOR_MAX_RPM ) { t_AI2VCU_FRONT_MOTOR_SPEED_REQUEST_rpm = MOTOR_MAX_RPM ; }
736
761
if (t_AI2VCU_FRONT_MOTOR_SPEED_REQUEST_rpm < 0.0f ) { t_AI2VCU_FRONT_MOTOR_SPEED_REQUEST_rpm = 0.0f ; }
737
762
738
763
if (t_AI2VCU_REAR_MOTOR_SPEED_REQUEST_rpm > MOTOR_MAX_RPM ) { t_AI2VCU_REAR_MOTOR_SPEED_REQUEST_rpm = MOTOR_MAX_RPM ; }
739
764
if (t_AI2VCU_REAR_MOTOR_SPEED_REQUEST_rpm < 0.0f ) { t_AI2VCU_REAR_MOTOR_SPEED_REQUEST_rpm = 0.0f ; }
740
765
741
- if (t_AI2VCU_FRONT_AXLE_TORQUE_REQUEST_Nm > t_FRONT_AXLE_TORQUE_MAX ) { t_AI2VCU_FRONT_AXLE_TORQUE_REQUEST_Nm = t_FRONT_AXLE_TORQUE_MAX ; }
766
+ if (t_AI2VCU_FRONT_AXLE_TORQUE_REQUEST_Nm > t_FRONT_AXLE_TORQUE_MAX_Nm ) { t_AI2VCU_FRONT_AXLE_TORQUE_REQUEST_Nm = t_FRONT_AXLE_TORQUE_MAX_Nm ; }
742
767
if (t_AI2VCU_FRONT_AXLE_TORQUE_REQUEST_Nm < 0.0f ) { t_AI2VCU_FRONT_AXLE_TORQUE_REQUEST_Nm = 0.0f ; }
743
768
744
- if (t_AI2VCU_REAR_AXLE_TORQUE_REQUEST_Nm > t_REAR_AXLE_TORQUE_MAX ) { t_AI2VCU_REAR_AXLE_TORQUE_REQUEST_Nm = t_REAR_AXLE_TORQUE_MAX ; }
769
+ if (t_AI2VCU_REAR_AXLE_TORQUE_REQUEST_Nm > t_REAR_AXLE_TORQUE_MAX_Nm ) { t_AI2VCU_REAR_AXLE_TORQUE_REQUEST_Nm = t_REAR_AXLE_TORQUE_MAX_Nm ; }
745
770
if (t_AI2VCU_REAR_AXLE_TORQUE_REQUEST_Nm < 0.0f ) { t_AI2VCU_REAR_AXLE_TORQUE_REQUEST_Nm = 0.0f ; }
746
771
747
772
if (t_AI2VCU_FRONT_BRAKE_PRESS_REQUEST_pct > 100.0f ) { t_AI2VCU_FRONT_BRAKE_PRESS_REQUEST_pct = 100.0f ; }
0 commit comments