40823129

  • Home
    • Site Map
    • reveal
    • blog
  • About
  • 個人簡介
  • supplement
    • DroidCam  teaching
  • stage1-ag7
    • W1
    • W2
    • W3
    • W4
  • stage2-ag7
    • W5
    • W6
    • W7
      • coppliasim 模擬
      • Heroku
  • stage3-ag6
    • W10
      • task1
      • task2
    • W11
    • W13
      • Robodk
      • gogs
    • W14-W15
    • W16
      • Onshape 零組件繪製
      • CoppeliaSim 4.1.0 MTB robot
      • MTB_robot add suction pad
      • 逆向運動學函式
      • Python remote API 逆向運動學函式
    • W17
      • Basket control program
      • Program introduction and purpose
      • MTB robot controls the pick and place of the ball
    • W18
MTB_robot add suction pad << Previous Next >> Python remote API 逆向運動學函式

逆向運動學函式

W16_exam

影片:

主程式:

function sysCall_init() 
    axis1=sim.getObjectHandle('MTB_axis1')
    axis2=sim.getObjectHandle('MTB_axis2')
    axis3=sim.getObjectHandle('MTB_axis3')
    axis4=sim.getObjectHandle('MTB_axis4')
    mtb3=sim.getObjectHandle('link3')
    suctionPad=sim.getObjectHandle('suctionPad')
    BaseFrame=sim.getObjectHandle("BaseFrame")
    block =sim.getObjectHandle("Cuboid")
    rotation1 = 0
    rotation2 = 0
    distance3 = 0
    modelBase=sim.getObjectHandle(sim.handle_self)
    robotBase=modelBase
    robotName='suctionPad'
    deg = math.pi/180
     
end
function sysCall_actuation() 
    calibration = 0.0042
    message, auxiliaryData=sim.getSimulatorMessage()
        while message ~= -1 do
            key=auxiliaryData[1]
            sim.addStatusbarMessage('????? key:'..key)
            if (message==sim.message_keypress) then
            if (auxiliaryData[1]==112) then --p activate the suction pad
                sim.setScriptSimulationParameter(sim.getScriptAssociatedWithObject(suctionPad),"active",'true')
                end -- if p
                if (auxiliaryData[1]==113) then --q deactivate the suction pad
                sim.setScriptSimulationParameter(sim.getScriptAssociatedWithObject(suctionPad),'active','false')
                end -- if q
                if (auxiliaryData[1]==49) then  
                     rotation1 = 67.8
                     rotation2 = 44.76
                     sim.setJointPosition(axis1, rotation1)
                     sim.setJointPosition(axis2, rotation2)
                end -- if 1
                if (auxiliaryData[1]==50) then  
                     rotation1 = -279.64
                     rotation2 = -49.9
                     sim.setJointPosition(axis1, rotation2)
                     sim.setJointPosition(axis2, rotation1)
                end -- if 2
                if (auxiliaryData[1]==100) then  
                     distance3 = distance3 + 0.03 + calibration
                     sim.setJointPosition(axis4, distance3)
                     --轉軸旋轉 distance3 的數值 (逆轉)
                end -- if d
                if (auxiliaryData[1]==117) then 
                     distance3 = distance3 - 0.03 - calibration
                     sim.setJointPosition(axis4, distance3)
                     --轉軸旋轉 distance3 的數值 (順轉)
                end -- if u 
           end  -- if
    message, auxiliaryData=sim.getSimulatorMessage()
        end -- while
end -- function
function sysCall_sensing()
    -- put your sensing code here
end
function sysCall_cleanup()
    -- do some clean-up here
end
 
-- See the user manual or the available code snippets for additional callback functions and details


MTB_robot add suction pad << Previous Next >> Python remote API 逆向運動學函式

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