传统的工业机器人普遍采用电机 、齿轮减速器 、关节轴三者直接连接的传动机构,这种机构要求电机与减速器安装在机械臂关节附近,其缺点是对于多关节机械臂,下一级关节的电机与减速器等驱动装置成为上一级关节的额外负载 。这一额外负载带来的负面影响往往超过机械臂连杆等必要结构件,因此提高了对机械臂动力和驱动元件的要求,由此造成整体重量 、体积 、造价和内部消耗的增加,降低了机械臂对外做功的能力和效率。为了避免这一问题许多主动式医疗机器人采用绳驱动方式,使用柔性绳索远距离的传递运动和力矩。将驱动装置安装到远离相关关节的基座上,使得整个机械臂的结构紧凑 ,在减轻机械臂整体重量的同时提高了对外做功的能力。下图所示的就是达芬奇手术机器人的末端夹子,采用绳驱动方式可以在较小的机械结构内实现多自由度的灵活运动:

  下面尝试在VREP中使用力反馈设备Phantom omni来控制医疗机器人的末端夹子。机构简图如下图所示,一共有5个自由度:其中移动自由度负责进给,一个整体旋转自由度,还有两个左右、上下弯曲的自由度,最后是控制夹子张合的自由度。

  删除Solidworks CAD模型中的一些不必要特征,比如倒角、内部孔、螺纹孔等,导出成STL文件,再导入到VREP中。然后还需要进行继续化简,减少网格数量,当网格数减少到不影响几何外观就可以了。接下来在相应的位置添加关节,设置关节运动范围(软件限位),并将其设为Inverse kinematics模式。

  设置Calculation Modules中的Inverse kinematics:

  搭建好模型后可以先用键盘进行测试,按方向键移动ikTarget,VREP会根据构型自动计算运动学逆解,然后将ikTip移动到ikTarget处(这样就会带着整个机构运动)。键盘控制的脚本代码如下:

if (sim_call_type==sim_childscriptcall_initialization) then

    -- Put some initialization code here
targetHandle = simGetObjectHandle('ikTarget') end if (sim_call_type==sim_childscriptcall_actuation) then -- Put your main ACTUATION code here end if (sim_call_type==sim_childscriptcall_sensing) then -- Put your main SENSING code here
-- Read the keyboard messages (make sure the focus is on the main window, scene view):
message, auxiliaryData = simGetSimulatorMessage() if (message == sim_message_keypress) then if (auxiliaryData[]==) then
-- W key
local p = simGetObjectPosition(targetHandle, -)
p[] = p[] - 0.001
simSetObjectPosition(targetHandle, -, p)
end
if (auxiliaryData[]==) then
-- S key
local p = simGetObjectPosition(targetHandle, -)
p[] = p[] + 0.001
simSetObjectPosition(targetHandle, -, p)
end if (auxiliaryData[]==) then
-- up key
local p = simGetObjectPosition(targetHandle, -)
p[] = p[] + 0.001
simSetObjectPosition(targetHandle, -, p)
end
if (auxiliaryData[]==) then
-- down key
local p = simGetObjectPosition(targetHandle, -)
p[] = p[] - 0.001
simSetObjectPosition(targetHandle, -, p)
end if (auxiliaryData[]==) then
-- left key
local p = simGetObjectPosition(targetHandle, -)
p[] = p[] - 0.001
simSetObjectPosition(targetHandle, -, p)
end
if (auxiliaryData[]==) then
-- right key
local p = simGetObjectPosition(targetHandle, -)
p[] = p[] + 0.001
simSetObjectPosition(targetHandle, -, p)
end end
end if (sim_call_type==sim_childscriptcall_cleanup) then -- Put some restoration code here end

  测试没问题后可以使用CHAI3D插件来连接力反馈设备。这里采用增量控制的模式,即计算当前时刻与前一时刻手柄位置在X、Y、Z方向上的差,然后控制VREP中的ikTarget控制点按相应的增量移动。注意在VREP中机器人向前运动是沿X轴负方向、向上运动是沿Z轴正方向、向右运动是沿Y轴正方向,这与CHAI3D中坐标系的定义一致(向前推手柄是沿着X轴负方向...),因此可以使用力反馈设备直观的控制机器人的运动。当然如果坐标系定义不一致,需要进行简单的转换才行。

  下面的代码在sensing探测部分会使用simExtCHAI3D_readPosition来读取当前操作手柄的位置和按钮状态。按照VREP默认设置,这部分代码会50ms执行一次,这里会出现一个问题:如果采样速率太快,会导致前后两次采集到的位置数据偏差为零(人手的操作频率没那么快,还来不及改变位置),那么输出的控制量就一直是零,这样就没办法用增量控制的方式来操控机器人。解决办法是延迟几个周期再采样,等到有足够大的偏差之后再生成控制量。还有一个问题是使用CHAI3D返回的数据以“米”为单位,而VREP世界中的单位有可能未知,那么使用增量控制时需要对控制量乘一个比例系数,避免因操作端微小的移动造成从动端运动量过大,超出关节限制(无法到达的逆解)。或者可以调节比例系数,用操作端的大位移来控制从动端的小位移,实现精细控制。

if (sim_call_type==sim_childscriptcall_initialization) then
-- Check if the plugin is loaded:
moduleName=
moduleVersion=
index=
pluginNotFound=true
while moduleName do
moduleName,moduleVersion=simGetModuleName(index)
if (moduleName=='CHAI3D') then
pluginNotFound=false
end
index=index+
end if (pluginNotFound) then
simDisplayDialog('Error','CHAI3D plugin was not found, or was not correctly initialized (v_repExtCHAI3D.dll).',sim_dlgstyle_ok,false,nil,{0.8,,,,,},{0.5,,,,,})
else -- Start the device:
local toolRadius = 0.001 -- the radius of the tool
local workspaceRadius = 0.2 -- the workspace radius
if simExtCHAI3D_start(, toolRadius,workspaceRadius) ~= then
simDisplayDialog('Error','Device failed to initialize.',sim_dlgstyle_ok,false,nil,{0.8,,,,,},{0.5,,,,,})
else
CHAI3DPluginInitialized = true end
end targetHandle = simGetObjectHandle('ikTarget') deltaPos = {, , }
counter =
ratio = end if (sim_call_type==sim_childscriptcall_actuation) then
if buttonState == then -- press the button
local p = simGetObjectPosition(targetHandle, -) -- get the target position
-- add increment of the tool tip
p[] = p[] + deltaPos[] / ratio
p[] = p[] + deltaPos[] / ratio
p[] = p[] + deltaPos[] / ratio
simSetObjectPosition(targetHandle, -, p) -- move to the absolute position
end
end if (sim_call_type==sim_childscriptcall_sensing) then
if CHAI3DPluginInitialized then
-- Read the current position of the cursor:
local currentToolPosition = simExtCHAI3D_readPosition() -- Read the buttons of the device:
buttonState = simExtCHAI3D_readButtons() counter = counter + -- increase the counter if counter % == then -- keep the value
prevToolPosition = currentToolPosition
end if counter % == then -- calculate tool tip increment
deltaPos[] = currentToolPosition[] - prevToolPosition[] -- X-axis increment
deltaPos[] = currentToolPosition[] - prevToolPosition[] -- Y-axis increment
deltaPos[] = currentToolPosition[] - prevToolPosition[] -- Z-axis increment
counter = -- reset counter local info = string.format("CurrentPosition:%.2f,%.2f,%.2f DeltaPosition:%.2f,%.2f,%.2f",
currentToolPosition[],currentToolPosition[],currentToolPosition[],
deltaPos[],deltaPos[],deltaPos[])
simAddStatusbarMessage(info) end end
end if (sim_call_type==sim_childscriptcall_cleanup) then
if CHAI3DPluginInitialized then -- Disconnects all devices and removes all objects from the scene
simExtCHAI3D_reset()
end
end

  将力反馈设备手柄移动到合适的位置之后就可以按住按钮开始操控机器人,松开按钮会停止控制。如果在VREP虚拟场景中添加其它物体(比如障碍物),则还可以模拟环境中的力(接触力、重力、摩擦力、弹簧力等)让操控着“感觉”到。如果实际机器人上装有力传感器,则在用Phantom omni控制机器人的同时也能读取力的信息,反馈给操作者。

  下面是使用Phantom omni来控制机器人的动态图,黄色的轨迹为使用Graph记录的控制点的空间位置:

  对于该机构也可以自己实现运动学逆解的数值算法,下面给出伪逆矩阵法和阻尼最小二乘法的参考:

import math
import numpy as np # link length
L1 = 1
L2 = 1 gamma = 1 # step size
lamda = 0.2 # damping constant (DLS-method)
stol = 1e-3 # tolerance
nm = 10 # initial error
count = 0 # iteration count
ilimit = 20 # maximum iteration # numerical method for inverse kinematics
method = 'Pseudo Inverse' # 'Pseudo Inverse', 'DLS', ... # initial joint value
q = np.array([0, 0, math.pi/2, 0]) # [theta1, d1, theta2, theta3] # target position
target_pos = np.array([1, 0, 2]) # [x,y,z] while True:
if(nm > stol):
# forward kinematics:
x = np.array([math.cos(q[0])*math.cos(q[2])*(L1+L2*math.cos(q[3]))+L2*math.sin(q[0])*math.sin(q[3]),\
math.cos(q[2])*math.sin(q[0])*(L1+L2*math.cos(q[3]))-L2*math.cos(q[0])*math.sin(q[3]),\
q[1]+(L1+L2*math.cos(q[3]))*math.sin(q[2])]) # compute error
error = target_pos - x # compute Jacobian
J11 = -math.sin(q[0])*math.cos(q[2])*(L1+L2*math.cos(q[3]))+L2*math.cos(q[0])*math.sin(q[3])
J12 = 0
J13 = -math.sin(q[2])*math.cos(q[0])*(L1+L2*math.cos(q[3]))
J14 = L2*(math.sin(q[0])*math.cos(q[3])-math.cos(q[0])*math.cos(q[2])*math.sin(q[3]))
J21 = math.cos(q[0])*math.cos(q[2])*(L1+L2*math.cos(q[3]))+L2*math.sin(q[0])*math.sin(q[3])
J22 = 0
J23 = -math.sin(q[0])*math.sin(q[2])*(L1+L2*math.cos(q[3]))
J24 = -L2*(math.cos(q[0])*math.cos(q[3])+math.sin(q[0])*math.cos(q[2])*math.sin(q[3]))
J31 = 0
J32 = 1
J33 = math.cos(q[2])*(L1+L2*math.cos(q[3]))
J34 = -L2*math.sin(q[2])*math.sin(q[3]) J = np.array([[J11,J12,J13,J14],[J21,J22,J23,J24],[J31,J32,J33,J34]]) if method == 'Pseudo Inverse':
# Pseudo Inverse Method
J_pseudo = np.dot(J.transpose(), np.linalg.inv(J.dot(J.transpose()))) # compute pseudo inverse
dq = gamma * J_pseudo.dot(error) if method == 'DLS':
# Damped Least Squares Method
f = np.linalg.solve(J.dot(J.transpose())+lamda**2*np.identity(3), error)
dq = np.dot(J.transpose(), f) # update joint position
q = q + dq nm = np.linalg.norm(error) count = count + 1
if count > ilimit:
print "Solution wouldn't converge!"
break
else:
# print result
print 'theta1=' + str(q[0]*180/math.pi)+' d1='+str(q[1]) + ' theta2=' + str((q[2]-math.pi/2)*180/math.pi)+' theta3=' + str(q[3]*180/math.pi)
print 'Current position: %.2f, %.2f, %.2f' %(x[0],x[1],x[2])
print str(count)+' iterations'+' err:'+str(nm)
break

参考:

OpenHaptics编程环境搭建

VREP中的力触觉设备接口(CHAI3D)

“逆运动学”——从操作空间到关节空间(上篇)

使用Phantom omni力反馈设备控制机器人的更多相关文章

  1. ROS(indigo)机器人操作系统学习资料和常用功能包汇总整理(ubuntu14.04LTS)

    ROS(indigo)机器人操作系统学习资料和常用功能包汇总整理(ubuntu14.04LTS) 1. 网站资源: ROSwiki官网:http://wiki.ros.org/cn GitHub    ...

  2. OpenHaptics编程环境搭建

    SensAble Technologies公司是3D可触摸(力反馈)解决方案和技术领域中的领先开发商,其解决方案和技术不仅使用户能够看到并听到屏幕计算机应用,还可以对该应用进行实际“感应”.该公司的P ...

  3. VREP中的力触觉设备接口(CHAI3D)

    力反馈技术是一种新型的人机交互技术,它允许用户借助力反馈设备触碰.操纵计算机生成的虚拟环境中的物体,并感知物体的运动和相应的力反馈信息,实现人机力觉交互.虽然传统的鼠标.键盘.触摸屏等交互手段可以满足 ...

  4. Phantom omini设备开发流程

    最近在忙着做毕业设计,我的毕业设计是做力觉临场感的,所以在力反馈设备Phantom Omini,由于整个设备是国外的国内的资料很少,我是14年拿到这个设备的但是真的是在开发是在16年了,中间有很多事没 ...

  5. 玩转12款Linux开源机器人

    玩转12款Linux开源机器人 头条网2016-02-15 09:04 3DR Solo智能无人机发布于2015年中期.作为试图与大疆广受欢迎的Phantom系列无人机相抗衡的产品,它的双处理器运行L ...

  6. 机器人操作系统 除了Android还有一个ROS(转)

    你知道市面上的机器人都采用了哪些操作系统吗? 估计大多数人给出的答案就是 Android 了.从市面上的产品来看,基于 Android 系统开发的机器人确实是主流,但是还有一种操作系统却鲜为人知,它叫 ...

  7. ROS机器人程序设计(原书第2版)补充资料 (伍) 第五章 计算机视觉

    ROS机器人程序设计(原书第2版)补充资料 (伍) 第五章 计算机视觉 书中,大部分出现hydro的地方,直接替换为indigo或jade或kinetic,即可在对应版本中使用. 计算机视觉这章分为两 ...

  8. SLAM+语音机器人DIY系列:(二)ROS入门——1.ROS是什么

    摘要 ROS机器人操作系统在机器人应用领域很流行,依托代码开源和模块间协作等特性,给机器人开发者带来了很大的方便.我们的机器人“miiboo”中的大部分程序也采用ROS进行开发,所以本文就重点对ROS ...

  9. phantomjs + python 打造一个微信机器人

    phantomjs + python 打造一个微信机器人 1.前奏   媳妇公司不能上网,但经常需要在公众号上找一些文章做一些参考,需要的时候就把文章链接分享给我,然后我在浏览器打开网页,一点点复制过 ...

随机推荐

  1. Makefile:160: recipe for target 'all' failed (Ubuntu 16.06 + Opencv3.2)解决办法

    前言 之前一直用的opencv 好好的,今天安装了anaconda之后,python中的opencv不能用了,即便是拷贝cv2.so之后也是不能用,问题如下: 根本原因 安装anaconda之后,很多 ...

  2. Statistical Artifact (error)

    In natural science and signal processing, an artifact is any error in the perception or representati ...

  3. serializeArray()与 serialize()

    serialize()序列表表格内容为字符串,用于 Ajax 请求. serializeArray()序列化表格元素 (类似 '.serialize()' 方法) 返回 JSON 数据结构数据. .s ...

  4. cannot be resolved. It is indirectly referenced from required .class files

    缺少引用. 把缺少的引用在导入一下...如果是mavan 在当前moudle里也要把 dependency加进来

  5. rank,dense_rank,row_number使用和区别

    rank,dense_rank,row_number区别 一:语法(用法):     rank() over([partition by col1] order by col2)      dense ...

  6. USB线插拔检测使用UEventObserver检测uevent事件的分析

    说实话这玩样儿的代码量真的很少,大家如果能耐得住性子啃一会儿也就能撸懂了. 在这之前研究USB线插拔的时候就知道了有这么个东西,当时也就看了看,但没做什么笔记.最近想用起来,却发现就只有个名字在记忆中 ...

  7. uva 331 Mapping the Swaps 求交换排序的map 纯DFS

    给出一个序列,每次交换两个数,求有几种交换方法能使序列变成升序. n不大于5,用dfs做. 代码: #include <cstdio> #include <cstring> # ...

  8. Linux修改终端显示前缀及环境变量

    Linux终端前面默认显示一长串,如: [work@aaa.baidu.com dir]$ 这是由PS1环境变量决定的: [work@aaa.baidu.com dir]$ echo $PS1 [\u ...

  9. 菜鸟学步之 爆破AspriseOCR 4.0

    最近写一个小程序要用到OCR控件,在网上查了一下,据说AspriseOCR 4.0效果不错.试用了一下发现的确还行,不过就是要注册,试用版本每次都会弹出讨厌的对话框来.网上看到有一篇“新人报道–处女破 ...

  10. linux服务器上面部署ShowDoc 安装Composer

    1.安装Composer Composer 是 PHP 的一个依赖管理工具,功能上类似于Java 的 Maven,Python 的 pip,Ruby的 gem,Nodejs 的 npm.详细介绍可参考 ...