feat: implement copilot drive mode
This commit is contained in:
parent
993cfaa9d4
commit
fb20ef0d06
2
go.mod
2
go.mod
@ -4,7 +4,7 @@ go 1.21
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/cyrilix/robocar-base v0.1.8
|
github.com/cyrilix/robocar-base v0.1.8
|
||||||
github.com/cyrilix/robocar-protobuf/go v1.3.1
|
github.com/cyrilix/robocar-protobuf/go v1.4.0
|
||||||
github.com/eclipse/paho.mqtt.golang v1.4.3
|
github.com/eclipse/paho.mqtt.golang v1.4.3
|
||||||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07
|
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07
|
||||||
go.uber.org/zap v1.25.0
|
go.uber.org/zap v1.25.0
|
||||||
|
4
go.sum
4
go.sum
@ -2,8 +2,8 @@ github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT
|
|||||||
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||||
github.com/cyrilix/robocar-base v0.1.8 h1:9hfH9rCcyGXR0dtESIhI9tCrK9juq+dSnJXCxCF2LVw=
|
github.com/cyrilix/robocar-base v0.1.8 h1:9hfH9rCcyGXR0dtESIhI9tCrK9juq+dSnJXCxCF2LVw=
|
||||||
github.com/cyrilix/robocar-base v0.1.8/go.mod h1:oJnfYjoz2PX16BD8I8LJ14kRQt1zbFb7XaUHtUEZgjg=
|
github.com/cyrilix/robocar-base v0.1.8/go.mod h1:oJnfYjoz2PX16BD8I8LJ14kRQt1zbFb7XaUHtUEZgjg=
|
||||||
github.com/cyrilix/robocar-protobuf/go v1.3.1 h1:SSKf2g3H7V0PBaecowk6GuWLHhDlMQbo6q6PlgJcZsA=
|
github.com/cyrilix/robocar-protobuf/go v1.4.0 h1:ZMN2zjn2iplsbHoBrjiI7d3HdNutWUB+NcVDh2mFcqM=
|
||||||
github.com/cyrilix/robocar-protobuf/go v1.3.1/go.mod h1:69ZGmxS2JufIxGZPEKvAMZj5b1fVMVG3QTyFlCCHGtg=
|
github.com/cyrilix/robocar-protobuf/go v1.4.0/go.mod h1:69ZGmxS2JufIxGZPEKvAMZj5b1fVMVG3QTyFlCCHGtg=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/eclipse/paho.mqtt.golang v1.4.3 h1:2kwcUGn8seMUfWndX0hGbvH8r7crgcJguQNCyp70xik=
|
github.com/eclipse/paho.mqtt.golang v1.4.3 h1:2kwcUGn8seMUfWndX0hGbvH8r7crgcJguQNCyp70xik=
|
||||||
|
@ -287,7 +287,12 @@ func (a *Part) processChannel6(v string) {
|
|||||||
// No value, ignore it
|
// No value, ignore it
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if value > 1800 {
|
if value <= 1800 && value > 1200 {
|
||||||
|
if a.driveMode != events.DriveMode_COPILOT {
|
||||||
|
zap.S().Infof("Update channel 6 'drive-mode' with value %v, new user_mode: %v", value, events.DriveMode_PILOT)
|
||||||
|
a.driveMode = events.DriveMode_COPILOT
|
||||||
|
}
|
||||||
|
} else if value > 1800 {
|
||||||
if a.driveMode != events.DriveMode_PILOT {
|
if a.driveMode != events.DriveMode_PILOT {
|
||||||
zap.S().Infof("Update channel 6 'drive-mode' with value %v, new user_mode: %v", value, events.DriveMode_PILOT)
|
zap.S().Infof("Update channel 6 'drive-mode' with value %v, new user_mode: %v", value, events.DriveMode_PILOT)
|
||||||
a.driveMode = events.DriveMode_PILOT
|
a.driveMode = events.DriveMode_PILOT
|
||||||
|
@ -118,6 +118,10 @@ func TestArduinoPart_Update(t *testing.T) {
|
|||||||
{"DriveMode: user",
|
{"DriveMode: user",
|
||||||
fmt.Sprintf("12390,%d,%d,%d,%d,%d,%d,%d,%d,%d,50\n", channel1, channel2, channel3, channel4, channel5, 1003, channel7, channel8, channel9),
|
fmt.Sprintf("12390,%d,%d,%d,%d,%d,%d,%d,%d,%d,50\n", channel1, channel2, channel3, channel4, channel5, 1003, channel7, channel8, channel9),
|
||||||
defaultPwmThrottleConfig, -1., -1., events.DriveMode_USER, false},
|
defaultPwmThrottleConfig, -1., -1., events.DriveMode_USER, false},
|
||||||
|
// DriveMode: copilot
|
||||||
|
{"DriveMode: copilot",
|
||||||
|
fmt.Sprintf("12390,%d,%d,%d,%d,%d,%d,%d,%d,%d,50\n", channel1, channel2, channel3, channel4, channel5, 1250, channel7, channel8, channel9),
|
||||||
|
defaultPwmThrottleConfig, -1., -1., events.DriveMode_COPILOT, false},
|
||||||
|
|
||||||
{"Sterring: over left", fmt.Sprintf("12395,%d,%d,%d,%d,%d,%d,%d,%d,%d,50\n", 99, channel2, channel3, channel4, channel5, channel6, channel7, channel8, channel9),
|
{"Sterring: over left", fmt.Sprintf("12395,%d,%d,%d,%d,%d,%d,%d,%d,%d,50\n", 99, channel2, channel3, channel4, channel5, channel6, channel7, channel8, channel9),
|
||||||
defaultPwmThrottleConfig, -1., -1., events.DriveMode_USER, false},
|
defaultPwmThrottleConfig, -1., -1., events.DriveMode_USER, false},
|
||||||
|
16
vendor/github.com/cyrilix/robocar-protobuf/go/events/events.pb.go
generated
vendored
16
vendor/github.com/cyrilix/robocar-protobuf/go/events/events.pb.go
generated
vendored
@ -79,6 +79,7 @@ const (
|
|||||||
DriveMode_INVALID DriveMode = 0
|
DriveMode_INVALID DriveMode = 0
|
||||||
DriveMode_USER DriveMode = 1
|
DriveMode_USER DriveMode = 1
|
||||||
DriveMode_PILOT DriveMode = 2
|
DriveMode_PILOT DriveMode = 2
|
||||||
|
DriveMode_COPILOT DriveMode = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enum value maps for DriveMode.
|
// Enum value maps for DriveMode.
|
||||||
@ -87,11 +88,13 @@ var (
|
|||||||
0: "INVALID",
|
0: "INVALID",
|
||||||
1: "USER",
|
1: "USER",
|
||||||
2: "PILOT",
|
2: "PILOT",
|
||||||
|
3: "COPILOT",
|
||||||
}
|
}
|
||||||
DriveMode_value = map[string]int32{
|
DriveMode_value = map[string]int32{
|
||||||
"INVALID": 0,
|
"INVALID": 0,
|
||||||
"USER": 1,
|
"USER": 1,
|
||||||
"PILOT": 2,
|
"PILOT": 2,
|
||||||
|
"COPILOT": 3,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1114,14 +1117,15 @@ var file_events_events_proto_rawDesc = []byte{
|
|||||||
0x38, 0x0a, 0x09, 0x53, 0x70, 0x65, 0x65, 0x64, 0x5a, 0x6f, 0x6e, 0x65, 0x12, 0x0b, 0x0a, 0x07,
|
0x38, 0x0a, 0x09, 0x53, 0x70, 0x65, 0x65, 0x64, 0x5a, 0x6f, 0x6e, 0x65, 0x12, 0x0b, 0x0a, 0x07,
|
||||||
0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x4c, 0x4f,
|
0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x4c, 0x4f,
|
||||||
0x57, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x10, 0x02, 0x12,
|
0x57, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x10, 0x02, 0x12,
|
||||||
0x08, 0x0a, 0x04, 0x46, 0x41, 0x53, 0x54, 0x10, 0x03, 0x2a, 0x2d, 0x0a, 0x09, 0x44, 0x72, 0x69,
|
0x08, 0x0a, 0x04, 0x46, 0x41, 0x53, 0x54, 0x10, 0x03, 0x2a, 0x3a, 0x0a, 0x09, 0x44, 0x72, 0x69,
|
||||||
0x76, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49,
|
0x76, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49,
|
||||||
0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x55, 0x53, 0x45, 0x52, 0x10, 0x01, 0x12, 0x09, 0x0a,
|
0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x55, 0x53, 0x45, 0x52, 0x10, 0x01, 0x12, 0x09, 0x0a,
|
||||||
0x05, 0x50, 0x49, 0x4c, 0x4f, 0x54, 0x10, 0x02, 0x2a, 0x32, 0x0a, 0x0a, 0x54, 0x79, 0x70, 0x65,
|
0x05, 0x50, 0x49, 0x4c, 0x4f, 0x54, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x4f, 0x50, 0x49,
|
||||||
0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4e, 0x59, 0x10, 0x00, 0x12,
|
0x4c, 0x4f, 0x54, 0x10, 0x03, 0x2a, 0x32, 0x0a, 0x0a, 0x54, 0x79, 0x70, 0x65, 0x4f, 0x62, 0x6a,
|
||||||
0x07, 0x0a, 0x03, 0x43, 0x41, 0x52, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x42, 0x55, 0x4d, 0x50,
|
0x65, 0x63, 0x74, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4e, 0x59, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03,
|
||||||
0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x50, 0x4c, 0x4f, 0x54, 0x10, 0x03, 0x42, 0x0a, 0x5a, 0x08,
|
0x43, 0x41, 0x52, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x42, 0x55, 0x4d, 0x50, 0x10, 0x02, 0x12,
|
||||||
0x2e, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x08, 0x0a, 0x04, 0x50, 0x4c, 0x4f, 0x54, 0x10, 0x03, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x65,
|
||||||
|
0x76, 0x65, 0x6e, 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -2,7 +2,7 @@
|
|||||||
## explicit; go 1.21
|
## explicit; go 1.21
|
||||||
github.com/cyrilix/robocar-base/cli
|
github.com/cyrilix/robocar-base/cli
|
||||||
github.com/cyrilix/robocar-base/service
|
github.com/cyrilix/robocar-base/service
|
||||||
# github.com/cyrilix/robocar-protobuf/go v1.3.1
|
# github.com/cyrilix/robocar-protobuf/go v1.4.0
|
||||||
## explicit; go 1.21
|
## explicit; go 1.21
|
||||||
github.com/cyrilix/robocar-protobuf/go/events
|
github.com/cyrilix/robocar-protobuf/go/events
|
||||||
# github.com/eclipse/paho.mqtt.golang v1.4.3
|
# github.com/eclipse/paho.mqtt.golang v1.4.3
|
||||||
|
Loading…
Reference in New Issue
Block a user