Created
October 4, 2020 18:12
-
-
Save Heavy02011/00d6c37efd7b4387355ef4615f0e43cd to your computer and use it in GitHub Desktop.
sample script to get signals from G920 on Ubuntu 18.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# g920_testing.py | |
import os | |
import random | |
import json | |
import time | |
from io import BytesIO | |
import base64 | |
import pygame | |
from PIL import Image | |
import numpy as np | |
from gym_donkeycar.core.sim_client import SDClient | |
# Initialize the joysticks. | |
pygame.init() | |
pygame.joystick.init() | |
joystick = pygame.joystick.Joystick(1) | |
joystick.init() | |
while True: | |
pygame.event.get() | |
#st = joystick.get_axis(0) | |
#th = joystick.get_axis(4) | |
s0 = joystick.get_axis(0) # steering wheel -1...1 (+/-1.25 revolutions) | |
s1 = joystick.get_axis(1) # throttle 1..-1 | |
s2 = joystick.get_axis(2) # brake 1...-0.6/1 | |
s3 = joystick.get_axis(3) # kupplung 1...-1 | |
#s4 = joystick.get_axis(4) | |
#s5 = joystick.get_axis(5) | |
#s6 = joystick.get_axis(6) | |
print(s0, s1, s2, s3) | |
#print(st, th) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment