Пример #1
0
 def main(self):
     while self.running:
         #Si no estamos depurando y el movimiento no esta bloqueado, movemos los objetos de acuerdo al movimiento del Oculus
         if not self.debug and not self.moveBlocked:
             #Se obtiene la posición actual del OVR
             ss = ovrsdk.ovrHmd_GetSensorState(
                 self.hmd, ovrsdk.ovr_GetTimeInSeconds())
             pose = ss.Predicted.Pose
             #Valores de posición actuales del OVR
             currp = [pose.Orientation.x, pose.Orientation.y]
             #Movemos la cámara del visualizador de moléculas en sentido al movimiento del OVR
             pymol.cmd.move('x', (currp[1] - self.prevp[1]) *
                            self.ovr_sensitivity)
             pymol.cmd.move(
                 'y', -(currp[0] - self.prevp[0]) * self.ovr_sensitivity)
             #Actualizamos los valores de posición anteriores del OVR
             self.prevp = currp
         #Comprobamos si hay comandos por recibir, en caso de no existir alguno, se ignora el error que generaría el sistema operativo.
         try:
             self.data = self.sock.recv(1024)
         except socket.error:
             pass
         else:
             self.__process_command()
         #Dormimos el programa para disminuir el uso de CPU
         time.sleep(SLEEPTIME)
     pymol.cmd.quit()
Пример #2
0
    def _run(self):
        """Interpolate orientation data and update servo positions"""
        pitch_domain = [-0.3, 0.7]
        yaw_domain = [-0.7, 0.7]
        pitch_range = [0, 180]
        yaw_range = [15, 165]

        pitch_inversion = 1 * self.invert
        yaw_inversion = -1 * self.invert
        map_pitch = lambda x: int(interp(
            pitch_inversion * x,
            pitch_domain,
            pitch_range)
        )
        map_yaw = lambda x: int(interp(
            yaw_inversion * x,
            yaw_domain,
            yaw_range)
        )

        range0 = 90
        range1 = 45

        po.set_target(self.servo, 1, range0)
        po.set_target(self.servo, 1, range1)

        while True:
            state = ovr.ovrHmd_GetSensorState(
                self.hmd, ovr.ovr_GetTimeInSeconds()
            )
            pose = state.Predicted.Pose

            pitch = pose.Orientation.x # -0.3 ~ 0.7
            #roll = pose.Orientation.z
            yaw = pose.Orientation.y # -0.7 ~ 0.7

            range0 = map_yaw(yaw)
            range1 = map_pitch(pitch)

            #print("Servo 0 set to {}, servo 1 set to {}".format(range0, range1))
            po.set_target(self.servo, 0, range0)
            po.set_target(self.servo, 1, range1)

            gevent.sleep(0)
Пример #3
0
    def _run(self):
        """Interpolate orientation data and update servo positions"""
        pitch_domain = [-0.3, 0.7]
        yaw_domain = [-0.7, 0.7]
        pitch_range = [0, 180]
        yaw_range = [15, 165]

        pitch_inversion = 1 * self.invert
        yaw_inversion = -1 * self.invert
        map_pitch = lambda x: int(
            interp(pitch_inversion * x, pitch_domain, pitch_range))
        map_yaw = lambda x: int(
            interp(yaw_inversion * x, yaw_domain, yaw_range))

        range0 = 90
        range1 = 45

        po.set_target(self.servo, 1, range0)
        po.set_target(self.servo, 1, range1)

        while True:
            state = ovr.ovrHmd_GetSensorState(self.hmd,
                                              ovr.ovr_GetTimeInSeconds())
            pose = state.Predicted.Pose

            pitch = pose.Orientation.x  # -0.3 ~ 0.7
            #roll = pose.Orientation.z
            yaw = pose.Orientation.y  # -0.7 ~ 0.7

            range0 = map_yaw(yaw)
            range1 = map_pitch(pitch)

            #print("Servo 0 set to {}, servo 1 set to {}".format(range0, range1))
            po.set_target(self.servo, 0, range0)
            po.set_target(self.servo, 1, range1)

            gevent.sleep(0)
Пример #4
0
 def main(self): 
     while self.running:
         #Si no estamos depurando y el movimiento no esta bloqueado, movemos los objetos de acuerdo al movimiento del Oculus
         if not self.debug and not self.moveBlocked:
             #Se obtiene la posición actual del OVR
             ss = ovrsdk.ovrHmd_GetSensorState(self.hmd, ovrsdk.ovr_GetTimeInSeconds())
             pose = ss.Predicted.Pose
             #Valores de posición actuales del OVR
             currp = [pose.Orientation.x,pose.Orientation.y]
             #Movemos la cámara del visualizador de moléculas en sentido al movimiento del OVR
             pymol.cmd.move('x',(currp[1]-self.prevp[1])*self.ovr_sensitivity)
             pymol.cmd.move('y',-(currp[0]-self.prevp[0])*self.ovr_sensitivity)
             #Actualizamos los valores de posición anteriores del OVR
             self.prevp = currp
         #Comprobamos si hay comandos por recibir, en caso de no existir alguno, se ignora el error que generaría el sistema operativo.
         try:
             self.data = self.sock.recv(1024)
         except socket.error:
             pass
         else:
             self.__process_command()
         #Dormimos el programa para disminuir el uso de CPU
         time.sleep(SLEEPTIME)
     pymol.cmd.quit()
Пример #5
0
if __name__ == '__main__':
    hmd = oculus()

    pitch_domain = [-0.3, 0.7]
    yaw_domain = [-0.7, 0.7]
    pitch_range = [0, 180]
    yaw_range = [15, 165]

    map_pitch = lambda x: int(interp(x, pitch_domain, pitch_range))
    map_yaw = lambda x: int(interp(x, yaw_domain, yaw_range))

    range0 = 90
    range1 = 45

    while True:
        state = ovr.ovrHmd_GetSensorState(
            hmd, ovr.ovr_GetTimeInSeconds()
        )
        pose = state.Predicted.Pose

        pitch = pose.Orientation.x # -0.3 ~ 0.7
        #roll = pose.Orientation.z
        yaw = pose.Orientation.y # -0.7 ~ 0.7

        range0 = map_yaw(yaw)
        range1 = map_pitch(pitch)

        print("Servo 0 set to {}, servo 1 set to {}".format(range0, range1))

        sleep(0.05)