|
|
@@ -20,7 +20,6 @@ static throttle_torque_t _throttle;
|
|
|
|
|
|
void throttle_torque_reset(void) {
|
|
|
_throttle.accl = false;
|
|
|
- _throttle.thro_filted = 0.0f;
|
|
|
_throttle.thro_ration = _throttle.thro_ration_last = 0.0f;
|
|
|
_throttle.torque_req = _throttle.torque_real = _throttle.torque_acc_ = 0.0f;
|
|
|
_throttle.gear = mc_get_internal_gear();
|
|
|
@@ -127,7 +126,7 @@ void throttle_force_detect(void) {
|
|
|
}
|
|
|
|
|
|
/* 获取转把电压对应的油门开度 */
|
|
|
-float throttle_vol_to_open_ration(int thro_val) {
|
|
|
+float throttle_vol_to_open_ration(float thro_val) {
|
|
|
if (thro_val <= throttle_start_vol()) {
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -146,9 +145,10 @@ float throttle_get_open_ration(void) {
|
|
|
float throttle_open_ration_to_vol(float r) {
|
|
|
if (r == 0) {
|
|
|
return 0;
|
|
|
+ }else if (r > 1.0f) {
|
|
|
+ r = 1.0f;
|
|
|
}
|
|
|
- float vol = throttle_start_vol() + r * throttle_vol_range();
|
|
|
- return fclamp(vol, 0, throttle_end_vol());
|
|
|
+ return (throttle_start_vol() + r * throttle_vol_range());
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -253,8 +253,9 @@ float throttle_get_open_ration_filted(void) {
|
|
|
#define THRO_RPM_LP_CEOF 0.01f
|
|
|
float throttle_get_torque(mot_contrl_t * ctrl, float vol) {
|
|
|
float thro_r = throttle_vol_to_open_ration(vol);
|
|
|
+ float vel = mot_contrl_get_speed(ctrl);
|
|
|
_throttle.gear = mc_get_internal_gear();
|
|
|
- LowPass_Filter(_throttle.vel_filted, mot_contrl_get_speed(ctrl), THRO_RPM_LP_CEOF);
|
|
|
+ LowPass_Filter(_throttle.vel_filted, vel, THRO_RPM_LP_CEOF);
|
|
|
|
|
|
if (thro_r > _throttle.thro_ration) {
|
|
|
if (!_throttle.accl) {
|
|
|
@@ -345,3 +346,8 @@ float get_user_request_torque(void) {
|
|
|
return throttle_torque_for_decelerate();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+void throttle_log(void) {
|
|
|
+ sys_debug("r:%f, last %f, real:%f, req %f\n", _throttle.thro_ration, _throttle.thro_ration_last, _throttle.torque_real, _throttle.torque_req);
|
|
|
+ sys_debug("thro: %f-%f\n", throttle_start_vol(), throttle_end_vol());
|
|
|
+}
|