文章目录
- 模型设置
- 设定关节角的代码
- 注意
- 参考链接
模型设置
- 为了避免下图情形发生需要设置模型为非动态的,UR机器人是这样的,但是 KUKA 机器人没有设置也不会散架。
设定关节角的代码
forbidThreadSwitches=function(forbid)
if forbid then
forbidLevel=forbidLevel+1
if forbidLevel==1 then
sim.setThreadAutomaticSwitch(false)
end
else
forbidLevel=forbidLevel-1
if forbidLevel==0 then
sim.setThreadAutomaticSwitch(true)
end
end
end
getConfig=function()
-- Returns the current robot configuration
local config={}
for i=1,#jh,1 do
config[i]=sim.getJointPosition(jh[i])
end
return config
end
setConfig=function(config)
-- Applies the specified configuration to the robot
if config then
for i=1,#jh,1 do
sim.setJointPosition(jh[i],config[i])
end
end
end
function sysCall_threadmain()
-- Initialization phase:
jh={-1,-1,-1,-1,-1,-1}
for i=1,6,1 do
jh[i]=sim.getObjectHandle('UR3_joint'..i)
end
forbidLevel=0
print('Current config: ',getConfig())
forbidThreadSwitches(true)
config_={-70.1*math.pi/180,18.85*math.pi/180,93.18*math.pi/180,68.02*math.pi/180,109.9*math.pi/180,90*math.pi/180}
setConfig(config_)
print('New config',config_)
forbidThreadSwitches(false)
print('New current config: ',getConfig())
end
注意
- 在后面添加手爪之后,非动态的属性会导致无法控制手爪,需要通过代码随时修改机械臂的动态属性来解决。
评论(0)
您还未登录,请登录后发表或查看评论