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
task1 << Previous Next >> week11

task2

採 Python remote API 進行操控

step1  

先把5個檔案放在同一個資料夾

step2

打開CoppliaSim(4.2.0)把你要的檔案丟進去  

step3

把程式複製放在主體的上面(如果沒有可以自己新增)

threadFunction=function()
	-- Put your thread code here (initialization and clean-up code should not be in here)

	
	-- Some EXTERNAL commands (e.g. socket commands provided by Lua libraries)
	-- might appear as blocking to the simulator. In that case, you can define
	-- a non-blocking section as following example shows:
	--
	-- sim.setThreadIsFree(true) -- Start of the non-blocking section
	--
	-- Following 2 lines are meant as an example of EXTERNAL blocking commands:
	-- http = require("socket.http")
	-- print(http.request("http://www.google.com"))
	--
	-- sim.setThreadIsFree(false) -- End of the non-blocking section
	--
	-- While in a non-blocking section, try to avoid calling sim-functions. Also
	-- never forget to close the blocking section, otherwise V-REP will hang.
	-- Make sure you read the information related to the sim.setThreadIsFree
	-- API function in V-REP's documentation.


	-- If you wish to synchronize a threaded loop with each simulation pass,
	-- set the thread switch timing in the initialization phase of this script
	-- to the maximum (200), and manually switch thread here with the
	-- sim.switchThread() command. 
	-- ( sim.switchThread() will suspend this script's execution until next
	-- simulation pass, i.e. until the simulation time has changed )
	--
	-- Following example illustrates this:
	-- 
	-- while true do
	--     local p=sim.getObjectPosition(objHandle,-1)
	--     p[1]=p[1]+0.001
	--     sim.setObjectPosition(objHandle,-1,p)
	--     sim.switchThread()
	-- end
end

-- Put some initialization code here:
sim.setThreadSwitchTiming(2) -- Default timing for automatic thread switching

-- Here we execute the regular thread code:
res,err=xpcall(threadFunction,function(err) return debug.traceback(err) end)
if not res then
	sim.addStatusbarMessage('Lua runtime error: '..err)
end

-- Put some clean-up code here:
simRemoteApi.start(19999)

task1 << Previous Next >> week11

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