Fix car integration

This commit is contained in:
2020-02-03 19:16:07 +01:00
parent dca1c25f11
commit 932e447cf1
3 changed files with 6 additions and 17 deletions

View File

@ -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)
}