40823111 協同產品設計實習

  • Home
    • Site Map
    • reveal
    • blog
  • Introduction
  • leo
    • edit blog
    • edit Reveal
  • old repositories update
  • repositories create
  • ssh
  • stage1
    • week1
    • week2
    • week3
    • week4
  • stage2
    • week5
    • week6
    • week7
    • week8
    • week9
  • stage3
    • week10
      • task1
      • task2
    • week11
      • task3
    • week12
      • topic
      • 影片直播
    • week13
      • RoboDK
      • FANUC_M710iC_50 機械手臂Remote Api
    • week14
    • week15
      • part 1-joint
      • part 2-joint
    • week16
      • Fossil
    • WEEK17
      • w16
      • 心得
    • week18
RoboDK << Previous Next >> week14

FANUC_M710iC_50 機械手臂Remote Api

FANUC_M710iC_50.ttt

import sim as vrep
import sys
import keyboard
import math
import time
# child threaded script: 
#simExtRemoteApiStart(19999)
  
vrep.simxFinish(-1)
clientID = vrep.simxStart('127.0.0.1', 19999, True, True, 5000, 5)
errorCode,left_motor_handle=vrep.simxGetObjectHandle(clientID,'Revolute_joint',vrep.simx_opmode_oneshot_wait)
errorCode,right_motor_handle=vrep.simxGetObjectHandle(clientID,'Revolute_joint1',vrep.simx_opmode_oneshot_wait)
 
 
if clientID!= -1:
    print("Connected to remote server")
    while True: 
        try:
            if keyboard.is_pressed('up'):
                  vrep.simxSetJointTargetVelocity(clientID,left_motor_handle,-0.1, vrep.simx_opmode_oneshot_wait)
                  vrep.simxSetJointTargetVelocity(clientID,right_motor_handle,-0.1, vrep.simx_opmode_oneshot_wait)
                  print('up')
            if keyboard.is_pressed('down'):     
                  vrep.simxSetJointTargetVelocity(clientID,left_motor_handle,0.1, vrep.simx_opmode_oneshot_wait)
                  vrep.simxSetJointTargetVelocity(clientID,right_motor_handle,0.1, vrep.simx_opmode_oneshot_wait)
                  print('down')
            if keyboard.is_pressed('space'):
                  vrep.simxSetJointTargetVelocity(clientID,left_motor_handle,0 , vrep.simx_opmode_oneshot_wait)
                  print('space')
            if keyboard.is_pressed('z'):
                 vrep.simxSetJointTargetVelocity(clientID,left_motor_handle,0 , vrep.simx_opmode_oneshot_wait)
                 print('break ')
                 break
            else:
                pass
        except:
            break
else: 
    print('Connection not successful')
    sys.exit('Could not connect')


RoboDK << Previous Next >> week14

Copyright © All rights reserved | This template is made with by Colorlib