Beispiel #1
0
def enter_mode(mode):
    logging.debug('entering mode: %s' % mode)
    if mode not in _mode_mapping:
        logging.error('unrecognized mode %s' % mode)
    mode_command = _mode_mapping[mode]
    if mode_command:
        send_command('mode_%s' % mode_command)
    set_current_controller(mode)
Beispiel #2
0
def enter_mode(mode):
    logging.debug('entering mode: %s' % mode)
    if mode not in _mode_mapping:
        logging.error('unrecognized mode %s' % mode)
    mode_command = _mode_mapping[mode]
    if mode_command:
        send_command('mode_%s' % mode_command)
    set_current_controller(mode)
Beispiel #3
0
    def stop(self):
        self.is_activated = False
        self.loc_x_hand.empty()
        self.loc_y_hand.empty()
        self.loc_z_hand.empty()
        self.rot_x_hand.empty()
        self.rot_y_hand.empty()
        self.rot_z_hand.empty()

        send_command('object_move_end', {})
        send_command('object_rotate_end', {})
Beispiel #4
0
    def stop(self):
        self.is_activated = False
        self.loc_x_hand.empty()
        self.loc_y_hand.empty()
        self.loc_z_hand.empty()
        self.rot_x_hand.empty()
        self.rot_y_hand.empty()
        self.rot_z_hand.empty()

        send_command('object_move_end', {})
        send_command('object_rotate_end', {})
Beispiel #5
0
 def point_finger(self, tip, direction):
     # TODO send as long command ?
     tip = rescale_position(tip)
     send_command(
         'finger_touch', {
             'x': tip.z,
             'y': tip.x,
             'z': tip.y,
             'vx': direction.z,
             'vy': direction.x,
             'vz': direction.y
         })
Beispiel #6
0
    def start(self, hand):
        self.is_activated = True

        # move origin
        pos = hand.stabilized_palm_position
        self.loc_x_origin = pos.x
        self.loc_y_origin = pos.y
        self.loc_z_origin = pos.z
        send_command('object_move_origin', {})

        # rotate origin
        self.rot_x_origin = hand.direction.pitch
        self.rot_y_origin = hand.direction.yaw
        self.rot_z_origin = hand.direction.roll
        send_command('object_rotate_origin', {})
Beispiel #7
0
    def start(self, hand):
        self.is_activated = True

        # move origin
        pos = hand.stabilized_palm_position
        self.loc_x_origin = pos.x
        self.loc_y_origin = pos.y
        self.loc_z_origin = pos.z
        send_command('object_move_origin', {})

        # rotate origin
        self.rot_x_origin = hand.direction.pitch
        self.rot_y_origin = hand.direction.yaw
        self.rot_z_origin = hand.direction.roll
        send_command('object_rotate_origin', {})
Beispiel #8
0
    def swipe(self, gesture):
        swipe_time = time.time()
        if abs(swipe_time - self.last_swipe_time) < self.swipe_min_delay:
            return

        self.last_swipe_time = swipe_time
        swipe_gesture = SwipeGesture(gesture)

        # don't handle vertical swipes
        if abs(swipe_gesture.direction[0]) < abs(swipe_gesture.direction[1]):
            return

        if swipe_gesture.direction[0] > 0:
            #print 'Rotating left'
            send_command('do_rotation_left')
        else:
            #print 'Rotating right'
            send_command('do_rotation_right')
Beispiel #9
0
    def run(self, hand):
        pos = hand.stabilized_palm_position
        self.loc_x_hand.add_value(pos.x)
        self.loc_y_hand.add_value(pos.y)
        self.loc_z_hand.add_value(pos.z)

        self.rot_x_hand.add_value(hand.direction.pitch)
        self.rot_y_hand.add_value(hand.direction.yaw)
        self.rot_z_hand.add_value(hand.direction.roll)

        # send motion
        dx = self.loc_x_hand.value - self.loc_x_origin
        dy = self.loc_y_hand.value - self.loc_y_origin
        dz = self.loc_z_hand.value - self.loc_z_origin
        send_command('object_move', {'loc_x': dx, 'loc_y': dy, 'loc_z': dz})

        # send rotation
        rx = self.rot_x_hand.value - self.rot_x_origin
        ry = self.rot_y_hand.value - self.rot_y_origin
        rz = self.rot_z_hand.value - self.rot_z_origin
        send_command('object_rotate', {'rot_x': rx, 'rot_y': ry, 'rot_z': rz})
Beispiel #10
0
    def run(self, hand):
        pos = hand.stabilized_palm_position
        self.loc_x_hand.add_value(pos.x)
        self.loc_y_hand.add_value(pos.y)
        self.loc_z_hand.add_value(pos.z)

        self.rot_x_hand.add_value(hand.direction.pitch)
        self.rot_y_hand.add_value(hand.direction.yaw)
        self.rot_z_hand.add_value(hand.direction.roll)

        # send motion
        dx = self.loc_x_hand.value - self.loc_x_origin
        dy = self.loc_y_hand.value - self.loc_y_origin
        dz = self.loc_z_hand.value - self.loc_z_origin
        send_command('object_move', { 'loc_x': dx, 'loc_y': dy, 'loc_z': dz})

        # send rotation
        rx = self.rot_x_hand.value - self.rot_x_origin
        ry = self.rot_y_hand.value - self.rot_y_origin
        rz = self.rot_z_hand.value - self.rot_z_origin
        send_command('object_rotate', { 'rot_x': rx, 'rot_y': ry, 'rot_z': rz})
Beispiel #11
0
def view_from(direction):
    logging.debug('viewing from %s' % direction)
    send_command('view_%s' % direction)
Beispiel #12
0
 def run(self, first_hand, second_hand):
     dis = first_hand.stabilized_palm_position - second_hand.stabilized_palm_position
     self.magnitude.add_value(dis.magnitude)
     mag = self.magnitude.value / self.magnitude_origin
     send_command('object_scale', {'sx': mag, 'sy': mag, 'sz': mag})
Beispiel #13
0
 def start(self, first_hand, second_hand):
     self.is_activated = True
     send_command('object_scale_origin')
     dis = first_hand.stabilized_palm_position - second_hand.stabilized_palm_position
     self.magnitude_origin = dis.magnitude
Beispiel #14
0
 def start(self, first_hand, second_hand):
     self.is_activated = True
     send_command('object_scale_origin')
     dis = first_hand.stabilized_palm_position - second_hand.stabilized_palm_position
     self.magnitude_origin = dis.magnitude
Beispiel #15
0
 def on_exit(self, controller):
     send_command('stop_rotation')
Beispiel #16
0
 def run(self, first_hand, second_hand):
     dis = first_hand.stabilized_palm_position - second_hand.stabilized_palm_position
     self.magnitude.add_value(dis.magnitude)
     mag = self.magnitude.value / self.magnitude_origin
     send_command('object_scale', { 'sx': mag, 'sy': mag, 'sz': mag })
Beispiel #17
0
 def stop(self):
     self.history = []
     send_command('stop_rotation')
Beispiel #18
0
 def stop(self):
     self.history = []
     send_command('stop_rotation')
Beispiel #19
0
def view_from(direction):
    logging.debug('viewing from %s' % direction)
    send_command('view_%s' % direction)
Beispiel #20
0
 def point_finger(self, tip, direction):
     # TODO send as long command ?
     tip = rescale_position(tip)
     send_command('finger_touch', { 'x': tip.z, 'y': tip.x, 'z': tip.y,
         'vx': direction.z, 'vy': direction.x, 'vz': direction.y })