对于套接字通信,我如何全局打印两者,而不是单独打印,如(90 90)
print(steering, throttle)from evdev import InputDevice, categorize, ecodes
gamepad = InputDevice('/dev/input/event8')
print(gamepad)
for event in gamepad.read_loop():
if event.type == ecodes.EV_ABS:
if event.code == 0:
steering = event.value/2047*180
steering = steering-0
print('steering', steering)
elif event.code == 1:
throttle = event.value/2047*180
print('throttle', throttle)发布于 2020-03-25 05:25:19
from evdev import InputDevice, categorize, ecodes
gamepad = InputDevice('/dev/input/event8')
steering = 0
throttle = 0
def otherthings():
...
def sticks():
global steering, throttle
for event in gamepad.read_loop():
if event.type == ecodes.EV_ABS:
if event.code in (0, 1):
if event.code == 0:
steering = event.value/2047*180
elif event.code == 1:
throttle = event.value/2047*180
def main():
while True:
# do things
sticks()
print(f'steering: {steering}, throttle: {throttle}')
# maybe do other things
if __name__ == '__main__':
main()https://stackoverflow.com/questions/60837923
复制相似问题