メカナムホイール ロボット

Wi-Fi メカナムホイール ロボット

Information

第9回日本橋ストリートフェスタ2013(3月24日開催予定)ものづくりエリア にて展示予定!

45度に配置された奇妙なホイールで自在に動く車型ロボットです。

Wi-Fiモジュールを搭載。無線LANのアクセスポイントとなって、iPhone等スマートフォンから接続でき、コントローラとして使えます。

ロボット上(mbed)にhttpサーバとWebSocketサーバを実装しており、スマートフォンやPCのブラウザ上で動くコントローラにより、専用アプリのインストールは不要です。

Hardware

Software

GSwifi ライブラリの httpサーバ(ウェブサーバ)と WebSocketサーバを有効にしています。

Import libraryGSwifi

GainSpan Wi-Fi library see: http://mbed.org/users/gsfan/notebook/gainspan_wifi/

mbed

#include "mbed.h"
#include "GSwifi.h"
#include "SDHCFileSystem.h"

GSwifi gs(p13, p14, p12, P0_22); // TX, RX, CTS, RTS
SDFileSystem sd(p5, p6, p7, p8, "sd");
   :
void ws (int cid, GS_httpd *gshttpd) {
    // parse received data and motor control
}
   :
int main () {
    sd.disk_initialize();

    gs.setBaud(921600);
    if (gs.limitedap(GSSEC_NONE, "MECANUM", "", IpAddr(192,168,0,1),
IpAddr(255,255,255,0), "www.mecanum.wheel")) {
        return -1;
    }

    gs.httpd(PORT);
    gs.attach_httpd("/ws/", &ws);
    gs.attach_httpd("/", "/sd/www/");

    for (;;) {
        gs.poll();
    }
}

SDメモリーカードへはhtmlファイルやJavaScript、画像ファイルなどを入れておきます。

JavaScript

   :
function init() {
	window.scrollTo(0,1);
	if (navigator.userAgent.indexOf('iPhone') > 0
	  || navigator.userAgent.indexOf('iPod') > 0
	  || navigator.userAgent.indexOf('iPad') > 0
	  || navigator.userAgent.indexOf('Android') > 0) {
		document.addEventListener("touchstart", touchStart, false);
		document.addEventListener("touchmove", touchMove, false);
		document.addEventListener("touchend", touchEnd, false);
	} else {
		document.addEventListener("mousedown", mouseDown, false);
		document.addEventListener("mousemove", mouseMove, false);
		document.addEventListener("mouseup", mouseUp, false);
	}

	if ("WebSocket" in window) {
		ws = new WebSocket(ws_url);
	} else if ("MozWebSocket" in window) {
		ws = new MozWebSocket(ws_url);
	}
	ws.onopen = function(evt) { onOpen(event) };
	ws.onclose = function(evt) { onClose(event) };
	ws.onmessage = function(evt) { onMessage(event) };
	ws.onerror = function(evt) { onError() }; 
}
   :

Produced by Suga koubou.


Please log in to post comments.