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
task2 << Previous Next >> S2-B11

S1-B18

本人是stage1-bg18成員

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

----------

(按鍵指令)

Z............拉桿續力
"空白建".....拉桿前推
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,rod_handle=vrep.simxGetObjectHandle(clientID,"joint",opmode)
    ret,ro_handle=vrep.simxGetObjectHandle(clientID,"joint1",opmode)

    #ret,main = vrep.simxGetObjectHandle(clientID, "main", opmode)
    while True:
    
        #keyboard "Z" 
        if keyboard.is_pressed("Z"):
            vrep.simxSetJointTargetVelocity(clientID,rod_handle,1,opmode)
            
        #keyboard "space" 
        if keyboard.is_pressed("space"):
            vrep.simxSetJointTargetVelocity(clientID,rod_handle,-99999,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 ➝水球發射器)


task2 << Previous Next >> S2-B11

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