40823208 cd2021

  • Home
    • Site Map
    • reveal
    • blog
  • About
  • 影片
  • Stage1 小組作業
    • stage1小組討論
    • stage1小組進度 (w2~w4)
    • W4 stage1小組報告
    • 各組影片表格
  • Stage2小組作業
    • stage2小組討論
    • stage2小組進度 (w5~w9)
    • W9 stage2小組報告
  • Stage3小組作業
    • coppeliasim測試
    • stage3小組討論
    • stage3小組進度(w10~w18)
    • task1
    • task2
    • task3
  • W5
  • w15
  • w16
task1 << Previous Next >> task3

task2

分球機模擬檔

05/04 利用remoteApi控制stage1小組作業(分球機)旋轉軸速度

第一版

import sim as vrep
import math
import random
import time
 
print ('Start')
 
# Close eventual old connections
vrep.simxFinish(-1)
# Connect to V-REP remote server
clientID = vrep.simxStart('172.20.10.2', 19997, True, True, 5000, 5)
if clientID !=-1:
    print ('Connected to remote API server')
 
    res = vrep.simxAddStatusbarMessage(
        clientID, "40823208",
        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, wristHandle = vrep.simxGetObjectHandle(clientID, "joint",opmode)
    
    vrep.simxSetJointTargetVelocity(clientID,wristHandle,5,opmode)
    
else:
    print ('Failed connecting to  remote API server')
print ('End')

05/12 新增鍵盤控制分球機轉速

第二版

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.1.83', 19997, True, True, 5000, 5)
if clientID !=-1:
    print ('Connected to remote API server')
 
    res = vrep.simxAddStatusbarMessage(
        clientID, "40823208",
        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, wristHandle = vrep.simxGetObjectHandle(clientID, "joint",opmode)
while True:
     if keyboard.is_pressed("Q"):
            print("Velocity=5")
            vrep.simxSetJointTargetVelocity(clientID,wristHandle,5,opmode)
            #Q可以讓轉速=5
     if keyboard.is_pressed("W"):
            print("Velocity=10")
            vrep.simxSetJointTargetVelocity(clientID,wristHandle,10,opmode)
            #W可以讓轉速=10
     if keyboard.is_pressed("E"):
            print("Velocity=0")
            vrep.simxSetJointTargetVelocity(clientID,wristHandle,0,opmode)       
            #E可以讓轉速=0
else:
    print ('Failed connecting to  remote API server')
print ('End')


task1 << Previous Next >> task3

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