40823210 cd2021

  • Home
    • Site Map
    • reveal
    • blog
  • About
  • Stage1-bg18
    • w1
      • LEO
    • w2~w3
      • 零件組合圖-1
      • 爆炸圖
      • Inventor模擬
    • w4(報告)
  • Stage2-bg11
    • w5
    • w6
      • 零件組合圖-2
    • w7
    • w8
    • w9(報告)
  • Stage3-bg2
    • task1
    • task2
      • S1-B18
      • S2-B11
    • task3
    • w10
    • w11
    • w12
    • w13
    • w14
    • w15
    • w16
    • w17
    • w18
  • 影片
    • 第2週
    • 第3週
    • 第4週(報告)
    • 第5週
    • 第6週
    • 第7週
    • 第8週
    • 第9週(報告)
  • gitter討論
  • 筆記
    • 9443
    • 8444
    • OBS
    • Python remote API
    • CoppeliaSim物體顏色、透明度
    • CoppeliaSim碰撞&動態
    • gitlab
    • gitlab-ssh
S1-B18 << Previous Next >> task3

S2-B11

本人是stage2-bg11成員

stage2 所完成的 coppeliasim 場景, 採 Python remote API 進行操控。

----------

(按鍵指令)

1~9..........控制螺旋鉤子
"空白建".....停止螺旋鉤子
Z............關門
X............暫停開/關門
C............開門
O............控制滾輪
W............平台上升
E............暫停平台
S............下降平台
esc..........結束

◾實際操作影片

----------
(程式碼)

import sim as vrep
import math
import random
import time
import keyboard

print ('Start')

# Close eventual old connections
vrep.simxFinish(-1)
# Connect to V-REP remote server
clientID = vrep.simxStart('192.168.0.12', 19997, True, True, 5000, 5)

if clientID != -1:
    print ('Connected to remote API server')
    
    res = vrep.simxAddStatusbarMessage(
        clientID, "40823210",
        vrep.simx_opmode_oneshot)
    if res not in (vrep.simx_return_ok, vrep.simx_return_novalue_flag):
        print("Could not add a message to the status bar.")

    opmode = vrep.simx_opmode_oneshot_wait
    
    vrep.simxStartSimulation(clientID, opmode)
    ret,DOOR_handle=vrep.simxGetObjectHandle(clientID,"joint4",opmode)
    ret,C1_handle=vrep.simxGetObjectHandle(clientID,"joint2",opmode)
    ret,B1_handle=vrep.simxGetObjectHandle(clientID,"joint1",opmode)
    ret,SP5_handle=vrep.simxGetObjectHandle(clientID,"joint",opmode)
    ret,S1_1_handle=vrep.simxGetObjectHandle(clientID,"S1_1",opmode)
    ret,S2_1_handle=vrep.simxGetObjectHandle(clientID,"S2_1",opmode)
    ret,S3_1_handle=vrep.simxGetObjectHandle(clientID,"S3_1",opmode)
    ret,S4_1_handle=vrep.simxGetObjectHandle(clientID,"S4_1",opmode)
    ret,S5_1_handle=vrep.simxGetObjectHandle(clientID,"S5_1",opmode)
    ret,S6_1_handle=vrep.simxGetObjectHandle(clientID,"S6_1",opmode)
    ret,S7_1_handle=vrep.simxGetObjectHandle(clientID,"S7_1",opmode)
    ret,S8_1_handle=vrep.simxGetObjectHandle(clientID,"S8_1",opmode)
    ret,S9_1_handle=vrep.simxGetObjectHandle(clientID,"S9_1",opmode)
    ret,S10_1_handle=vrep.simxGetObjectHandle(clientID,"S10_1",opmode)
    #ret,main = vrep.simxGetObjectHandle(clientID, "main", opmode)
    while True:
    
        #keyboard "5" 
        if keyboard.is_pressed("5"):
            vrep.simxSetJointTargetVelocity(clientID,SP5_handle,1,opmode)
        
        #keyboard "space" 
        if keyboard.is_pressed("space"):
            vrep.simxSetJointTargetVelocity(clientID,SP5_handle,0,opmode)
        #keyboard "O" 
        if keyboard.is_pressed("O"):
            vrep.simxSetJointTargetVelocity(clientID,S1_1_handle,100,opmode)
            vrep.simxSetJointTargetVelocity(clientID,S2_1_handle,100,opmode)
            vrep.simxSetJointTargetVelocity(clientID,S3_1_handle,100,opmode)
            vrep.simxSetJointTargetVelocity(clientID,S4_1_handle,100,opmode)
            vrep.simxSetJointTargetVelocity(clientID,S5_1_handle,100,opmode)
            vrep.simxSetJointTargetVelocity(clientID,S6_1_handle,100,opmode)
            vrep.simxSetJointTargetVelocity(clientID,S7_1_handle,100,opmode)
            vrep.simxSetJointTargetVelocity(clientID,S8_1_handle,100,opmode)
            vrep.simxSetJointTargetVelocity(clientID,S9_1_handle,100,opmode)
            vrep.simxSetJointTargetVelocity(clientID,S10_1_handle,100,opmode)
        #keyboard "W" 
        if keyboard.is_pressed("W"):
            vrep.simxSetJointTargetVelocity(clientID,C1_handle,1,opmode)
            vrep.simxSetJointTargetVelocity(clientID,B1_handle,2,opmode)
         #keyboard "E" 
        if keyboard.is_pressed("E"):
            vrep.simxSetJointTargetVelocity(clientID,C1_handle,0,opmode)
            vrep.simxSetJointTargetVelocity(clientID,B1_handle,0,opmode)   
        #keyboard "S" 
        if keyboard.is_pressed("S"):
            vrep.simxSetJointTargetVelocity(clientID,C1_handle,-1,opmode)
            vrep.simxSetJointTargetVelocity(clientID,B1_handle,-2,opmode)
        #keyboard "Z" 
        if keyboard.is_pressed("Z"):
            vrep.simxSetJointTargetVelocity(clientID,DOOR_handle,1000,opmode)
       #keyboard "X" 
        if keyboard.is_pressed("X"):
            vrep.simxSetJointTargetVelocity(clientID,DOOR_handle,0,opmode)
        #keyboard "C" 
        if keyboard.is_pressed("C"):
            vrep.simxSetJointTargetVelocity(clientID,DOOR_handle,-1.5,opmode)              
        #keyboard "esc" 
        if  keyboard.is_pressed("esc"):
            vrep.simxStopSimulation(clientID, opmode)
            break
        
else:
    print ('Failed connecting to remote API server')
    print ('End')

---------

影片場景之ttt檔及其他相關檔案,可至本人的個人倉儲下載:

https://github.com/40823210/cd2021

(檔案位置:task2 ➝販賣機)


S1-B18 << Previous Next >> task3

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