xbox_udp链路
This commit is contained in:
@@ -69,7 +69,6 @@ class XBOXController:
|
||||
# smoothing
|
||||
self.height_step = 0.05
|
||||
|
||||
self._load_config()
|
||||
# default button map indices (can be overridden in config)
|
||||
self.button_map = {
|
||||
'a': 0, 'b': 1, 'x': 2, 'y': 3,
|
||||
@@ -84,6 +83,8 @@ class XBOXController:
|
||||
'dpad_h': 6, 'dpad_v': 7
|
||||
}
|
||||
|
||||
self._load_config()
|
||||
|
||||
def _load_config(self):
|
||||
try:
|
||||
config_path = os.path.join('.', 'config', 'dex_config.yaml')
|
||||
@@ -91,22 +92,24 @@ class XBOXController:
|
||||
cfg = yaml.safe_load(f) or {}
|
||||
xbox_cfg = cfg.get('xbox', {})
|
||||
# override button_map if provided
|
||||
# bm = xbox_cfg.get('button_map')
|
||||
# if isinstance(bm, dict):
|
||||
# for k, v in bm.items():
|
||||
# try:
|
||||
# self.button_map[k] = int(v)
|
||||
# except Exception:
|
||||
# pass
|
||||
|
||||
# # override axis_map if provided
|
||||
# am = xbox_cfg.get('axis_map')
|
||||
# if isinstance(am, dict):
|
||||
# for k, v in am.items():
|
||||
# try:
|
||||
# self.axis_map[k] = int(v)
|
||||
# except Exception:
|
||||
# pass
|
||||
bm = xbox_cfg.get('button_map')
|
||||
if isinstance(bm, dict):
|
||||
for k, v in bm.items():
|
||||
if k in self.button_map:
|
||||
try:
|
||||
self.button_map[k] = int(v)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# override axis_map if provided
|
||||
am = xbox_cfg.get('axis_map')
|
||||
if isinstance(am, dict):
|
||||
for k, v in am.items():
|
||||
if k in self.axis_map:
|
||||
try:
|
||||
self.axis_map[k] = int(v)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self.initial_height = xbox_cfg.get('initial_height', 0.89)
|
||||
self.forward_command_offset = xbox_cfg.get('forward_command_offset', 0.0)
|
||||
@@ -155,6 +158,9 @@ class XBOXController:
|
||||
# c -> gotoSTOP
|
||||
if self.map.y == 1:
|
||||
self.flag.fsm_state_command = 'gotoSTOP'
|
||||
# a -> gotoWALKAMP
|
||||
elif self.map.a == 1:
|
||||
self.flag.fsm_state_command = 'gotoWALKAMP'
|
||||
# h -> gotoDH (Left trigger + A)
|
||||
# v -> gotoBEYONDMIMIC (Left trigger + home)
|
||||
elif self.map.l_trigger < -0.5 and self.map.home == 1:
|
||||
|
||||
Reference in New Issue
Block a user