Example #1
0
    def __init__(self, id, color, speed, pos):
        self.id = id
        self.speed = speed
        self.color = color
        self.position = pos
        self.isLife = True
        self.acceleration = [0, 0]
        self.rotation = 0.0
        self.publisher = rospy.Publisher(self.id, Marker, queue_size=10)
        self.ros()

        self.nunchucks = []
        i = 0
        while i < NUNCHUCKS_COUNT + 1:
            me = self.id + "_hand" + str(i)

            position = (NUNCHUCK_LENGTH[0], 0, 0)
            parent = self.id + "_hand" + str(i - 1)

            if i == 0:
                parent = self.id
                position = (0.4, 0, 0)

            nunchuck = Nunchuck(me, Marker.CYLINDER, parent, position,
                                NUNCHUCK_LENGTH, [1, 1, 1], 220)
            self.nunchucks.append(nunchuck)
            i += 1

        position = (1, 0, 0)
        parent = self.id + "_hand" + str(i - 1)
        nunchuck = Nunchuck(self.id + "_damage", Marker.ARROW, parent,
                            position, [0.9, 0.5, 0.1], [0.3, 1, 0.7], 0)
        self.nunchucks.append(nunchuck)
        self.damage = nunchuck
Example #2
0
 def __init__(self):
     self.Nunchuck = Nunchuck.Nunchuck()
     self.Nunchuck.setdelay(0.005)
Example #3
0
#!/usr/bin/python
#
# Tests the connectivity of the Wii nunchuck over I2C
#

import smbus
import time
from Nunchuck import Nunchuck


nun = Nunchuck()

while True:
    nun.update()
    print 'Jx: %s Jy: %s Ax: %s Ay: %s Az: %s Bc: %s Bz: %s' % (nun.joy_x, nun.joy_y, nun.accel_x, nun.accel_y, nun.accel_z, nun.button_c, nun.button_z)
    




Example #4
0
    pos = 1
    for field in line:
      servoTable[int(servoNum)][int(pos)] = int(field)
      pos += 1

# get mid positions and move arms to those locations
midPositions = []
print '[#, min, max] mid'
for i in range(0,6):
    midPositions.append((servoTable[i][2]-servoTable[i][1])/2+servoTable[i][1])
    print servoTable[i], midPositions[i]
    #pwm.setPWM(i,0,midPositions[i])
currentPositions = [445,385,465,220,395,270]
updatePos(currentPositions)

nunchuck = Nunchuck()
mode = 1
while (1):
  nunchuck.update()
  #change mode if button c pressed
  if (nunchuck.button_c==True):
    if (mode==1):
      mode = 2
    else:
      mode =1
    print mode
    time.sleep(1)
  #mode 1
  if (mode==1 and nunchuck.button_z==False):
    if (nunchuck.joy_x < 60):
      currentPositions[0] -= 20