40823122

  • Home
    • Site Map
    • reveal
    • blog
  • stage1-ag13
    • w2
      • 網頁建立以及偕同修改
    • w3
      • 分組網站
      • 產品
    • w4
    • w5
  • stage2-ag7
    • w6
    • w7
      • 整合分組網頁
      • v-rep模擬
  • w8
  • stage3-ag6
    • w10
      • task1
      • task2
    • w13
    • w14
    • w15
      • MTB_robort
      • 字幕整理
    • w16
      • 成果
    • w17
      • 籃框移動控制
      • 程式
      • 導入w16的機械手臂
    • w18
程式 << Previous Next >> w18

導入w16的機械手臂

function sysCall_init()
    -- do some initialization here
     axis1=sim.getObjectHandle('MTB_axis1')
     axis2=sim.getObjectHandle('MTB_axis2')
     suctionPad=sim.getObjectHandle('suctionPad')     
     rotation1 = 0
     rotation2 = 0
     
     deg = math.pi/180
     
end
function sysCall_actuation()
 calibration = 0.05
 message,auxiliaryData=sim.getSimulatorMessage()
 if (message==sim.message_keypress) then
      --print(auxiliaryData[1])--key
      --if (auxiliaryData[1]==string.byte(' ')) then
      --end
      if (auxiliaryData[1]==119) then--w
      rotation2 = rotation2 + 1*deg
      sim.setJointPosition(axis2, rotation2)
      end
      -- Press the "w" key to turn axis2 5 degrees counterclockwise
      if (auxiliaryData[1]==115) then --s
      rotation2 = rotation2 - 1*deg
      sim.setJointPosition(axis2, rotation2)
      end
      -- Press the "s" key to turn axis2 5 degrees clockwise
      -- Press the "q" 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
      if (auxiliaryData[1]==49) then --1
      V1=61.2012*deg
      V2=49.5059*deg
      sim.setJointPosition(axis1, V1)
      sim.setJointPosition(axis2, V2)
      end
      if (auxiliaryData[1]==50) then --2
      sim.setJointPosition(axis1, 0)
      sim.setJointPosition(axis2, 0)
      end
      --if (auxiliaryData[1]==51) then --3
      --V1=-158.2529*deg
      --V2=87.7894*deg
      --sim.setJointPosition(axis1, V1)
      --sim.setJointPosition(axis2, V2)
      --end
      
 end    

end


程式 << Previous Next >> w18

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