我有一个带有机器人套件的 Raspberry Pi,我想使用 PS4 控制器但使用模拟输入来控制它。我已成功连接控制器,我可以读取事件并对电机进行编程以响应二进制输入。然而,文档 (pyPS4Controller)并没有明确说明使用模拟值(例如:50% 按下 R2 输出 0.5 向前)。
有人可以帮我弄清楚如何制作这个吗?
提前致谢!
# This is the example for binary buttons
from pyPS4Controller.controller import Controller
class MyController(Controller):
def __init__(self, **kwargs):
Controller.__init__(self, **kwargs)
def on_x_press(self):
print("Forward")
def on_x_release(self):
print("Stop")
# --> The objective is having some way to capture the "intensity" of the button press to use the motors accordingly
controller = MyController(interface="/dev/input/js0", connecting_using_ds4drv=False)
controller.listen()