feat: asymetric throttle
This commit is contained in:
parent
ed1f210a83
commit
973ebb9df9
@ -170,7 +170,16 @@ func (a *Part) processChannel2(v string) {
|
||||
} else if value > a.pwmThrottleConfig.Max {
|
||||
value = a.pwmThrottleConfig.Max
|
||||
}
|
||||
a.throttle = ((float32(value)-MinPwmThrottle)/(MaxPwmThrottle-MinPwmThrottle))*2.0 - 1.0
|
||||
|
||||
throttle := 0.
|
||||
if value > a.pwmThrottleConfig.Zero {
|
||||
throttle = (float64(value) - float64(a.pwmThrottleConfig.Zero)) / float64(a.pwmThrottleConfig.Max-a.pwmThrottleConfig.Zero)
|
||||
}
|
||||
if value < a.pwmThrottleConfig.Zero {
|
||||
throttle = -1. * (float64(a.pwmThrottleConfig.Zero) - float64(value)) / (float64(a.pwmThrottleConfig.Zero - a.pwmThrottleConfig.Min))
|
||||
}
|
||||
|
||||
a.throttle = float32(throttle)
|
||||
}
|
||||
|
||||
func (a *Part) processChannel3(v string) {
|
||||
|
@ -148,7 +148,7 @@ func TestArduinoPart_Update(t *testing.T) {
|
||||
{"Throttle: stop",
|
||||
fmt.Sprintf("12430,%d,%d,%d,%d,%d,%d,50,%d\n", channel1, 1450, channel3, channel4, channel5, channel6, distanceCm),
|
||||
defaultPwmThrottleConfig,
|
||||
-0.03, -1., events.DriveMode_USER, false},
|
||||
0.0, -1., events.DriveMode_USER, false},
|
||||
{"Throttle: up",
|
||||
fmt.Sprintf("12435,%d,%d,%d,%d,%d,%d,50,%d\n", channel1, 1948, channel3, channel4, channel5, channel6, distanceCm),
|
||||
defaultPwmThrottleConfig,
|
||||
@ -157,6 +157,10 @@ func TestArduinoPart_Update(t *testing.T) {
|
||||
fmt.Sprintf("12440,%d,%d,%d,%d,%d,%d,50,%d\n", channel1, 2998, channel3, channel4, channel5, channel6, distanceCm),
|
||||
defaultPwmThrottleConfig,
|
||||
1., -1., events.DriveMode_USER, false},
|
||||
{"Throttle: zero not middle",
|
||||
fmt.Sprintf("12440,%d,%d,%d,%d,%d,%d,50,%d\n", channel1, 1600, channel3, channel4, channel5, channel6, distanceCm),
|
||||
PWMThrottleConfig{1000, 1700, 1500},
|
||||
0.5, -1., events.DriveMode_USER, false},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
|
Loading…
Reference in New Issue
Block a user