debug: unmarshal msg when debug is enabled
This commit is contained in:
parent
f7d2ba12e8
commit
8b79fc58c0
@ -59,7 +59,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer client.Disconnect(50)
|
defer client.Disconnect(50)
|
||||||
|
|
||||||
p := part.NewPart(client, steeringTopic, driveModeTopic, rcSteeringTopic, tfSteeringTopic)
|
p := part.NewPart(client, steeringTopic, driveModeTopic, rcSteeringTopic, tfSteeringTopic, debug)
|
||||||
defer p.Stop()
|
defer p.Stop()
|
||||||
|
|
||||||
cli.HandleExit(p)
|
cli.HandleExit(p)
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewPart(client mqtt.Client, steeringTopic, driveModeTopic, rcSteeringTopic, tfSteeringTopic string) *SteeringPart {
|
func NewPart(client mqtt.Client, steeringTopic, driveModeTopic, rcSteeringTopic, tfSteeringTopic string, debug bool) *SteeringPart {
|
||||||
return &SteeringPart{
|
return &SteeringPart{
|
||||||
client: client,
|
client: client,
|
||||||
steeringTopic: steeringTopic,
|
steeringTopic: steeringTopic,
|
||||||
@ -17,6 +17,7 @@ func NewPart(client mqtt.Client, steeringTopic, driveModeTopic, rcSteeringTopic,
|
|||||||
rcSteeringTopic: rcSteeringTopic,
|
rcSteeringTopic: rcSteeringTopic,
|
||||||
tfSteeringTopic: tfSteeringTopic,
|
tfSteeringTopic: tfSteeringTopic,
|
||||||
driveMode: events.DriveMode_USER,
|
driveMode: events.DriveMode_USER,
|
||||||
|
debug: debug,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -30,6 +31,8 @@ type SteeringPart struct {
|
|||||||
|
|
||||||
cancel chan interface{}
|
cancel chan interface{}
|
||||||
driveModeTopic, rcSteeringTopic, tfSteeringTopic string
|
driveModeTopic, rcSteeringTopic, tfSteeringTopic string
|
||||||
|
|
||||||
|
debug bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *SteeringPart) Start() error {
|
func (p *SteeringPart) Start() error {
|
||||||
@ -64,7 +67,15 @@ func (p *SteeringPart) onDriveMode(_ mqtt.Client, message mqtt.Message) {
|
|||||||
func (p *SteeringPart) onRCSteering(_ mqtt.Client, message mqtt.Message) {
|
func (p *SteeringPart) onRCSteering(_ mqtt.Client, message mqtt.Message) {
|
||||||
p.muDriveMode.RLock()
|
p.muDriveMode.RLock()
|
||||||
defer p.muDriveMode.RUnlock()
|
defer p.muDriveMode.RUnlock()
|
||||||
zap.S().Debugf("receive steering message from radio command: %v",message)
|
if p.debug {
|
||||||
|
var evt events.SteeringMessage
|
||||||
|
err := proto.Unmarshal(message.Payload(), &evt)
|
||||||
|
if err != nil {
|
||||||
|
zap.S().Debugf("unable to unmarshal rc event: %v", err)
|
||||||
|
}else {
|
||||||
|
zap.S().Debugf("receive steering message from radio command: %0.00f", evt.GetSteering())
|
||||||
|
}
|
||||||
|
}
|
||||||
if p.driveMode == events.DriveMode_USER {
|
if p.driveMode == events.DriveMode_USER {
|
||||||
// Republish same content
|
// Republish same content
|
||||||
payload := message.Payload()
|
payload := message.Payload()
|
||||||
@ -74,7 +85,15 @@ func (p *SteeringPart) onRCSteering(_ mqtt.Client, message mqtt.Message) {
|
|||||||
func (p *SteeringPart) onTFSteering(_ mqtt.Client, message mqtt.Message) {
|
func (p *SteeringPart) onTFSteering(_ mqtt.Client, message mqtt.Message) {
|
||||||
p.muDriveMode.RLock()
|
p.muDriveMode.RLock()
|
||||||
defer p.muDriveMode.RUnlock()
|
defer p.muDriveMode.RUnlock()
|
||||||
zap.S().Debugf("receive steering message from tensorflow: %v",message)
|
if p.debug {
|
||||||
|
var evt events.SteeringMessage
|
||||||
|
err := proto.Unmarshal(message.Payload(), &evt)
|
||||||
|
if err != nil {
|
||||||
|
zap.S().Debugf("unable to unmarshal tensorflow event: %v", err)
|
||||||
|
}else {
|
||||||
|
zap.S().Debugf("receive steering message from tensorflow: %0.00f", evt.GetSteering())
|
||||||
|
}
|
||||||
|
}
|
||||||
if p.driveMode == events.DriveMode_PILOT {
|
if p.driveMode == events.DriveMode_PILOT {
|
||||||
// Republish same content
|
// Republish same content
|
||||||
payload := message.Payload()
|
payload := message.Payload()
|
||||||
|
Loading…
Reference in New Issue
Block a user