Created
May 23, 2023 11:24
-
-
Save peeranatkankham/cd25bcd3458fb859d772cbd62324b162 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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