1. 程式人生 > >V-rep學習筆記:機器人路徑規劃1

V-rep學習筆記:機器人路徑規劃1

 1 visualizePath = function(path)
 2     if not _lineContainer then
 3 -- simAddDrawingObject: Adds a drawing object that will be displayed in the scene
 4 -- Lua parameters:
 5     --sim_drawing_lines:items are pixel-sized lines(6 values per item (x0;y0;z0;x1;y1;z1) + auxiliary values)
 6     --size: size of the item (width of lines or size of points are in pixels, other sizes are in meters
7 --parentObjectHandle: handle of the scene object where the drawing items should keep attached to. if the scene 8 --object moves, the drawing items will also move,-1 if the drawing items are relative to the world (fixed) 9 --maxItemCount: maximum number of items this object can hold.
10 --ambient_diffuse: default ambient/diffuse color (pointer to 3 rgb values). Can be NULL 11 _lineContainer = simAddDrawingObject(sim_drawing_lines, 3, 0, -1, 99999, {0.2,0.2,0.2}) 12 end 13 14 -- Adds an item (or clears all items) to a previously inserted drawing object. 15 -- itemData: data relative to an item. If the item is a point item, 3 values are required (x;y;z).
16 -- If the item is a line item, 6 values are required, If nil the drawing object is emptied of all its items 17 simAddDrawingObjectItem(_lineContainer, nil) -- clear all items 18 19 if path then 20 local pc = #path / 3 21 for i=1, pc - 1,1 do 22 lineDat = {path[(i-1)*3+1], path[(i-1)*3+2], initPos[3], path[i*3+1], path[i*3+2], initPos[3]} 23 simAddDrawingObjectItem(_lineContainer, lineDat) 24 end 25 end 26 end 27 --------------------------------------------------------------------------------------------------------------------- 28 29 robotHandle = simGetObjectHandle('StartConfiguration') 30 targetHandle = simGetObjectHandle('GoalConfiguration') 31 32 initPos = simGetObjectPosition(robotHandle, -1) --Specify -1 to retrieve the absolute position 33 initOrient = simGetObjectOrientation(robotHandle, -1) 34 35 -- Create a task object, used to represent the motion planning task 36 -- Lua synopsis: number taskHandle = simExtOMPL_createTask(string name) 37 t = simExtOMPL_createTask('t') 38 39 -- Create a component of the state space for the motion planning problem 40 -- stateSpaceHandle=simExtOMPL_createStateSpace(name,type,objectHandle,boundsLow,boundsHigh,useForProjection) 41 ss = {simExtOMPL_createStateSpace('2d',sim_ompl_statespacetype_pose2d,robotHandle,{-0.5,-0.5},{0.5,0.5},1)} 42 43 -- Set the state space of this task object 44 -- Lua synopsis: number result=simExtOMPL_setStateSpace(number taskHandle, table stateSpaceHandles) 45 simExtOMPL_setStateSpace(t, ss) 46 47 -- Set the search algorithm for the specified task. Default algorithm used is KPIECE1 48 -- Lua synopsis: number result=simExtOMPL_setAlgorithm(number taskHandle, number algorithm) 49 simExtOMPL_setAlgorithm(t,sim_ompl_algorithm_RRTConnect) 50 51 52 -- Set the collision pairs for the specified task object. 53 -- Lua synopsis: number result=simExtOMPL_setCollisionPairs(number taskHandle, table collisionPairHandles) 54 --[[ 55 Lua parameters: 56 collisionPairHandles: a table containing 2 entity handles for each collision pair. A collision pair is represented 57 by a collider and a collidee, that will be tested against each other. The first pair could be used for robot 58 self-collision testing, and a second pair could be used for robot-environment collision testing. The collider can 59 be an object or a collection handle. The collidee can be an object or collection handle, or sim_handle_all, in which 60 case the collider will be checked agains all other collidable objects in the scene. 61 --]] 62 simExtOMPL_setCollisionPairs(t,{simGetObjectHandle('L_start'),sim_handle_all}) 63 64 startpos = simGetObjectPosition(robotHandle, -1) 65 startorient = simGetObjectOrientation(robotHandle, -1) 66 startpose={startpos[1], startpos[2], startorient[3]} 67 68 -- Set the start state for the specified task object 69 -- Lua synopsis: number result=simExtOMPL_setStartState(number taskHandle, table state) 70 -- state: a table of numbers, whose size must be consistent with the robot's state space specified in this task object 71 simExtOMPL_setStartState(t, startpose) 72 73 goalpos = simGetObjectPosition(targetHandle,-1) 74 goalorient = simGetObjectOrientation(targetHandle,-1) 75 goalpose = {goalpos[1], goalpos[2], goalorient[3]} 76 77 -- Set the goal state for the specified task object 78 simExtOMPL_setGoalState(t, goalpose) 79 80 -- Use OMPL to find a solution for this motion planning task. 81 -- number result,table states=simExtOMPL_compute(number taskHandle,number maxTime,number maxSimplificationTime=-1,number stateCnt=0) 82 -- return value: states--a table of states, representing the solution, from start to goal. States are specified linearly. 83 r, path = simExtOMPL_compute(t, 4, -1, 800) 84 85 visualizePath(path) 86 ---------------------------------------------------------------------------------------------------------------------------------- 87 88 -- Simply jump through the path points, no interpolation here: 89 for i=1, #path-3, 3 do -- count from 1 to len(path)-3 with increments of 3 90 pos={path[i], path[i+1], initPos[3]} 91 orient={initOrient[1], initOrient[2], path[i+2]} 92 simSetObjectPosition(robotHandle, -1, pos) 93 simSetObjectOrientation(robotHandle, -1, orient) 94 simSwitchThread() 95 end

相關推薦

運動規劃 V-rep學習筆記機器人路徑規劃1

轉載:https://www.cnblogs.com/lvchaoshun/p/6681541.html 1.引言   如 果你想要讓機器人能幫你拿瓶子、做飯、收拾屋子等,就必須賦予機器人快速生成無碰撞、最優運動軌跡的能力,這就需要靠運動規劃了。有人覺得運動規劃已經很 成熟了,無需再研究,但實際上,機械臂

V-rep學習筆記機器人路徑規劃1

1 visualizePath = function(path) 2 if not _lineContainer then 3 -- simAddDrawingObject: Adds a drawing object that will be displayed in the scene

V-rep學習筆記機器人逆運動學解算

uri strong sometimes dir pan eve 歐拉 lec oid IK groups and IK elements   VREP中使用IK groups和IK elements來進行正/逆運動學計算,一個IK group可以包含一個或者多

V-rep學習筆記視覺傳感器2

存在 bsp ping repr sim isp cif ron depth   視覺傳感器的屬性設置欄中還有如下幾個選項: Ignore RGB info (faster): if selected, the RGB information of the sensor

V-rep學習筆記串口操作

轉換 serial put 函數 ads 兩個 溫度 over display   VREP Regular API提供了串口操作的相關函數,可以對串口進行打開、關閉和讀寫:   下面使用一款淘寶上常見的AHRS(Attitude and heading referenc

V-rep學習筆記ROSInterface

comm sim itl 幫助 ubuntu下 具體步驟 按鈕 publisher 壓縮 Ubuntu 14.04 上安裝V-rep 3.4.0   進入VREP官網下載Linux版本的V-rep(註意V-rep 3.4.0只有64位的版本,因此操作系統也要與之對應,U

深度優先搜尋筆記2-機器人路徑規劃

以下程式碼改編自《啊哈,演算法》,原始碼只輸出了路徑的步數,改編後可以輸出所有可行路徑與最最短路徑。 問題: 已知地圖map,給定起點和目標點,要求輸出從起點到目標點的所有路徑,並計算最短的路徑 程式碼: /* 已知地圖map,給定起點和目標點,

流程python學習筆記第五章(1)

第五章:一等函式 在python中一切都可以視作為物件,包括函式。我們來看個例子: def function_try():     '''it is funciton try doc'''     print 'function_try' if __name__=="_

學習筆記axure 高階教程 1 動態面板製作tab切換效果

1. 例項截圖分析     淘寶的登入框主要分為了2個頁面標籤,淘寶會員和支付寶會員,登入者在這2個不同的標籤頁進行切換選擇自己的登入方式,並且未選中狀態層呈突出顯示。其他都是一些文字面板加文字框、複選框、按鈕元件可以製作的。重點是如何實現這2個標籤在點選下自動切換。

20180821 Python學習筆記如何獲取當前程序路徑

con awl tab style onf getcwd nbsp 為知筆記 想要 20180821 Python學習筆記:如何獲取當前程序路徑啟動的腳本的路徑為:D:\WORK\gitbase\ShenzhenHouseInfoCrawler\main.py當前腳本的路徑

開源機器人庫orocos KDL 學習筆記Kinematric Trees

上一篇主要講述了機器人學中用到的幾何基礎知識,以及在KDL中的實現和使用。本篇將更加深入的涉及到機器人學中的內容,主要是如何表示串聯型機械臂,以及KDL中的實現方式。 KDL中使用了兩個使用廣泛且技術成

學習筆記瀏覽器渲染優化——關鍵渲染路徑

幀 但瀏覽器還需要對每幀進行處理,所以要在10ms內完成所有任務並及時渲染每幀。 渲染樹(render tree) 只有實際上會顯示在網頁上的元素,才會進入渲染樹 它和DOM樹很

概率機器人學習筆記遞迴狀態估計

       不再可能情況的單一“最好推測”,而用概率演算法表示整個推測空間的概率分佈資訊。其核心為模糊性和置信度,通過在整個空間上的概率密度函式來表示機器人的瞬時置信度<機器人瞬時位置各可能點的各自概率>,機器人感知問題用概率來描述,就是一個狀態估計問題。概率演

Vue.js學習筆記屬性繫結 v-bind

v-bind  主要用於屬性繫結,Vue官方提供了一個簡寫方式 :bind,例如: <!-- 完整語法 --> <a v-bind:href="url"></a> <!-- 縮寫 --> <a :href="url"

Vue.js學習筆記在元素 和 template 中使用 v-if 指令

語法比較簡單,直接上程式碼: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <hea

c++學習筆記動態規劃(最長公共子序列,01揹包問題,金錢兌換問題)

/* 參考書:演算法設計技巧與分析 M.H.Alsuwaiyel著 吳偉旭 方世昌譯 ---------------------------------------------------------------- 1.遞迴 將問題分成相似的子問題 1.1Fa

Linux學習筆記存儲管理

linux 磁盤管理 Linux系統中所有的硬件設備都是通過文件的方式來表現和使用的,我們將這些文件稱為設備文件,在Linux下的/dev目錄中有大量的設備文件,根據設備文件的不同,又分為字符設備文件和塊設備文件。字符設備文件的存取是以字符流的方式來進行的,一次傳送一個字符。常見的有打印

學習筆記javascript內置對象數組對象

b- sort splice 刪除 分隔 href 結果 join() strong 1.數組對象的創建 1.設置一個長度為0的數組 var myarr=new array(); 2.設置一個長度為n的數組 var myarr=new arr(n); 3.聲明一個

學習筆記javascript內置對象日期對象

etsec sel mil cond ava com 描述 學習筆記 asp 2.日期對象的常用函數 2.日期對象的常用函數 Date 對象方法 方法描述 Date() 返回當日的日期和時間。 getDate() 從 Date 對象返回一個月

Linux學習筆記btrfs

可擴展性 linux btrfs Technical Preview, 技術預覽版 BtrFS(B-tree文件系統,又稱為Butter FS或Better FS),2007由oracle開源後,得到了IBM、intel等廠商的大力支持,其目標計劃是替代linux目前的ext3/4,成為下