diff --git a/actuator/steering.go b/actuator/steering.go index de7cebd..90e43b3 100644 --- a/actuator/steering.go +++ b/actuator/steering.go @@ -34,11 +34,11 @@ func (s *Steering) SetPercentValue(p float32) { } func NewSteering(channel, leftPWM, rightPWM int) *Steering { - t := Steering{ + s := Steering{ channel: channel, dev: device, leftPWM: leftPWM, rightPWM: rightPWM, } - return &t + return &s } diff --git a/actuator/throttle.go b/actuator/throttle.go index 9a5cf43..b747be1 100644 --- a/actuator/throttle.go +++ b/actuator/throttle.go @@ -48,7 +48,7 @@ func NewThrottle(channel, zeroPulse, minPulse, maxPulse int) *Throttle { } log.Infof("send zero pulse to calibrate ESC") - t.SetPulse(zeroPulse) + t.SetPercentValue(0) return &t } diff --git a/part/part.go b/part/part.go index e1733b8..944344c 100644 --- a/part/part.go +++ b/part/part.go @@ -9,7 +9,6 @@ import ( "github.com/golang/protobuf/proto" log "github.com/sirupsen/logrus" "sync" - "time" ) type Pca9685Part struct { @@ -46,12 +45,12 @@ func (p *Pca9685Part) Start() error { if err := p.registerCallbacks(); err != nil { return fmt.Errorf("unable to start service: %v", err) } - ticker := time.NewTicker(time.Second / time.Duration(p.updateFrequency)) + + p.steeringCtrl.SetPercentValue(0) + p.throttleCtrl.SetPercentValue(0) for { select { - case <-ticker.C: - p.updateCtrl() case <-p.cancel: return nil } @@ -101,13 +100,3 @@ func (p *Pca9685Part) registerCallbacks() error { return nil } - -func (p *Pca9685Part) updateCtrl() { - p.muThrottle.Lock() - defer p.muThrottle.Unlock() - p.throttleCtrl.SetPercentValue(p.throttleValue) - - p.muSteering.Lock() - defer p.muSteering.Unlock() - p.steeringCtrl.SetPercentValue(p.steeringValue) -}