stage3-ag5

  • Home
    • Site Map
    • reveal
    • blog
  • Introduction
  • Stage1,2
    • stage1
      • stage2
  • week
    • w10
      • task1
      • task2
      • task3
    • w11
      • task3-1
    • w12
    • w13
    • w14
    • w15
    • w16
    • w18
  • FINAL
    • 40823124
    • 40823128
    • 40823120
    • 40823115
    • 40823140
    • 40823139
    • 40823111
FINAL << Previous Next >> 40823128

40823124

part2 測試轉動 

-- just test joints turning by 40823124
function moving1()

    sim.setJointTargetPosition(joint1,45*math.pi/180)
    sim.setJointTargetPosition(joint2,-45*math.pi/180)

    
end
function moving2()

    sim.setJointTargetPosition(joint1,-45*math.pi/180)
    sim.setJointTargetPosition(joint2,45*math.pi/180)

    
end


function sysCall_threadmain()
    
    t=5
    joint1=sim.getObjectHandle('joint1')
    joint2=sim.getObjectHandle('joint2')
    sim.setJointTargetPosition(joint1,0)
    sim.setJointTargetPosition(joint2,0)

    sim.wait(t)
    while sim.getSimulationState()~=sim.simulation_advancing_abouttostopre do
        moving1()
        sim.wait(t)
        moving2()
        sim.wait(t)
        sim.setJointTargetPosition(joint1,0)
        sim.setJointTargetPosition(joint2,0)
        sim.wait(t)
    end

end

part3 按鍵轉動 -40823124

--by 40823124 key press test

function sysCall_init() 
    b1=sim.getObjectHandle('joint1')
    m1=sim.getObjectHandle('joint2')
    s1=sim.getObjectHandle('joint4')
    suctionPad=sim.getObjectHandle('suctionPad')
    BaseFrame=sim.getObjectHandle("BaseFrame")
    block =sim.getObjectHandle("BOX")
    r1 = 0
    r2 = 0
    d3 = 0
    deg = math.pi/180
end
function sysCall_actuation() 

    message, auxiliaryData=sim.getSimulatorMessage()
        while message ~= -1 do
            key=auxiliaryData[1]
            if (message==sim.message_keypress) then
                if (auxiliaryData[1]==101) then 
                    --press e to open the suctionpad
sim.setScriptSimulationParameter(sim.getScriptAssociatedWithObject(suctionPad),'active','true')
                end 
                
                if (auxiliaryData[1]==113) then 
                    --press q to close the suctionpad
sim.setScriptSimulationParameter(sim.getScriptAssociatedWithObject(suctionPad),'active','false')
                end 
                
                if (auxiliaryData[1]==068) then 
                    --press D to turn joint1
                     r1 = r1 + 5*deg
                     sim.setJointPosition(b1, r1)
                end 
                if (auxiliaryData[1]==065) then 
                    --press A to turn joint1
                     r1 = r1  - 5*deg
                     sim.setJointPosition(b1, r1)
                end 
                if (auxiliaryData[1]==100) then 
                    --press d to turn joint2
                     r2 = r2 + 5*deg
                     sim.setJointPosition(m1, r2)
                end 
                if (auxiliaryData[1]==097) then 
                    -- press a to turn joint2
                     r2 = r2 - 5*deg
                     sim.setJointPosition(m1, r2)
                end 
                if (auxiliaryData[1]==119) then 
                    --press s to control joint4
                     d3 =-0.058
                     sim.setJointPosition(s1, d3)
                end 
                if (auxiliaryData[1]==115) then 
                    --press w to control joint4
                     sim.setJointPosition(s1, 0)
                end 
                
           end  
    message, auxiliaryData=sim.getSimulatorMessage()
        end 
end 

part4 lua自動執行 -40823124

>>>>>>> ba3417913a9ac1e0268b21e7fe352c217a93570a


FINAL << Previous Next >> 40823128

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