RoBoard魔人的機器人日誌

2013/7/5

[RoBoME] Smartphone Controller

最近進擊巨人很夯

所以機器人也要進擊一下這樣
以下影片演示給大家看:







這次本魔開發的是RoBoME的控制器喔~

只要將你用RoBoME編寫的動作丟到智慧手機裡就可以做控制了!!

聽起來相當的容易吧~

以下教學

首先智慧手機上的程式我有打包apk供各位下載安裝囉~   LINK

然後RoBoard上必須要有接收端程式     LINK

附注:   接收端程式我預設是接到COM8 所以藍芽設定請設定到COM8

接著   只要在智慧手機根目錄下建置一個資料夾為RoBoME (如下圖)

然後將檔案放入即可喔!

無feedback的機器人記得要放入homeframe文件

或有聲音也要放入喔

開啟應用程式後   會看到兩個欄位

第一個欄位用來選rbm檔案

第二個欄位為選擇藍芽通道
 完成後按下Start
出現此介面後

先按下Start   再開啟Power   它就會給馬達電了

下面中文字的部分是我們已經編輯好的動作   它會自動生成按鈕來做整套的動作

相信眼睛很利的大家都有看到voice的按鈕

沒錯   這按鈕就是用來做聲控的

你只要念出下面按鈕的名稱   它就會做對應的動作囉!!



P.S.介面相當的陽春   不過別太介意啦=D   有時間的話再來認真的設計界面吧
Share:

2013/6/7

[練習] AX-12輪胎 簡易控制程式

在很久之前本魔有介紹過AX-12轉動的方法

而今天我要介紹的是AX-12的全轉模式

基本上在官方的文件中有提到喔!

Address 0x20,0x21 
Moving Speed. Sets the angular velocity of the output moving to the Goal Position. Setting this value to its maximum value of 0x3ff moves the output with an angular velocity of 114 RPM, provided that there is enough power supplied (The lowest velocity is when this value is set to 1. When set to 0, the velocity is the largest possible for the supplied voltage, e.g. no velocity control is applied.)

沒錯的   所以我們只要將Operating Angle Limit設定為0    它就會進入全轉模式

而官方文件中也有寫到Operating Angle Limit 的Address為0x06,0x07,0x08,0x09

在這之後我們只要控制轉動速度    就可以讓馬達旋轉囉!!

那就讓我們來看看程式碼吧!!

首先看看介面的設計 在此本魔是使用C#來做的


應該是不會很難理解的

下面的上下左右button是可以讓輪胎轉動   直到按下stop button

上面的 speed則是可以調整轉速

keyboard mode則是可以讓我們使用WSAD來控制輪胎

那我們來看看本魔實做的辦法吧   

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using RoBoIO_DotNet;
namespace controller_AX12
{
    public partial class Form1 : Form
    {
        public byte[] ax01 = new byte[11]{ 0xff, 0xff, 0x0f, 0x07, 0x03, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00 };
        public byte[] ax02 = new byte[11]{ 0xff, 0xff, 0x12, 0x07, 0x03, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00 };
        public byte[] read = new byte[6];
        public int run;
        public Form1()
        {
            InitializeComponent();
            groupBox1.Enabled = false;
            checkBox1.Enabled = false;
            run = 0;
            
        }
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            //RoBoIO.com3_DisableTurboMode();
            RoBoIO.com3_Close();
        }
        private void Start_Click(object sender, EventArgs e)
        {
            if (!groupBox1.Enabled){
                if (!RoBoIO.roboio_SetRBVer(RoBoIO.RB_100RD))
                    MessageBox.Show("roboio_SetRBVer fail");
                if (!RoBoIO.com3_Init(RoBoIO.COM_HDUPLEX))
                    MessageBox.Show("com3_Init fail");
                if (!RoBoIO.com3_SetFormat(RoBoIO.COM_BYTESIZE8, RoBoIO.COM_STOPBIT1, RoBoIO.COM_NOPARITY))
                    MessageBox.Show("com3_SetFormat fail");
                if (!RoBoIO.com3_SetBaud(RoBoIO.COMBAUD_115200BPS))
                    MessageBox.Show("com3_SetBaud fail");
                //RoBoIO.com3_EnableTurboMode();
                groupBox1.Enabled = true;
                checkBox1.Enabled = true;
                Start.Enabled = false;
                ax02[10] = BitConverter.GetBytes(~(ax02[2] + ax02[3] + ax02[4] + ax02[5] + ax02[6] + ax02[7] + ax02[8] + ax02[9]))[0];
                ax01[10] = BitConverter.GetBytes(~(ax01[2] + ax01[3] + ax01[4] + ax01[5] + ax01[6] + ax01[7] + ax01[8] + ax01[9]))[0];
                if (!RoBoIO.com3_ServoTRX(ax01, 11, read, 6))
                    MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                if (!RoBoIO.com3_ServoTRX(ax02, 11, read, 6))
                    MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                ax01[3] = 0x05;
                ax01[5] = 0x20;
                ax02[3] = 0x05;
                ax02[5] = 0x20;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            xUp();
        }
        private void xUp() {
            int speed = 10;
            if (run != 0)
            {
                Stop(5);
                speed = 5;
            }
            int v = speedbar.Value;
            run = 1;
            for (int i = 0; i < v % 0x3ff; i = i + v / speed)
            {
                ax01[6] = BitConverter.GetBytes(0x00ff & (i + 0x400))[0];
                ax01[7] = BitConverter.GetBytes((0xff00 & (i + 0x400)) / 0xff)[0];
                ax02[6] = BitConverter.GetBytes(0x00ff & i)[0];
                ax02[7] = BitConverter.GetBytes((0xff00 & i) / 0xff)[0];
                ax02[8] = BitConverter.GetBytes(~(ax02[2] + ax02[3] + ax02[4] + ax02[5] + ax02[6] + ax02[7]))[0];
                ax01[8] = BitConverter.GetBytes(~(ax01[2] + ax01[3] + ax01[4] + ax01[5] + ax01[6] + ax01[7]))[0];
                if (!RoBoIO.com3_ServoTRX(ax01, 9, read, 6))
                    MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                if (!RoBoIO.com3_ServoTRX(ax02, 9, read, 6))
                    MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                RoBoIO.delay_ms(25);
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            xdown();
        }
        private void xdown() {
            int speed = 10;
            if (run != 0)
            {
                Stop(5);
                speed = 5;
            }
            int v = speedbar.Value;
            run = 2;
            for (int i = 0; i < v % 0x3ff; i = i + v / speed)
            {
                ax01[6] = BitConverter.GetBytes(0x00ff & i)[0];
                ax01[7] = BitConverter.GetBytes((0xff00 & i) / 0xff)[0];
                ax02[6] = BitConverter.GetBytes(0x00ff & (i + 0x400))[0];
                ax02[7] = BitConverter.GetBytes((0xff00 & (i + 0x400)) / 0xff)[0];
                ax02[8] = BitConverter.GetBytes(~(ax02[2] + ax02[3] + ax02[4] + ax02[5] + ax02[6] + ax02[7]))[0];
                ax01[8] = BitConverter.GetBytes(~(ax01[2] + ax01[3] + ax01[4] + ax01[5] + ax01[6] + ax01[7]))[0];
                if (!RoBoIO.com3_ServoTRX(ax01, 9, read, 6))
                    MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                if (!RoBoIO.com3_ServoTRX(ax02, 9, read, 6))
                    MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                RoBoIO.delay_ms(25);
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            xleft();
        }
        private void xleft() {
            int speed = 10;
            if (run != 0)
            {
                Stop(5);
                speed = 5;
            }
            int v = speedbar.Value;
            run = 3;
            for (int i = 0; i < v % 0x3ff; i = i + v / speed)
            {
                ax01[6] = BitConverter.GetBytes(0x00ff & (i + 0x400))[0];
                ax01[7] = BitConverter.GetBytes((0xff00 & (i + 0x400)) / 0xff)[0];
                ax02[6] = BitConverter.GetBytes(0x00ff & (i + 0x400))[0];
                ax02[7] = BitConverter.GetBytes((0xff00 & (i + 0x400)) / 0xff)[0];
                ax02[8] = BitConverter.GetBytes(~(ax02[2] + ax02[3] + ax02[4] + ax02[5] + ax02[6] + ax02[7]))[0];
                ax01[8] = BitConverter.GetBytes(~(ax01[2] + ax01[3] + ax01[4] + ax01[5] + ax01[6] + ax01[7]))[0];
                if (!RoBoIO.com3_ServoTRX(ax01, 9, read, 6))
                    MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                if (!RoBoIO.com3_ServoTRX(ax02, 9, read, 6))
                    MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                RoBoIO.delay_ms(25);
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            xright();
        }
        private void xright() {
            int speed = 10;
            if (run != 0)
            {
                Stop(5);
                speed = 5;
            }
            int v = speedbar.Value;
            run = 4;
            for (int i = 0; i < v % 0x3ff; i = i + v / speed)
            {
                ax01[6] = BitConverter.GetBytes(0x00ff & i)[0];
                ax01[7] = BitConverter.GetBytes((0xff00 & i) / 0xff)[0];
                ax02[6] = BitConverter.GetBytes(0x00ff & i)[0];
                ax02[7] = BitConverter.GetBytes((0xff00 & i) / 0xff)[0];
                ax02[8] = BitConverter.GetBytes(~(ax02[2] + ax02[3] + ax02[4] + ax02[5] + ax02[6] + ax02[7]))[0];
                ax01[8] = BitConverter.GetBytes(~(ax01[2] + ax01[3] + ax01[4] + ax01[5] + ax01[6] + ax01[7]))[0];
                if (!RoBoIO.com3_ServoTRX(ax01, 9, read, 6))
                    MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                if (!RoBoIO.com3_ServoTRX(ax02, 9, read, 6))
                    MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                RoBoIO.delay_ms(25);
            }
        }
        private void button5_Click(object sender, EventArgs e)
        {
            Stop(10);
        }
        private void Stop(int speed)
        {
            if (run != 0)
            {
                int v = speedbar.Value;
                switch (run)
                {
                    case 1:
                        for (int i = v % 0x3ff; i > 0; i = i - v / speed)
                        {
                            ax01[6] = BitConverter.GetBytes(0x00ff & (i + 0x3ff))[0];
                            ax01[7] = BitConverter.GetBytes((0xff00 & (i + 0x3ff)) / 0xff)[0];
                            ax02[6] = BitConverter.GetBytes(0x00ff & i)[0];
                            ax02[7] = BitConverter.GetBytes((0xff00 & i) / 0xff)[0];
                            ax02[8] = BitConverter.GetBytes(~(ax02[2] + ax02[3] + ax02[4] + ax02[5] + ax02[6] + ax02[7]))[0];
                            ax01[8] = BitConverter.GetBytes(~(ax01[2] + ax01[3] + ax01[4] + ax01[5] + ax01[6] + ax01[7]))[0];
                            if (!RoBoIO.com3_ServoTRX(ax01, 9, read, 6))
                                MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                            if (!RoBoIO.com3_ServoTRX(ax02, 9, read, 6))
                                MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                            RoBoIO.delay_ms(25);
                        }
                        break;
                    case 2:
                        for (int i = v % 0x3ff; i > 0; i = i - v / speed)
                        {
                            ax01[6] = BitConverter.GetBytes(0x00ff & i)[0];
                            ax01[7] = BitConverter.GetBytes((0xff00 & i) / 0xff)[0];
                            ax02[6] = BitConverter.GetBytes(0x00ff & (i + 0x3ff))[0];
                            ax02[7] = BitConverter.GetBytes((0xff00 & (i + 0x3ff)) / 0xff)[0];
                            ax02[8] = BitConverter.GetBytes(~(ax02[2] + ax02[3] + ax02[4] + ax02[5] + ax02[6] + ax02[7]))[0];
                            ax01[8] = BitConverter.GetBytes(~(ax01[2] + ax01[3] + ax01[4] + ax01[5] + ax01[6] + ax01[7]))[0];
                            if (!RoBoIO.com3_ServoTRX(ax01, 9, read, 6))
                                MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                            if (!RoBoIO.com3_ServoTRX(ax02, 9, read, 6))
                                MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                            RoBoIO.delay_ms(25);
                        }
                        break;
                    case 3:
                        for (int i = v % 0x3ff; i > 0; i = i - v / speed)
                        {
                            ax01[6] = BitConverter.GetBytes(0x00ff & (i + 0x3ff))[0];
                            ax01[7] = BitConverter.GetBytes((0xff00 & (i + 0x3ff)) / 0xff)[0];
                            ax02[6] = BitConverter.GetBytes(0x00ff & (i + 0x3ff))[0];
                            ax02[7] = BitConverter.GetBytes((0xff00 & (i + 0x3ff)) / 0xff)[0];
                            ax02[8] = BitConverter.GetBytes(~(ax02[2] + ax02[3] + ax02[4] + ax02[5] + ax02[6] + ax02[7]))[0];
                            ax01[8] = BitConverter.GetBytes(~(ax01[2] + ax01[3] + ax01[4] + ax01[5] + ax01[6] + ax01[7]))[0];
                            if (!RoBoIO.com3_ServoTRX(ax01, 9, read, 6))
                                MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                            if (!RoBoIO.com3_ServoTRX(ax02, 9, read, 6))
                                MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                            RoBoIO.delay_ms(25);
                        }
                        break;
                    case 4:
                        for (int i = v % 0x3ff; i > 0; i = i - v / speed)
                        {
                            ax01[6] = BitConverter.GetBytes(0x00ff & i)[0];
                            ax01[7] = BitConverter.GetBytes((0xff00 & i) / 0xff)[0];
                            ax02[6] = BitConverter.GetBytes(0x00ff & i)[0];
                            ax02[7] = BitConverter.GetBytes((0xff00 & i) / 0xff)[0];
                            ax02[8] = BitConverter.GetBytes(~(ax02[2] + ax02[3] + ax02[4] + ax02[5] + ax02[6] + ax02[7]))[0];
                            ax01[8] = BitConverter.GetBytes(~(ax01[2] + ax01[3] + ax01[4] + ax01[5] + ax01[6] + ax01[7]))[0];
                            if (!RoBoIO.com3_ServoTRX(ax01, 9, read, 6))
                                MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                            if (!RoBoIO.com3_ServoTRX(ax02, 9, read, 6))
                                MessageBox.Show("com3_ServoTRX fail read back = " + read[0] + " " + read[1] + " " + read[2] + " " + read[3] + " " + read[4] + " " + read[5]);
                            RoBoIO.delay_ms(25);
                        }
                        break;
                }
                run = 0;
            }
        }
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
            {
                groupBox1.Enabled = false;
            }
            else {
                groupBox1.Enabled = true;
            }
        }
        private void checkBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (checkBox1.Checked)
            {
                if (e.KeyCode == Keys.W && run != 1)
                    xUp();
                else if (e.KeyCode == Keys.S && run != 2)
                    xdown();
                else if (e.KeyCode == Keys.A && run != 3)
                    xleft();
                else if (e.KeyCode == Keys.D && run != 4)
                    xright();
            }
        }
        private void checkBox1_KeyUp(object sender, KeyEventArgs e)
        {
            if(checkBox1.Checked){
                if (run != 0)
                Stop(10);
            }
        }
    }
}

Share:

2013/6/6

[RoBoard魔人] DMP秘密機器人-Zero上半身 輪胎測試

各位大家好

如果大家有在關注這台機器人的話就會知道

他現在有分上下半身

下半身之前已經給各位看過他的走路了

雖然目前還是有點弱弱的走路

但我相信 近期內我會將他改得較順暢
 DMP秘密機器人-Zero下半身
 DMP秘密機器人-Zero下半身
加上了殼  變得更安全


而今天的主角呢   就是上半身啦!
 DMP秘密機器人-Zero上半身

沒錯

加上了輪子依然霸氣十足

這輪子是使用AX-12來驅動的

而AX-12也是可以使用360度旋轉的喔!!

這樣就可以用輪子來移動了

來看看影片吧!!




至於這小程式的code    我會再做介紹的!
Share:

2013/5/13

[RoBoME] DMP秘密機器人-Zero 走路測試

大家看了那麼多RoBoME的使用教學

不知道有沒有心動呢?

本魔自己認為是蠻好用的啦

本魔之前在介紹DMP秘密機器人-Zero時

就有說過要用RoBoME來編輯這機器人的動作囉!!

所以本魔在此也拍了個影片來給大家看看

由於DMP秘密機器人-Zero的馬達沒有Feedback

所以在編輯上會有些吃力

不過有Feedback的馬達會有個缺點就是

我們抓回來的動作不一定對稱 或精準

廢話不多說 來看看影片吧!


教學系列文章:
V1.0   V1.1   V1.2   V1.3-4   V1.5-6


Source Code:
Github link
Share:

2013/4/12

[RoBoME] 使用教學V1.5~V1.6

這一次的V1.5更新絕對讓大家有全新體驗

為什麼呢?

這是因為本魔有加入了新功能囉~

在某年某月某日有一位大大  

也就是DMP秘密機器人的製作者

他說:[這個拉霸一定要排成這樣嗎?這樣找馬達的效率不是會很差?]



真不愧是DMP秘密機器人的製作者

一語點醒夢中魔阿!

所以這一次更新的內容就是~~~

可以隨意的擺放拉霸到你想要的位置~~!!

什麼?   你說這樣擺放不知道有什麼意義?

別急~  本魔還新增了圖形背景的功能

你可以選擇匯入圖檔
在設定的地方   左下方新增了一個選擇圖片的按鈕  (附註: 位置必須為跟目錄下)



然後再將拉霸移到相對應的位置
移動的方法是拖曳拉霸前面的CHx字串

那這樣就可以很快速的對照馬達囉~

當然圖檔你可以選擇拍照片   也可以選擇自己畫一張草稿

這樣就不怕會找不到馬達或轉錯馬達囉~

且下次再開啟檔案時    它會讀取上一次設定的位置及圖片喔~

不用擔心需要重新設定

也不用管你是機器人 機器貓 機器手臂   只要有圖   就可以放到你想要的位置囉~



但是   如果是在RoBoard上使用   建議圖檔盡量壓小

本魔實際測試過在刷新的時候  

約105k的圖檔(約720*1080)會讓程式有點LAG

而如果有人怕圖檔放進去後   會被框架給拉長圖片  

這裡告訴各位 框架的大小為700*550    各位可以用這個比例去裁切圖片






疑~你說什麼?    v1.6是做什麼的?

其實v1.6是修正前面一些bug

如拉霸拉了之後   馬達反應得很奇怪

以及背景功能的一些小bug



Source code

RoBoME
Share:
技術提供:Blogger.

追蹤者