From bf1e41ed73a414793e41a1d8e1a2c5795503ef70 Mon Sep 17 00:00:00 2001 From: Matthias Mueller Date: Thu, 15 Apr 2021 20:06:21 +0200 Subject: [PATCH 1/4] fix AI fragment navigation --- android/app/src/main/java/org/openbot/main/MainFragment.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/android/app/src/main/java/org/openbot/main/MainFragment.java b/android/app/src/main/java/org/openbot/main/MainFragment.java index fd5971c15..8b8034e6a 100644 --- a/android/app/src/main/java/org/openbot/main/MainFragment.java +++ b/android/app/src/main/java/org/openbot/main/MainFragment.java @@ -61,19 +61,23 @@ public void onItemClick(SubCategory subCategory) { case FeatureList.DATA_COLLECTION: Navigation.findNavController(requireView()) .navigate(R.id.action_mainFragment_to_loggerFragment); + break; case FeatureList.CONTROLLER: // For a library module, uncomment the following line // intent = new Intent(this, ControllerActivity.class); // startActivity(intent); break; + case FeatureList.AI_MODELS: Navigation.findNavController(requireView()) .navigate(R.id.action_mainFragment_to_AIFragment); + break; case FeatureList.CONTROLLER_MAPPING: Navigation.findNavController(requireView()) .navigate(R.id.action_mainFragment_to_controllerMappingFragment); + break; } } } From 42a8db10235c654235df18318205e8585631721e Mon Sep 17 00:00:00 2001 From: Matthias Mueller Date: Thu, 15 Apr 2021 20:07:24 +0200 Subject: [PATCH 2/4] add missing control handling --- .../main/java/org/openbot/ai/AIFragment.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/android/app/src/main/java/org/openbot/ai/AIFragment.java b/android/app/src/main/java/org/openbot/ai/AIFragment.java index 3046e65a8..4454a864c 100644 --- a/android/app/src/main/java/org/openbot/ai/AIFragment.java +++ b/android/app/src/main/java/org/openbot/ai/AIFragment.java @@ -445,6 +445,24 @@ protected void processControllerKeyData(String commandType) { String.format(Locale.US, "%.0f,%.0f", vehicle.getLeftSpeed(), vehicle.getRightSpeed())); break; + case Constants.CMD_DRIVE_MODE: + setDriveMode(Enums.switchDriveMode(vehicle.getDriveMode())); + break; + + case Constants.CMD_SPEED_DOWN: + setSpeedMode( + Enums.toggleSpeed( + Enums.Direction.DOWN.getValue(), + Enums.SpeedMode.getByID(preferencesManager.getSpeedMode()))); + break; + + case Constants.CMD_SPEED_UP: + setSpeedMode( + Enums.toggleSpeed( + Enums.Direction.UP.getValue(), + Enums.SpeedMode.getByID(preferencesManager.getSpeedMode()))); + break; + case Constants.CMD_NETWORK: setNetworkEnabledWithAudio(!binding.autoSwitch.isChecked()); break; From 85b14feeb5a1684e24023bf21e412806682a6be0 Mon Sep 17 00:00:00 2001 From: Matthias Mueller Date: Thu, 15 Apr 2021 20:08:09 +0200 Subject: [PATCH 3/4] add audio effects for drive and speed mode --- .../main/java/org/openbot/common/ControlsFragment.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/java/org/openbot/common/ControlsFragment.java b/android/app/src/main/java/org/openbot/common/ControlsFragment.java index dd7ff9d42..6050ebd39 100644 --- a/android/app/src/main/java/org/openbot/common/ControlsFragment.java +++ b/android/app/src/main/java/org/openbot/common/ControlsFragment.java @@ -116,7 +116,6 @@ private void processKeyEvent(KeyEvent keyCode) { toggleIndicatorEvent(Enums.VehicleIndicator.RIGHT.getValue()); processControllerKeyData(Constants.CMD_INDICATOR_RIGHT); break; - case KeyEvent.KEYCODE_BUTTON_A: // x processControllerKeyData(Constants.CMD_LOGS); break; @@ -126,15 +125,20 @@ private void processKeyEvent(KeyEvent keyCode) { break; case KeyEvent.KEYCODE_BUTTON_L1: processControllerKeyData(Constants.CMD_DRIVE_MODE); + audioPlayer.playDriveMode(voice, vehicle.getDriveMode()); break; case KeyEvent.KEYCODE_BUTTON_R1: processControllerKeyData(Constants.CMD_NETWORK); break; case KeyEvent.KEYCODE_BUTTON_THUMBL: processControllerKeyData(Constants.CMD_SPEED_DOWN); + audioPlayer.playSpeedMode( + voice, Enums.SpeedMode.getByID(preferencesManager.getSpeedMode())); break; case KeyEvent.KEYCODE_BUTTON_THUMBR: processControllerKeyData(Constants.CMD_SPEED_UP); + audioPlayer.playSpeedMode( + voice, Enums.SpeedMode.getByID(preferencesManager.getSpeedMode())); break; default: @@ -202,9 +206,9 @@ private void handlePhoneControllerEvents() { } protected void toggleNoise() { + vehicle.toggleNoise(); BotToControllerEventBus.emitEvent(Utils.createStatus("NOISE", vehicle.isNoiseEnabled())); audioPlayer.playNoise(voice, vehicle.isNoiseEnabled()); - vehicle.toggleNoise(); } private void toggleIndicatorEvent(int value) { From 2077521014c44d475f3950f0b7aac4e9b45d26ab Mon Sep 17 00:00:00 2001 From: Matthias Mueller Date: Thu, 15 Apr 2021 20:08:40 +0200 Subject: [PATCH 4/4] cleanup --- .../app/src/main/java/org/openbot/logging/LoggerFragment.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/android/app/src/main/java/org/openbot/logging/LoggerFragment.java b/android/app/src/main/java/org/openbot/logging/LoggerFragment.java index 0f99e5629..8bc015a8b 100644 --- a/android/app/src/main/java/org/openbot/logging/LoggerFragment.java +++ b/android/app/src/main/java/org/openbot/logging/LoggerFragment.java @@ -401,9 +401,7 @@ protected void processControllerKeyData(String commandType) { case Constants.CMD_LOGS: handleLogging(); break; - // case "Constants.CMD_NOISE": - // handleNoise(); - // break; + case Constants.CMD_INDICATOR_LEFT: case Constants.CMD_INDICATOR_RIGHT: case Constants.CMD_INDICATOR_STOP: