diff --git a/README1.md b/README1.md new file mode 100644 index 0000000000..d789046688 --- /dev/null +++ b/README1.md @@ -0,0 +1,20 @@ +# OpenPilot Custom Modifications + +This repository contains custom modifications to OpenPilot(steering and accelaration), including updates to the keyboard and joystick control files. + +## Modified Files + +1. **Keyboard Control File:** + - File: `tools/lib/keyboard_ctrl.py` + - Description: Custom changes to the keyboard control logic to integrate with the new GUI button. + - Path in Repository: [tools/lib/keyboard_ctrl.py](https://github.com/Sage-A/openpilot/blob/ADbranch/tools/lib/keyboard_ctrl.py) + +2. **Joystick Control File:** + - File: `tools/sim/joystick_control.py` + - Description: Modifications to the joystick control to handle new input methods, including GUI-based control. + - Path in Repository: [tools/sim/joystick_control.py](https://github.com/Sage-A/openpilot/blob/ADbranch/tools/sim/joystick_control.py) + +## How to Set Up + +Find instructions on how to set up/build Openpilot in the README.md file in openpilot/tools. +Find instructions on how to run MetaSim in the README.md file in openpilot/tools/sim. diff --git a/tools/joystick/joystick_control.py b/tools/joystick/joystick_control.py index 4f6b855c17..68fa67f4b9 100755 --- a/tools/joystick/joystick_control.py +++ b/tools/joystick/joystick_control.py @@ -16,9 +16,11 @@ class Keyboard: def __init__(self): + managed_processes['ui'].w.customWindow.accelDown.connect(self.GUI_ACCEL) + managed_processes['ui'].w.customWindow.accelRelease.connect(self.GUI_ACCEL) self.kb = KBHit() self.axis_increment = 0.05 # 5% of full actuation each key press - self.axes_map = {'b': 'gb', 's': 'gb', + self.axes_map = {'GUI_ACCEL': 'gb', 's': 'gb', 'a': 'steer', 'd': 'steer'} self.axes_values = {'gb': 0., 'steer': 0.} self.axes_order = ['gb', 'steer'] @@ -33,7 +35,7 @@ def update(self): self.cancel = True elif key in self.axes_map: axis = self.axes_map[key] - incr = self.axis_increment if key in ['b', 'a'] else -self.axis_increment + incr = self.axis_increment if key in ['GUI_ACCEL', 'a'] else -self.axis_increment self.axes_values[axis] = float(np.clip(self.axes_values[axis] + incr, -1, 1)) else: return False @@ -42,7 +44,7 @@ def update(self): class SteeringGUI: def __init__(self, steer_slider): # Refers to the acceleration and steering inputs - self.accel_axis = 'GUI_ACCEL' + self.accel_axis = 'b' self.steer_axis = 'GUI_STEER' # Acceleration and steering both range from -1.0 to 1.0 @@ -192,7 +194,7 @@ def main(): if args.gui: print('Using GUI for control (slider + throttle inputs).') elif args.keyboard: - print('Gas/brake control: `B` and `S` keys') + print('Gas/brake control: `GUI_ACCEL` and `S` keys') print('Steering control: `A` and `D` keys') print('Buttons') print('- `R`: Resets axes') diff --git a/tools/sim/lib/keyboard_ctrl.py b/tools/sim/lib/keyboard_ctrl.py index 014a4f9466..e54d35cb03 100644 --- a/tools/sim/lib/keyboard_ctrl.py +++ b/tools/sim/lib/keyboard_ctrl.py @@ -28,7 +28,7 @@ | r | Reset Simulation | | i | Toggle Ignition | | q | Exit all | - | basd | Control manually | + | GUI_ACCELasd | Control manually | """ @@ -66,7 +66,7 @@ def keyboard_poll_thread(q: 'Queue[QueueMessage]'): q.put(control_cmd_gen("cruise_down")) elif c == '3': q.put(control_cmd_gen("cruise_cancel")) - elif c == 'b': + elif c == 'GUI_ACCEL': q.put(control_cmd_gen(f"throttle_{100.0}")) elif c == 'a': q.put(control_cmd_gen(f"steer_{-0.15}"))