Exemplo n.º 1
0
    def _update(self):
        state = sixaxis.get_state()

        # Buttons
        self._gamepad.buttons["square"] = state["square"]
        self._gamepad.buttons["cross"] = state["cross"]
        self._gamepad.buttons["circle"] = state["circle"]
        self._gamepad.buttons["triangle"] = state["triangle"]
        self._gamepad.buttons["R1"] = state["R1"]
        self._gamepad.buttons["L1"] = state["L1"]
        self._gamepad.buttons["R2"] = state["R2"]
        self._gamepad.buttons["L2"] = state["L2"]
        self._gamepad.buttons["select"] = state["select"]
        self._gamepad.buttons["start"] = state["start"]
        self._gamepad.buttons["ps3"] = state["PS3"]
        self._gamepad.buttons["left"] = state["bottomleft"]
        self._gamepad.buttons["right"] = state["bottomright"]
        self._gamepad.buttons["up"] = state["bottomup"]
        self._gamepad.buttons["down"] = state["bottomdown"]

        # Axis
        self._gamepad.axisLeft_X = state["leftx"]
        self._gamepad.axisLeft_Y = state["lefty"]
        self._gamepad.axisRight_X = state["rightx"]
        self._gamepad.axisRight_Y = state["righty"]
Exemplo n.º 2
0
 def _update(self):
     state = sixaxis.get_state()
     
     # Buttons
     self._gamepad.buttons["square"] = state["square"]
     self._gamepad.buttons["cross"] = state["cross"]
     self._gamepad.buttons["circle"] = state["circle"]
     self._gamepad.buttons["triangle"] = state["triangle"]
     self._gamepad.buttons["R1"] = state["R1"]
     self._gamepad.buttons["L1"] = state["L1"]
     self._gamepad.buttons["R2"] = state["R2"]
     self._gamepad.buttons["L2"] = state["L2"]
     self._gamepad.buttons["select"] = state["select"]
     self._gamepad.buttons["start"] = state["start"]
     self._gamepad.buttons["ps3"] = state["PS3"]
     self._gamepad.buttons["left"] = state["bottomleft"]
     self._gamepad.buttons["right"] = state["bottomright"]
     self._gamepad.buttons["up"] = state["bottomup"]
     self._gamepad.buttons["down"] = state["bottomdown"]
     
     # Axis
     self._gamepad.axisLeft_X = state["leftx"] 
     self._gamepad.axisLeft_Y = state["lefty"] 
     self._gamepad.axisRight_X = state["rightx"] 
     self._gamepad.axisRight_Y = state["righty"]
	def getInput(self):
		state = sixaxis.get_state()
		self.motor_speeds[0] = int(state['lefty'] )
		self.motor_speeds[1] = int(state['righty'] )
		self.motor_speeds[2] = int(state['trig2'] )
		print self.motor_speeds
		sleep(0.1)
Exemplo n.º 4
0
# Spins at a certain percent of full speed.
def spinAtPcSpeed(ID,pcSpeed):
        if pcSpeed >= 0:
                spinAtDxSpeed(ID,int(float(pcSpeed)*10.23))
        else:
                spinAtDxSpeed(ID,1024+int(float(-pcSpeed)*10.23))
 
def throttleSteeringToLeftRight(inThrottle, inSteering):
        left = min(100, max(-100, inThrottle - inSteering));
        right = min(100, max(-100, inThrottle + inSteering));
        return (left, right)
 
 
 
# Purge the first value
joystate = sixaxis.get_state()
time.sleep(0.5)
print("Press [triangle] to exit.")
shoulderPos = 225
tiltPos = 220
panPos = 0
clawPos = 800
 
# Set wheel and joint modes.
writeWord(1, DXL_REG_CCW_Angle_Limit, 0)
writeWord(2, DXL_REG_CCW_Angle_Limit, 0)
writeWord(3, DXL_REG_CCW_Angle_Limit, 0)
writeWord(4, DXL_REG_CCW_Angle_Limit, 0)
 
 
jointMode(5)
Exemplo n.º 5
0
            gaugeSocket = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
            #Write your MAC address
            gaugeSocket.connect(('XX:XX:XX:XX:XX:XX', 1))
            break
        except bluetooth.btcommon.BluetoothError as error:
            gaugeSocket.close()
            print "Connection failed ", error, "; Retry in 5s..."
            time.sleep(5)
    return gaugeSocket


gaugeSocket = connect()
while (True):

    time.sleep(0.05)
    data = sixaxis.get_state()
    print data
    try:
        gaugeSocket.send(str(int(data[0], 16)))
        gaugeSocket.send(str(int(data[1], 16)))
        gaugeSocket.send(str(int(data[2], 16)))
        gaugeSocket.send(str(int(data[3], 16)))
        #print gaugeSocket.recv(1)
    except bluetooth.btcommon.BluetoothError as error:
        print "Caught Bluetooth Error: ", error
        time.sleep(5)
        gaugeSocket = connect()
        pass

gaugeSocket.close()
Exemplo n.º 6
0
        try:
            gaugeSocket = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
            #Write your MAC address
            gaugeSocket.connect(('XX:XX:XX:XX:XX:XX', 1))
            break;
        except bluetooth.btcommon.BluetoothError as error:
            gaugeSocket.close()
            print "Connection failed ", error, "; Retry in 5s..."
            time.sleep(5)
    return gaugeSocket;

gaugeSocket = connect()
while(True):

    time.sleep(0.05)
    data = sixaxis.get_state()
    print data
    try:
        gaugeSocket.send(str(int(data[0], 16)))
        gaugeSocket.send(str(int(data[1], 16)))
        gaugeSocket.send(str(int(data[2], 16)))
        gaugeSocket.send(str(int(data[3], 16)))
        #print gaugeSocket.recv(1)
    except bluetooth.btcommon.BluetoothError as error:
        print "Caught Bluetooth Error: ", error
        time.sleep(5)
        gaugeSocket = connect()
        pass

gaugeSocket.close()
Exemplo n.º 7
0
#! /usr/bin/env python

import sixaxis
import pprint

sixaxis.init("/dev/input/js1")
pp = pprint.PrettyPrinter(indent=4)
while (1):
    state = sixaxis.get_state()
    if (state['triangle'] == True):
        break
    pp.pprint(state)