40823125 協同產品設計實習

  • Home
    • Site Map
    • reveal
    • blog
  • 個人簡介
  • Stage1-ag14
    • W1
    • W2
      • 零件尺寸及示意圖
      • 分組開會紀錄
    • W4
      • PDF
  • 發球機版本
    • 第1版
    • 第2版
    • 第3版
    • 第4版
    • 第5版
  • Stage2-ag12
    • W5
    • 產品目標
    • W7
      • Heroku 網站建立
    • W9
  • 籃球機版本
    • 版本一
    • 版本二
      • 2.1
      • 2.2
      • 2.3
      • 2.4
  • ssh
  • Error exclude
  • stage3-ag6
    • task 1
      • stage3-2a
    • task 2
    • W13
      • gutlab
      • gogs操作
    • W14
      • CoppeliaSim sensor
    • W15
      • fossil 教學
      • Inverse kinematics for a 2-joint robot arm using geometry
      • Inverse kinematics for a 2-joint robot arm using algebra
    • W16
      • MTB Onshape
      • 建立 CoppeliaSim 4.1.0 MTB robot 場景
      • 手臂末端加入 components-gripper-suction pad 吸盤
      • 逆向運動學函式
      • Python remote API 逆向運動學函式
    • W18
      • Sensor
  • Collaborative flowchart
建立 CoppeliaSim 4.1.0 MTB robot 場景 << Previous Next >> 逆向運動學函式

手臂末端加入 components-gripper-suction pad 吸盤

接續MTB Robot keyboard, 在其抓物品的桿件上加suction pad

W16_exam_MTB_robot keyboard add suction pad.7z

Lua程式:

function sysCall_init()
     axis1=sim.getObjectHandle('MTB_axis1')
     axis2=sim.getObjectHandle('MTB_axis2')
     axis3=sim.getObjectHandle('MTB_axis3')
     axis4=sim.getObjectHandle('MTB_axis4') 
     suctionPad=sim.getObjectHandle('suctionPad')     
     rotation1 = 0
     rotation2 = 0
     distance3 = 0
    -- Do some initial settings here
    -- Get object handle
      
     deg = math.pi/180
     --sim.sJointTargetVelocity(joint,5.5)
     
end
 
function sysCall_actuation()
 calibration = 0.01
 message,auxiliaryData=sim.getSimulatorMessage()
 if (message==sim.message_keypress) then
      print(auxiliaryData[1])--key
      if (auxiliaryData[1]==string.byte(' ')) then
      end
       --Display keyboard key code
      if (auxiliaryData[1]==97) then--a
      rotation1 = rotation1 + 5*deg
      sim.setJointPosition(axis1, rotation1)
      end
      -- Press the "a" key to turn axis1 5 degrees counterclockwise
      if (auxiliaryData[1]==100) then --d
      rotation1 = rotation1 - 5*deg
      sim.setJointPosition(axis1, rotation1)
      end
      -- Press the "d" key to turn axis1 5 degrees clockwise
      if (auxiliaryData[1]==119) then--w
      rotation2 = rotation2 + 5*deg
      sim.setJointPosition(axis2, rotation2)
      end
      -- Press the "w" key to turn axis2 5 degrees counterclockwise
      if (auxiliaryData[1]==115) then --s
      rotation2 = rotation2 - 5*deg
      sim.setJointPosition(axis2, rotation2)
      end
      -- Press the "s" key to turn axis2 5 degrees clockwise
      if (auxiliaryData[1]==113) then --q
      distance3 = distance3 + calibration
      sim.setJointPosition(axis3, distance3)
      end
      -- Press the "q" key to move down 0.01
      if (auxiliaryData[1]==101) then --e
      distance3 = distance3 - calibration
      sim.setJointPosition(axis3, distance3)
      end
      -- Press the "e" key to move up 0.01
      if (auxiliaryData[1]==122) then --z 
sim.setScriptSimulationParameter(sim.getScriptAssociatedWithObject(suctionPad),'active','true')
      end -- Press "z" key to activate the suction pad
      if (auxiliaryData[1]==120) then --x
sim.setScriptSimulationParameter(sim.getScriptAssociatedWithObject(suctionPad),'active','false')
      end -- Press "x" key to deactivate the suction pad
      
 end   
 
end
function sysCall_sensing()
    -- put your sensing code here
    
end
 
function sysCall_cleanup()
    -- do some clean-up here
    
end
 


建立 CoppeliaSim 4.1.0 MTB robot 場景 << Previous Next >> 逆向運動學函式

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