feat: implement copilot drive mode

This commit is contained in:
2023-10-15 11:33:10 +02:00
parent 993cfaa9d4
commit fb20ef0d06
6 changed files with 24 additions and 11 deletions

View File

@ -287,7 +287,12 @@ func (a *Part) processChannel6(v string) {
// No value, ignore it
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 {
zap.S().Infof("Update channel 6 'drive-mode' with value %v, new user_mode: %v", value, events.DriveMode_PILOT)
a.driveMode = events.DriveMode_PILOT

View File

@ -118,6 +118,10 @@ func TestArduinoPart_Update(t *testing.T) {
{"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),
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),
defaultPwmThrottleConfig, -1., -1., events.DriveMode_USER, false},