Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
|
|
7 months ago | |
|---|---|---|
| .. | ||
| gamepad | 7 months ago | |
| tests | 10 months ago | |
| README.md | 7 months ago | |
| demo.yml | 10 months ago | |
| pyproject.toml | 9 months ago | |
A Dora framework node that provides universal gamepad control functionality. While tested primarily with the Logitech F710 wireless controller, it supports any standard gamepad/joystick.
pip install -e .
dora build demo.yml --uv
dora run demo.yml --uv
ls /dev/input/js* # Should show your controller
If port is not executable then run
sudo chmod +x /dev/input/js*
The node also outputs complete gamepad state including all buttons, axes, and D-pad for custom processing.
nodes:
- id: gamepad
build: pip install -e .
path: gamepad
outputs:
- cmd_vel # Velocity commands [vx, vy, vz, wx, wy, wz]
- raw_control # Complete gamepad state (JSON)
inputs:
tick: dora/timer/millis/10 # Update rate (100Hz)
cmd_vel - 6-element velocity array:[0]: Linear X velocity (D-pad vertical)[1]: Linear Y velocity (D-pad horizontal)[2]: Linear Z velocity (right stick Y)[3]: Angular X velocity (left stick Y)[4]: Angular Y velocity (left stick X)[5]: Angular Z velocity (right stick X)raw_control - Complete gamepad state (JSON):{
"axes": [left_x, left_y, right_x, right_y, ...],
"buttons": [X, A, B, Y, LB, RB, LT, RT, BACK, START, LEFT_STICK, RIGHT_STICK],
"hats": [[dpad_x, dpad_y]],
"mapping": {
"axes": {"LEFT-X": 0, "LEFT-Y": 1, "RIGHT-X": 2, "RIGHT-Y": 3},
"buttons": {"X": 0, "A": 1, "B": 2, "Y": 3, "LB": 4, "RB": 5, ...}
}
}
To use a different controller, modify the Controller class mapping:
class Controller:
def __init__(self):
# Customize for your controller
self.axisNames = {
'LEFT-X': 0,
'LEFT-Y': 1,
'RIGHT-X': 2,
'RIGHT-Y': 3,
}
self.buttonNames = {
'X': 0,
'A': 1,
# ... add your button mapping
}
Format code using ruff:
ruff check . --fix
Run tests with pytest:
pytest .
for event in node:
if event["id"] == "cmd_vel":
velocity = event["value"].to_numpy()
# Apply velocity to your robot/system
print(f"Velocity: {velocity}")
import json
for event in node:
if event["id"] == "raw_control":
control_state = json.loads(event["value"].to_pylist()[0])
buttons = control_state["buttons"]
axis = control_state[axis]
No gamepad detected:
Raw control output empty:
jstest /dev/input/js0Incorrect button mapping:
jstest to identify your controller's button/axis numbersController class accordinglyIf port is not executable then run:
sudo chmod +x /dev/input/js*
Released under the MIT License. See LICENSE file for details.
DORA (Dataflow-Oriented Robotic Architecture) is middleware designed to streamline and simplify the creation of AI-based robotic applications. It offers low latency, composable, and distributed datafl
Rust Python TOML Markdown C other