robocar-throttle/pkg/throttle/processor.go
2022-09-05 16:46:28 +02:00

17 lines
425 B
Go

package throttle
import (
"github.com/cyrilix/robocar-throttle/pkg/types"
"math"
)
type SteeringProcessor struct {
minThrottle, maxThrottle types.Throttle
}
// Process compute throttle from steering value
func (sp *SteeringProcessor) Process(steering float32) types.Throttle {
absSteering := math.Abs(float64(steering))
return sp.minThrottle + types.Throttle(float64(sp.maxThrottle-sp.minThrottle)*(1-absSteering))
}