Skip to content

Commit e3873c9

Browse files
authored
Merge pull request #3 from Sage-A/ADbranch
Adbranch
2 parents 7e36fd0 + 03efb8b commit e3873c9

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

README1.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# OpenPilot Custom Modifications
2+
3+
This repository contains custom modifications to OpenPilot(steering and accelaration), including updates to the keyboard and joystick control files.
4+
5+
## Modified Files
6+
7+
1. **Keyboard Control File:**
8+
- File: `tools/lib/keyboard_ctrl.py`
9+
- Description: Custom changes to the keyboard control logic to integrate with the new GUI button.
10+
- Path in Repository: [tools/lib/keyboard_ctrl.py](https://github.com/Sage-A/openpilot/blob/ADbranch/tools/lib/keyboard_ctrl.py)
11+
12+
2. **Joystick Control File:**
13+
- File: `tools/sim/joystick_control.py`
14+
- Description: Modifications to the joystick control to handle new input methods, including GUI-based control.
15+
- Path in Repository: [tools/sim/joystick_control.py](https://github.com/Sage-A/openpilot/blob/ADbranch/tools/sim/joystick_control.py)
16+
17+
## How to Set Up
18+
19+
Find instructions on how to set up/build Openpilot in the README.md file in openpilot/tools.
20+
Find instructions on how to run MetaSim in the README.md file in openpilot/tools/sim.

tools/joystick/joystick_control.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717

1818
class Keyboard:
1919
def __init__(self):
20+
managed_processes['ui'].w.customWindow.accelDown.connect(self.GUI_ACCEL)
21+
managed_processes['ui'].w.customWindow.accelRelease.connect(self.GUI_ACCEL)
2022
self.kb = KBHit()
2123
self.axis_increment = 0.05 # 5% of full actuation each key press
22-
self.axes_map = {'b': 'gb', 's': 'gb',
24+
self.axes_map = {'GUI_ACCEL': 'gb', 's': 'gb',
2325
'a': 'steer', 'd': 'steer'}
2426
self.axes_values = {'gb': 0., 'steer': 0.}
2527
self.axes_order = ['gb', 'steer']
@@ -34,7 +36,7 @@ def update(self):
3436
self.cancel = True
3537
elif key in self.axes_map:
3638
axis = self.axes_map[key]
37-
incr = self.axis_increment if key in ['b', 'a'] else -self.axis_increment
39+
incr = self.axis_increment if key in ['GUI_ACCEL', 'a'] else -self.axis_increment
3840
self.axes_values[axis] = float(np.clip(self.axes_values[axis] + incr, -1, 1))
3941
else:
4042
return False
@@ -46,7 +48,7 @@ def __init__(self, steer_slider):
4648
managed_processes['ui'].w.customWindow.accelDown.connect(self.GUI_ACCEL)
4749
managed_processes['ui'].w.customWindow.accelRelease.connect(self.GUI_ACCEL)
4850
# Refers to the acceleration and steering inputs
49-
self.accel_axis = 'GUI_ACCEL'
51+
self.accel_axis = 'b'
5052
self.steer_axis = 'GUI_STEER'
5153

5254
# Acceleration and steering both range from -1.0 to 1.0
@@ -196,7 +198,7 @@ def main():
196198
if args.gui:
197199
print('Using GUI for control (slider + throttle inputs).')
198200
elif args.keyboard:
199-
print('Gas/brake control: `B` and `S` keys')
201+
print('Gas/brake control: `GUI_ACCEL` and `S` keys')
200202
print('Steering control: `A` and `D` keys')
201203
print('Buttons')
202204
print('- `R`: Resets axes')

tools/sim/lib/keyboard_ctrl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
| r | Reset Simulation |
2929
| i | Toggle Ignition |
3030
| q | Exit all |
31-
| basd | Control manually |
31+
| GUI_ACCELasd | Control manually |
3232
"""
3333

3434

@@ -66,7 +66,7 @@ def keyboard_poll_thread(q: 'Queue[QueueMessage]'):
6666
q.put(control_cmd_gen("cruise_down"))
6767
elif c == '3':
6868
q.put(control_cmd_gen("cruise_cancel"))
69-
elif c == 'b':
69+
elif c == 'GUI_ACCEL':
7070
q.put(control_cmd_gen(f"throttle_{100.0}"))
7171
elif c == 'a':
7272
q.put(control_cmd_gen(f"steer_{-0.15}"))

0 commit comments

Comments
 (0)