Fix car integration
This commit is contained in:
parent
dca1c25f11
commit
932e447cf1
@ -34,11 +34,11 @@ func (s *Steering) SetPercentValue(p float32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewSteering(channel, leftPWM, rightPWM int) *Steering {
|
func NewSteering(channel, leftPWM, rightPWM int) *Steering {
|
||||||
t := Steering{
|
s := Steering{
|
||||||
channel: channel,
|
channel: channel,
|
||||||
dev: device,
|
dev: device,
|
||||||
leftPWM: leftPWM,
|
leftPWM: leftPWM,
|
||||||
rightPWM: rightPWM,
|
rightPWM: rightPWM,
|
||||||
}
|
}
|
||||||
return &t
|
return &s
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ func NewThrottle(channel, zeroPulse, minPulse, maxPulse int) *Throttle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("send zero pulse to calibrate ESC")
|
log.Infof("send zero pulse to calibrate ESC")
|
||||||
t.SetPulse(zeroPulse)
|
t.SetPercentValue(0)
|
||||||
|
|
||||||
return &t
|
return &t
|
||||||
}
|
}
|
||||||
|
17
part/part.go
17
part/part.go
@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Pca9685Part struct {
|
type Pca9685Part struct {
|
||||||
@ -46,12 +45,12 @@ func (p *Pca9685Part) Start() error {
|
|||||||
if err := p.registerCallbacks(); err != nil {
|
if err := p.registerCallbacks(); err != nil {
|
||||||
return fmt.Errorf("unable to start service: %v", err)
|
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 {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
|
||||||
p.updateCtrl()
|
|
||||||
case <-p.cancel:
|
case <-p.cancel:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -101,13 +100,3 @@ func (p *Pca9685Part) registerCallbacks() error {
|
|||||||
|
|
||||||
return nil
|
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)
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user