40823247

  • Home
    • Site Map
    • reveal
    • blog
  • About
  • Stage1
    • W1
    • W2
    • W3
    • W4
    • 自動旋轉烤肉機
  • Stage2
    • W5
    • W6
    • W7
    • W8
    • W9
    • 多功能腳踏車衝擊測試機
  • stage3
    • W10
    • W11
    • W12
    • W13
  • W16
  • Task
    • Mission
    • task1
    • task2
    • task3
    • Robot Pick and Place
  • Others
    • Fix cmsimde
    • Update cmsimde
    • leo
    • github提交沒有顯示頭像
    • 組員合併倉儲產生衝突
    • 轉移Github倉儲資料至GOGS
  • Videos
task1 << Previous Next >> task3

task2

task2:http://mde.tw/cd2021/content/task2.html

各組員分別將個人在 stage1 與 stage2 所完成的 coppeliasim 場景, 採 Python remote API 進行操控, 並將過程拍成影片後, 放在個人與分組網站上.

下載檔案:

https://drive.google.com/file/d/1FErGMzyfP5MTvf8cLc1Ox2xHJhuDN1XH/view?usp=sharing

檔案裡面有以下資料

005.ttt為模型檔

api.py是remoteAPI檔

打開coppeliasim4.2.0

點選open scene打開005.ttt

將api.py檔拉進白窗

若要操控自己電腦的coppeliasim,將位址改成127.0.0.1即可。

到白窗按go即可,回到coppeliasim,按OK即可操作機械手臂

---------------------------

按鍵space為停止動作

按鍵A為主軸順時針旋轉

按鍵B為主軸逆時針旋轉

按鍵W為大臂向上

按鍵S為大臂向下

按鍵E為小臂向上

按鍵D為小臂向下

按鍵R為小臂旋轉

按鍵J為手肘向上

按鍵K為手肘向下

------------------------

# File created by Thibaut Royer, Epitech school
# thibaut1.royer@epitech.eu
# It intends to be an example program for the "Two wheels, one arm" educative project.
  
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('127.0.0.1', 19997, True, True, 5000, 5)
  
if clientID != -1:
    print ('Connected to remote API server')
      
    res = vrep.simxAddStatusbarMessage(
        clientID, "40823218",
        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.")
  
    # Communication operating mode with the remote API : wait for its answer before continuing (blocking mode)
    # http://www.coppeliarobotics.com/helpFiles/en/remoteApiConstants.htm
    opmode = vrep.simx_opmode_oneshot_wait
    STREAMING = vrep.simx_opmode_streaming
  
    # Try to retrieve motors and robot handlers
    # http://www.coppeliarobotics.com/helpFiles/en/remoteApiFunctionsPython.htm#simxGetObjectHandle
    vrep.simxStartSimulation(clientID, opmode)
    ret,base_handle=vrep.simxGetObjectHandle(clientID,"joint1",opmode)
    ret,bottom_handle=vrep.simxGetObjectHandle(clientID,"joint2",opmode)
    ret,top_handle=vrep.simxGetObjectHandle(clientID,"joint3",opmode)
    ret,rotate_handle=vrep.simxGetObjectHandle(clientID,"joint4",opmode)
    ret,wrist_handle=vrep.simxGetObjectHandle(clientID,"joint5",opmode)
    while True:
        #Clockwise
        if keyboard.is_pressed("a"):
         vrep.simxSetJointTargetVelocity(clientID,base_handle,0.2,opmode)
        #anti-Clockwise
        if keyboard.is_pressed("f"):
         vrep.simxSetJointTargetVelocity(clientID,base_handle,-0.2,opmode)
        #bottom_handle up
        if keyboard.is_pressed ("w"):
         vrep.simxSetJointTargetVelocity(clientID,bottom_handle,0.2,opmode)
        #bottom_handle down
        if keyboard.is_pressed ("s"):
         vrep.simxSetJointTargetVelocity(clientID,bottom_handle,-0.2,opmode)
         #top_handle up
        if keyboard.is_pressed ("e"):
         vrep.simxSetJointTargetVelocity(clientID,top_handle,0.2,opmode)
         #top_handle down
        if keyboard.is_pressed ("d"):
         vrep.simxSetJointTargetVelocity(clientID,top_handle,-0.2,opmode)
         #rotate
        if keyboard.is_pressed ("r"):
         vrep.simxSetJointTargetVelocity(clientID,rotate_handle,0.2,opmode)
         #wrist_handle left
        if keyboard.is_pressed ("j"):
         vrep.simxSetJointTargetVelocity(clientID,wrist_handle,0.2,opmode)
         #wrist_handle right
        if keyboard.is_pressed ("k"):
         vrep.simxSetJointTargetVelocity(clientID,wrist_handle,-0.2,opmode)
         #stop
        if keyboard.is_pressed ("space"):
         vrep.simxSetJointTargetVelocity(clientID,base_handle,0,opmode)
         vrep.simxSetJointTargetVelocity(clientID,bottom_handle,0,opmode)
         vrep.simxSetJointTargetVelocity(clientID,top_handle,0,opmode)
         vrep.simxSetJointTargetVelocity(clientID,rotate_handle,0,opmode)
         vrep.simxSetJointTargetVelocity(clientID,wrist_handle,0,opmode)
  
  
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