Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save peeranatkankham/cd25bcd3458fb859d772cbd62324b162 to your computer and use it in GitHub Desktop.
Save peeranatkankham/cd25bcd3458fb859d772cbd62324b162 to your computer and use it in GitHub Desktop.
from smars_library.smars_library import SmarsRobot
from pyPS4Controller.controller import Controller
import smars_library.smars_library as sl
SMARS = SmarsRobot()
# SMARS.invert_feet()
DRIVER = sl.DO_NOT_USE_PCA_DRIVER
class MyController(Controller):
def __init__(self, **kwargs):
Controller.__init__(self, **kwargs)
def on_up_arrow_press(self):
SMARS.walkforward(steps=10)
def on_down_arrow_press(self):
SMARS.walkbackward(steps=10)
def on_left_arrow_press(self):
SMARS.turnleft()
def on_right_arrow_press(self):
SMARS.turnright()
def on_L1_press(self):
SMARS.stand()
def on_R1_press(self):
SMARS.sit()
def on_square_press(self):
SMARS.wiggle(1)
def on_circle_press(self):
SMARS.clap(1)
def on_x_press(self):
SMARS.default()
controller = MyController(interface="/dev/input/js0", connecting_using_ds4drv=False)
# you can start listening before controller is paired, as long as you pair it within the timeout window
controller.listen(timeout=60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment