V-rep学习笔记:Reflexxes Motion Library 2
VREP中的simRMLMoveToPosition函数可以将静态物体按照设定的运动规律移动到指定的目标位置/姿态。If your object is dynamically enabled, it will not work (since in that case the position of the object is dictated by the physics engine). In that case, make sure to uncheck the Body is dynamic checkbox.
下面在原点处创建一个Dummy,为其添加threaded child script(The simRMLMoveToPosition function can only be called from child scripts running in a thread (since this is a blocking operation) ),并使用Graph记录其位置-速度-加速度信息。
local h=simGetObjectAssociatedWithScript(sim_handle_self)
local currentVel={,,,}
local currentAccel={,,,}
local maxVel={0.2,0.2,0.2,0.2}
local maxAccel={0.1,0.1,0.1,0.1}
local maxJerk={0.1,0.1,0.1,0.1}
local targetPos={,,}
local targetVel={,,,}
simRMLMoveToPosition(h,-,-,currentVel,currentAccel,maxVel,maxAccel,maxJerk,targetPos,nil,targetVel)
simWait()
simStopSimulation()
Graph的Data stream type中没有加速度的选项,但是注意下面有个Data transformation(determines how the selected data stream is transformed)选项框可以对原始数据进行微分、积分、缩放、平移等变换。
Raw uses the original data stream, Derivative uses the time derivative of the data stream (e.g. if the raw data stream is the position of an object, then data will be its velocity), Integral uses the time integral of the data stream (e.g. if the raw data is the velocity of an object, then data will be its position) and Cumulative uses the cumulative value of the data stream (e.g. if the raw data is the surface cut by a mill, then data will be the total surface cut by that mill during the simulation). Additionally, the data can be scaled, shifted, and a moving average period specified.
  选择记录Dummy的X方向绝对速度,然后在Data transformations选项框中选择Derivative对数据进行微分,得到X方向加速度:
下图记录了Dummy沿X轴运动1m时的位置、速度、加速度随时间的变化曲线。可以看出在开始的加速阶段,加速度在加加速度(Jerk)限制下以梯形曲线达到最大值0.1m/s2,此后进行一段匀加速直线运动,速度曲线为直线段,位置曲线为二次曲线;达到最大速度0.2m/s时进行匀速直线运动,此时加速度为0,位置曲线为直线段。

另外需要注意的是simRMLMoveToPosition是一个阻塞模式(blocking operation)的函数,前一个函数执行完后才会继续执行下一个。下面连续两行代码让dummy先按规律运动到(1,0,0)处然后再返回远点:
simRMLMoveToPosition(h,-,-,currentVel,currentAccel,maxVel,maxAccel,maxJerk,targetPos,nil,targetVel)
simRMLMoveToPosition(h,-,-,currentVel,currentAccel,maxVel,maxAccel,maxJerk,{,,},nil,targetVel)
使用simRMLMoveToPosition并配合逆运动学可以实现机器人的路径控制:控制Target的目标位置/姿态和运动规律,VREP的运动学逆解解算器会自动让Tip跟随Target运动。下面在场景中拖入ABB IRB4600机器人模型,创建4个路径点pos1~pos4,使机器人按照指定的运动规律依次经过这4个路径点。
-- This is a threaded script! getTargetPosVectorFromObjectPose=function(objectHandle)
local p=simGetObjectPosition(objectHandle,targetBase)
local o=simGetObjectQuaternion(objectHandle,targetBase)
return p,o
end threadFunction=function()
while simGetSimulationState()~=sim_simulation_advancing_abouttostop do -- target is the object that the robot's tooltip will try to follow via IK, which means that
-- if you change the position/orientation of target, then the robot's tooltip will try to follow
-- target is used so that all position and orientation values are always relative to the robot base
-- (e.g. so that if you move the robot to another position, you will not have to rewrite this code!) -- Go to pos1:
targetP,targetO=getTargetPosVectorFromObjectPose(pos1_handle)
simRMLMoveToPosition(target,targetBase,-,nil,nil,maxVel,maxAccel,maxJerk,targetP,targetO,nil)
-- Go to pos2:
targetP,targetO=getTargetPosVectorFromObjectPose(pos2_handle)
simRMLMoveToPosition(target,targetBase,-,nil,nil,maxVel,maxAccel,maxJerk,targetP,targetO,nil)
-- Go to pos3:
targetP,targetO=getTargetPosVectorFromObjectPose(pos3_handle)
simRMLMoveToPosition(target,targetBase,-,nil,nil,maxVel,maxAccel,maxJerk,targetP,targetO,nil)
-- Go to pos4:
targetP,targetO=getTargetPosVectorFromObjectPose(pos4_handle)
simRMLMoveToPosition(target,targetBase,-,nil,nil,maxVel,maxAccel,maxJerk,targetP,targetO,nil)
end
end -- Initialization:
simSetThreadSwitchTiming() target=simGetObjectHandle('IRB4600_IkTarget')
targetBase=simGetObjectHandle('IRB4600') pos1_handle=simGetObjectHandle('pos1')
pos2_handle=simGetObjectHandle('pos2')
pos3_handle=simGetObjectHandle('pos3')
pos4_handle=simGetObjectHandle('pos4') -- Set-up some of the RML vectors:
maxVel={0.4,0.4,0.4,1.8}
maxAccel={0.3,0.3,0.3,0.9}
maxJerk={0.2,0.2,0.2,0.8} -- Here we execute the regular thread code:
res,err=xpcall(threadFunction,function(err) return debug.traceback(err) end)
if not res then
simAddStatusbarMessage('Lua runtime error: '..err)
end
参考:
Reflexxes Motion LibrariesManual and Documentation
V-REP: Reflexxes Motion Library Demonstration
V-rep学习笔记:Reflexxes Motion Library 1
V-rep学习笔记:Reflexxes Motion Library 2的更多相关文章
- V-rep学习笔记:Reflexxes Motion Library 3
		路径规划 VS 轨迹规划 轨迹规划的目的是将输入的简单任务描述变为详细的运动轨迹描述.注意轨迹和路径的区别:Trajectory refers to a time history of positio ... 
- V-rep学习笔记:Reflexxes Motion Library 1
		V-REP中集成了在线运动轨迹生成库Reflexxes Motion Library Type IV,目前Reflexxes公司已经被谷歌收购.(The Reflexxes Motion Librar ... 
- 【HLSL学习笔记】WPF Shader Effect Library算法解读之[DirectionalBlur]
		原文:[HLSL学习笔记]WPF Shader Effect Library算法解读之[DirectionalBlur] 方位模糊是一个按照指定角度循环位移并叠加纹理,最后平均颜色值并输出的一种特效. ... 
- 【HLSL学习笔记】WPF Shader Effect Library算法解读之[Embossed]
		原文:[HLSL学习笔记]WPF Shader Effect Library算法解读之[Embossed] Embossed(浮雕效果) 浮雕效果主要有两个参数:Amount和Wid ... 
- 【HLSL学习笔记】WPF Shader Effect Library算法解读之[BandedSwirl]
		原文:[HLSL学习笔记]WPF Shader Effect Library算法解读之[BandedSwirl] 因工作原因,需要在Silverlight中使用Pixel Shader技术,这对于我来 ... 
- R语言与机器学习学习笔记
		人工神经网络(ANN),简称神经网络,是一种模仿生物神经网络的结构和功能的数学模型或计算模型.神经网络由大量的人工神经元联结进行计算.大多数情况下人工神经网络能在外界信息的基础上改变内部结构,是一种自 ... 
- DirectX Graphics Infrastructure(DXGI):最佳范例 学习笔记
		今天要学习的这篇文章写的算是比较早的了,大概在DX11时代就写好了,当时龙书11版看得很潦草,并没有注意这篇文章,现在看12,觉得是跳不过去的一篇文章,地址如下: https://msdn.micro ... 
- <老友记>学习笔记
		这是六个人的故事,从不服输而又有强烈控制欲的monica,未经世事的千金大小姐rachel,正直又专情的ross,幽默风趣的chandle,古怪迷人的phoebe,花心天真的joey——六个好友之间的 ... 
- (转) OpenCV学习笔记大集锦  与   图像视觉博客资源2之MIT斯坦福CMU
		首页 视界智尚 算法技术 每日技术 来打我呀 注册 OpenCV学习笔记大集锦 整理了我所了解的有关OpenCV的学习笔记.原理分析.使用例程等相关的博文.排序不分先后,随机整理的 ... 
随机推荐
- Orchard模块开发全接触2:新建 ProductPart
			一:创建 Part 1:项目引用 Orchard.Framework: 2:创建 Models 文件夹: 3:在 Models 文件夹下创建类 ProductPartRecord,如下: public ... 
- Generalized normal distribution and Skew normal distribution
			Density Function The Generalized Gaussian density has the following form: where (rho) is the " ... 
- python模块uuid产生唯一id
			使用版本4:uuid4就可以了 UUID4缺点:糟糕的随机数发生器使得它更有可能发生碰撞,但是概率真的很小 UUID1缺点:暴露隐私 If all you want is a unique ID, y ... 
- java操作mongodb(连接池)(转)
			原文链接: java操作mongodb(连接池) Mongo的实例其实就是一个数据库连接池,这个连接池里默认有10个链接.我们没有必要重新实现这个链接池,但是我们可以更改这个连接池的配置.因为Mong ... 
- Python Configparser模块读取、写入配置文件
			写代码中需要用到读取配置,最近在写python,记录一下. 如下,假设有这样的配置. [db] db_host=127.0.0.1 db_port=3306 db_user=root db_pass= ... 
- android动手写控件系列——老猪叫你写相机
			前记:Android这个开源而自由的系统,为我们带来开发便利,同时也埋下太多的深坑.例如调用系统自带的相机就会出现照片丢失,或者其他各种各样的问题.因此,看来自定义一个相机十分的必要. 要自定义相机我 ... 
- 【Spark】SparkStreaming-加载外部配置文件
			SparkStreaming-加载外部配置文件 spark加载配置文件_百度搜索 Spark加载外部配置文件 - CSDN博客 spark读取配置文件中的配置 - CSDN博客 spark加载prop ... 
- gl.h included before glew.h
			So I'm trying to move my OpenGL code from Main() into a specific class that will handle the 3D gra ... 
- win8下everything无法使用的解决方法
			今日我电脑上的Everything打开后都无法使用了,只显示几个分区,重装之后暂时就好了,重启电脑又坏了 解决方法:运行services.msc,启动everything.然后重启everything ... 
- C#.NET常见问题(FAQ)-public private protectd internal有什么区别
			首先要区分public和private,这两个修饰符是最常用的.Public就是对外公开的,private就是对外不公开的(类内部可以使用),比如下面我定义一个类的实例,自动补全代码中只有public ... 
 
			
		