(請打開字幕觀賞)
P&B 6x2 Spider
// http://4rdp.blogspot.tw/search/label/ROSA%20(Arduino)
#define LAST_SERVO 12 // for 6 x 2 spider
byte servo_revse[] =
{ 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1 };
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
_SERVO,bck,std,bck,std,mid,std,mid,std,fwd,std,fwd,std, //0
_HOLD, 150,255,150,255,150,255,150,255,150,255,150,255, //1
_LOOP, 3,255,255,255,255,255,255,255,255,255,255,255, //2
_SERVO,255, 60,255,120,255, 60,255,120,255, 60,255,120, //3
_SERVO,255,std,255,std,255,std,255,std,255,std,255,std, //4
_NEXT, 3,255,255,255,255,255,255,255,255,255,255,255, //5
_LOOP, 3,255,255,255,255,255,255,255,255,255,255,255, //6
_SERVO,255,120,255, 60,255,120,255, 60,255,120,255, 60, //7
_SERVO,255,std,255,std,255,std,255,std,255,std,255,std, //8
_NEXT, 7,255,255,255,255,255,255,255,255,255,255,255, //9
_GOTO, 0, //10
};
const byte RUN_4[] PROGMEM = { // spider dance-2
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
_SERVO,mid,std,mid,std,mid,std,mid,std,mid,std,mid,std, //0
_HOLD, 150,255,150,255,150,255,150,255,150,255,150,255, //1
_SERVO,255,hon,255,zeo,255,255,255,255,255,255,255,255, //2
_SERVO,255,255,255,std,255,255,255,255,255,255,255,255, //3
_SERVO,255,255,255,hon,255,255,255,zeo,255,255,255,255, //4
_SERVO,255,255,255,255,255,255,255,std,255,255,255,255, //5
_SERVO,255,255,255,255,255,255,255,hon,255,255,255,zeo, //6
_SERVO,255,255,255,255,255,255,255,255,255,255,255,std, //7
_SERVO,255,255,255,255,255,255,255,255,255,zeo,255,hon, //8
_SERVO,255,255,255,255,255,255,255,255,255,std,255,255, //9
_SERVO,255,255,255,255,255,zeo,255,255,255,hon,255,255, //10
_SERVO,255,255,255,255,255,std,255,255,255,255,255,255, //11
_SERVO,255,zeo,255,255,255,hon,255,255,255,255,255,255, //12
_SERVO,255,std,255,255,255,255,255,255,255,255,255,255, //13
_GOTO, 2, //14
};
const byte RUN_R[] PROGMEM = { // spider turn right
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
_LOOP, 2,255,255,255,255,255,255,255,255,255,255,255, //0
_SERVO,fwd,lif,255,255,255,hon,255,255,255,255,255,255, //1
_SERVO,255,std,255,255,255,255,255,255,255,255,255,255, //2
_SERVO,255,hon,bck,lif,255,255,255,255,255,255,255,255, //3
_SERVO,255,255,255,std,255,255,255,255,255,255,255,255, //4
_SERVO,255,255,255,hon,255,255,bck,lif,255,255,255,255, //5
_SERVO,255,255,255,255,255,255,255,std,255,255,255,255, //6
_SERVO,255,255,255,255,255,255,255,hon,255,255,bck,lif, //7
_SERVO,255,255,255,255,255,255,255,255,255,255,255,std, //8
_SERVO,255,255,255,255,255,255,255,255,fwd,lif,255,hon, //9
_SERVO,255,255,255,255,255,255,255,255,255,std,255,255, //10
_SERVO,255,255,255,255,fwd,lif,255,255,255,hon,255,255, //11
_SERVO,255,255,255,255,255,std,255,255,255,255,255,255, //12
_SERVO,bck,255,fwd,255,bck,255,fwd,255,bck,255,fwd,255, //13
_NEXT, 1,255,255,255,255,255,255,255,255,255,255,255, //14
_RETURN, //15
};
const byte RUN_L[] PROGMEM = { // spider turn left
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
_LOOP, 2,255,255,255,255,255,255,255,255,255,255,255, //0
_SERVO,255,255,fwd,lif,255,255,255,255,255,255,255,255, //1
_SERVO,255,255,255,std,255,255,255,255,255,255,255,255, //2
_SERVO,bck,lif,255,hon,255,255,255,255,255,255,255,255, //3
_SERVO,255,std,255,255,255,255,255,255,255,255,255,255, //4
_SERVO,255,hon,255,255,bck,lif,255,255,255,255,255,255, //5
_SERVO,255,255,255,255,255,std,255,255,255,255,255,255, //6
_SERVO,255,255,255,255,255,hon,255,255,bck,lif,255,255, //7
_SERVO,255,255,255,255,255,255,255,255,255,std,255,255, //8
_SERVO,255,255,255,255,255,255,255,255,255,hon,fwd,lif, //9
_SERVO,255,255,255,255,255,255,255,255,255,255,255,std, //10
_SERVO,255,255,255,255,255,255,fwd,lif,255,255,255,hon, //11
_SERVO,255,255,255,255,255,255,255,std,255,255,255,255, //12
_SERVO,fwd,255,bck,255,fwd,255,bck,255,fwd,255,bck,255, //13
_NEXT, 1,255,255,255,255,255,255,255,255,255,255,255, //14
_RETURN, //15
};
機器蜘蛛的腳位編號次序原則是:由內而外,由左而右,由前而後。
機器蜘蛛控制困難之處在於重心平衡,尤其是四足蜘蛛,行動時最少要有三點成面穩定立足,否則會傾倒或是跛足前進。
對了,因為前一篇四腳機器蜘蛛文章在成功大學黃敬群教授的 2015 年嵌入式系統課程 FB 社團貼文,所以黃教授問道:能多介紹一點運動模型的背景知識嗎?由於機構是由 Pizg Chen 設計,而我著重在機電控制部分,對於此議題與 Pizg 討論後,認為黃教授應該是想知道機器蜘蛛是如何做出各種動作?
在細節進一步說明前,有段 Pizg 精彩的發言,先與各位讀者分享,大意是:
機器人動作用文字編輯方式還是無法跟圖形方式比,用文字來編動作不容易讓人體會到 "模樣",舉個例子,最近這兩年不是有很多舞蹈表演配合音樂和 LED 做出燈光效果嗎,國內有些人是用土方法一個動作一個樂句一個閃燈...這樣編輯,應該要有一個圖形化的動作編輯軟體,靈活的機器人動作不會像 PLC 那樣一板一眼,這個圖形化的動作編輯軟體...應該簡單能讓小學生都會用才算成功。VRML 是後端程式,而 GUI 是前端操作畫面,我的建議.....VRML應該分成兩部分,一是韌體的 firmware,另一個是操作介面的 app,千萬不要把機器人動作寫死在MCU 裏,機器人的 firmware 只要能解讀 VRML 傳進來的資料,然後忠實精確地做出動作即可,GUI 這邊才是重點。
首先說明,我和 Pizg 並非 3D 動畫專家,雖然知道有 VRML 這種東西,但是要把這搞入 ROSA 內,技術離我們太遠了,想說的是,最佳的解決方案是能以電腦、平板或手機 VRML 編輯並模擬機器人 3D 動作,然後將這些動作以指令方式控制機器人,再由機器人內嵌入式系統控制器解譯指令並執行動作,在還沒有這麼棒的圖控解決方案出來前,我們先提供文字編輯方式,也就是現在 ROSA 程式碼中 RUN_X[] 的內容,ROSA 下一個階段就是再加入通訊指令的處理,讓動作不必寫死在程式碼中,雖然現在不能傳入 VRML,但是我將 ROSA 程式碼開源,告訴各位 ROSA 的指令格式,不排除未來有其他高手並懂 VRML 接手這個專案,為大家加入這方面程式功能,開源專案就是這樣,每位工程師貢獻自己所專長的部分,讓專案茁壯,讓成果大家可以享用,個人只是在想台灣科技島有這麼多各領域優秀專家,應該可以做點有台灣特色的東西,ROSA 只是拋磚引玉,如果 ROSA 可以成為 Arduino 機器人內重要的作業系統,那就是為台灣的科技能力做出最佳宣傳,而不是只追隨國外的東西,讓我們引領 Arduino 世界風潮一次,歡迎有興趣的朋友繼續討論。
現在 ROSA 已經將機器人動作控制由撰寫複雜程式碼的層次,簡化到編輯動作程序 (Profile),不過目前我沒有使用任何動作編輯程式,而是畫個簡單草圖,然後直接在大腦中構思動作並轉化為程序碼,這對我已經寫程式三十多年的程式人沒太大的困難,不過對大多數人應該有些難度,能有個動作編輯程式是最好不過,這部分未來有空應該會參考 Regis 的 vPython 或是用 Algodoo 弄一個動作模擬器。
這次我把 Arduino Uno 控制板架在蜘蛛本體上方,方便大家了解電路板配置概況,不過重心位置提高也相對比較不穩定,還好它是六腳機器蜘蛛,有較多的腳可以支撐身體,另外,這隻蜘蛛行動電源因為電路板上移的關係,放得比較後面,因此第五、六兩隻腳馬達受力較大,所以可以看到這兩隻腳比較下沉,如果想要仿製,會建議將電路放置在蜘蛛底部。
最後,我再舉個六足機器蜘蛛左轉運動為例,當按下紅外遙控器向左鍵,控制器判斷出左轉訊號傳入,就開始執行左轉程序第零行,設定 LOOP 兩次,接下來都是伺服馬達角度設定,ROSA 系統已經設計好,在伺服馬達還沒轉至定位前,是不會執行下一行指令,因此玩家不需要安插多餘的等待指令。第三、四號馬達是六腳蜘蛛的右前腿,因此程序第一行動作就是向外抬腿逆時針方向前轉,等定位後,然後把腳放直站穩,再換左前腿抬腳逆旋,再左中腳抬腳逆旋,左後腳抬腳逆旋,右後腳抬腳逆旋,右中腳抬腳逆旋,這樣所有的腳都逆轉一輪後,於站立狀態再同時六個大腿馬達順轉 (蜘蛛本體左旋),就這樣執行兩次迴圈動作,然後就跳回原先動作程序繼續執行。
截至目前為止,所展現的機器蜘蛛算是雛形設計,重點是看基本功能可不可以實現出來,經過個人測試與意見回饋給網友 Pizg,他已經有成熟的第二代機器蜘蛛設計,將陸陸續續展示出來敬請期待,歡迎有興趣製作的朋友可以留言或透過電郵 idea22much@gmail.com 跟我們聯絡。
沒有留言:
張貼留言