From c4ab134ee23c56143d012422efe544dfad9b8e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alptu=C4=9F=20C=C4=B1r=C4=B1t?= Date: Mon, 23 Sep 2024 10:50:37 +0300 Subject: [PATCH] add: park gear shortcut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alptuğ Cırıt --- Assets/AWSIM/Resources/Hotkeys.json | 8 ++++++-- .../Scripts/UI/Toggle/UIKeyboardControlToggle.cs | 14 ++++++++++++++ docs/ProjectGuide/HotkeyList/index.md | 6 ++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Assets/AWSIM/Resources/Hotkeys.json b/Assets/AWSIM/Resources/Hotkeys.json index a7d3dbbfd..99a412906 100644 --- a/Assets/AWSIM/Resources/Hotkeys.json +++ b/Assets/AWSIM/Resources/Hotkeys.json @@ -5,11 +5,11 @@ "hotkeys": [ { "key": "W / Up Arrow", - "description": "Throttle" + "description": "Forward" }, { "key": "S / Down Arrow", - "description": "Brake" + "description": "Brake & Reverse" }, { "key": "A / Left Arrow", @@ -35,6 +35,10 @@ "key": "N", "description": "Neutral Gear" }, + { + "key": "P", + "description": "Park Gear" + }, { "key": "Left Alt", "description": "Change Gear Mode" diff --git a/Assets/AWSIM/Scripts/UI/Toggle/UIKeyboardControlToggle.cs b/Assets/AWSIM/Scripts/UI/Toggle/UIKeyboardControlToggle.cs index 746bae646..af73c1fa8 100644 --- a/Assets/AWSIM/Scripts/UI/Toggle/UIKeyboardControlToggle.cs +++ b/Assets/AWSIM/Scripts/UI/Toggle/UIKeyboardControlToggle.cs @@ -1,6 +1,7 @@ using AWSIM.Scripts.Vehicles.VPP_Integration; using AWSIM.Scripts.Vehicles.VPP_Integration.Enums; using UnityEngine; +using VehiclePhysics; namespace AWSIM.Scripts.UI.Toggle { @@ -8,11 +9,13 @@ public class UIKeyboardControlToggle : MonoBehaviour { private GameObject _egoVehicle; private AutowareVPPAdapter _adapter; + private VPVehicleController _controller; private void Start() { _egoVehicle = GameObject.FindWithTag("Ego"); _adapter = _egoVehicle.GetComponent(); + _controller = _egoVehicle.GetComponent(); // Set the toggle to the current state of the keyboard control mode GetComponent().isOn = _adapter.ControlModeInput != VPPControlMode.Autonomous; @@ -24,6 +27,17 @@ public void Activate() Start(); } + private void Update() + { + if (_adapter.ControlModeInput == VPPControlMode.Manual) + { + if (Input.GetKeyDown(KeyCode.P)) + { + _controller.data.bus[Channel.Input][InputData.AutomaticGear] = (int)Gearbox.AutomaticGear.P; + } + } + } + // Toggle the keyboard control public void OnClick(bool isOn) { diff --git a/docs/ProjectGuide/HotkeyList/index.md b/docs/ProjectGuide/HotkeyList/index.md index a5b281afe..695aa4b16 100644 --- a/docs/ProjectGuide/HotkeyList/index.md +++ b/docs/ProjectGuide/HotkeyList/index.md @@ -4,16 +4,18 @@ | Key | Feature | |:-----------------------|:------------------| -| W / Up Arrow | Throttle. | -| S / Down Arrow | Brake. | +| W / Up Arrow | Forward. | +| S / Down Arrow | Brake & Reverse. | | A / Left Arrow | Steer Left. | | D / Right Arrow | Steer Right. | | Space | Handbrake. | | Left Shift / Left Ctrl | Change Gear +/-. | | R | Reverse Gear. | | N | Neutral Gear. | +| P | Park Gear. | | Left Alt | Change Gear Mode. | + ### [VPPVehicleSignalHandler.cs](https://github.com/autowarefoundation/AWSIM-Labs/blob/main/Assets/AWSIM/Scripts/Vehicles/VPP%20Integration/VPPVehicleSignalHandler.cs) | Key | Feature |