w17 << 
Previous Next >> 程式
籃框移動控制
function sysCall_init()
    -- do some initialization here
     j=sim.getObjectHandle('slide') --定義籃框伸縮軸
     d = 0 --posion
     a=10 --定義a與b的基礎值方便底下程式運算
     b=0
     distance=0.001  --籃框的位移量
     --sim.sJointTargetVelocity(joint,5.5)
end
  
function sysCall_actuation()
      if (a==10) then --在a等於10的情況下
      d = d - distance  --對d原本為0的值持續改變座標
      sim.setJointPosition(j, d)--設定軸位置的語法(對應軸的代號/位置)
      end
      if(d<=-0.5)then  --如果軸的位置到達設定範圍
      a=0  --更改初始值
      b=10
      end
      if (b==10) then
      d = d + distance
      sim.setJointPosition(j, d)
      end
      if(d>=0.5)then
      a=10
      b=0
      end
      end 
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
w17 << 
Previous Next >> 程式