Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/Teleop-Control/joystick_control/launch/controller.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,36 @@
import os
from ament_index_python.packages import get_package_share_directory

def find_ps5():
try:
with open("/proc/bus/input/devices", "r") as f:
device_block = ""
for line in f:
if line.strip() == "":
if "Wireless Controller" in device_block:
# Find the handlers line, e.g., H: Handlers=event19 js0
for part in device_block.split():
if part.startswith("js"):
# Return the full path string, not just the number
dev_path = f"/dev/input/{part.strip()}"
print(f"Found PS5 controller at {dev_path}")
return dev_path
device_block = ""
else:
device_block += line
except Exception as e:
print(f"Error reading devices: {e}")

print("ERROR: PS5 controller not found. Defaulting to /dev/input/js0")
return "/dev/input/js0"


def generate_launch_description():
pkg_joystick_control = get_package_share_directory("joystick_control")
parameters_file = os.path.join(pkg_joystick_control, "pxn.yaml")
# Detect IDs dynamically
arm_dev = "/dev/input/by-id/usb-LiteStar_PXN-2113_Pro-joystick"
drive_dev = "/dev/input/by-id/usb-Thrustmaster_T.16000M-joystick"
drive_dev = find_ps5()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the playstation controller not provide a /dev/input/by-id path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not over bluetooth


ld = LaunchDescription()

Expand Down
Loading