狠狠撸

狠狠撸Share a Scribd company logo
GR-SAKURAで動く mrubyスマホリモコンカー
(タミヤ製ラジコン改造)
アライブビジョンソフトウェア株式会社
髙橋和浩
TOPPERSプロジェクト特別会員
GR0SAKURA-mruby-CAR 2
全体構成
GR0SAKURA-mruby-CAR 3
ラジコンカーの説明 接続編
? 工作が苦手な人必見。
? 完成済み1/10スケールのタミヤ製なら、フタバソケットケーブルのひっこ抜くだけ
GR0SAKURA-mruby-CAR 4
ラジコンカーの説明 制御編
GR0SAKURA-mruby-CAR 5
今回の特徴
? mrubyOS(仮称)を搭載しており、アプリケー
ションはmruby言語をマルチスレッド環境で動
作します
? アプリケーションをUPLOADして実行
? UPLOADせず、リンク済みのmrubyの実行も
可能
GR0SAKURA-mruby-CAR 6
GR0SAKURA-mruby-CAR 7
Youtube 「ドリフト raspberry pi」 で検索
GR0SAKURA-mruby-CAR 8
デモ
ソース
classclassclassclass Myalarm < Ssp_alarm
defdefdefdef initialize(id,gpio)
supersupersupersuper("alarm",id)
@gpio = gpio
endendendend
defdefdefdef alarm(n)
@gpio.off
endendendend
endendendend
classclassclassclass Gpiocyclic < Ssp_cyclic
defdefdefdef initialize(id,alarm,gpio,led)
supersupersupersuper("cyclic",id)
@alarm = alarm
@gpio = gpio
@led = led
endendendend
defdefdefdef start(tout)
@tout = tout
supersupersupersuper
@led.on
endendendend
GR0SAKURA-mruby-CAR 9
def change_tout(value) #moterは 100から141
@tout += value
p "tout = "+ @tout.to_s
end
def stop
super
@alarm.stop
@led.off
end
def cyclic(n)
@gpio.on
@alarm.istart(@tout)
end
end
class MainThread < Ssp_thread
def initialize(id)
super("thread",id)
end
def thread(n)
puts "start mainThread"
led1 = Rx_gpio.new(Rx_gpio::LED1) #accell
accel = Rx_gpio.new(Rx_gpio::IO2)
led1.off
accel_timer = Myalarm.new(1,accel)
accel_loop = Gpiocyclic.new(1,accel_timer,accel,led1)
stear = Rx_rcservo.new()
GR0SAKURA-mruby-CAR 10
###---------------------------------
whilewhilewhilewhile 1 dodododo
width = 0
p "please hit any key!"
command = Rx_getc()
p "getc = " + command.to_s
casecasecasecase command
whenwhenwhenwhen 'w' thenthenthenthen #accell start
accel_loop.start(140)
whenwhenwhenwhen 's' thenthenthenthen #accell stop
accel_loop.stop
whenwhenwhenwhen '1' thenthenthenthen # Speed down
accel_loop.change_tout(1)
whenwhenwhenwhen '3' thenthenthenthen # speed up
accel_loop.change_tout(-1)
whenwhenwhenwhen '4' thenthenthenthen # 左
width = 1050
whenwhenwhenwhen '5' thenthenthenthen # 中
width = 1550
whenwhenwhenwhen '6' thenthenthenthen # 右
width = 1900
endendendend
ifififif width != 0 thenthenthenthen
p "width =" + width.to_s
stear.Start(width)
endendendend
GC.start
endendendend
###---------------------------------
GR0SAKURA-mruby-CAR 11
endendendend
endendendend
GC.interval_ratio = 20
GC.step_ratio = 200
led0 = Rx_gpio.new(Rx_gpio::LED0)
led0.on #動作中
thread_main = MainThread.new(5)
puts "mruby setup finish!"
thread_main.act()
GR0SAKURA-mruby-CAR 12
mrubyのコンパイル&UPLOAD&実行
? C:?>mrbc rb_main-servo5.rb
? 上記の場合 rb_main-servo5.mrbができる
のでこれをUPLOADします。
? UPLOADモードで Lコマンドで送信
? Eコマンドで実行
GR0SAKURA-mruby-CAR 13
GR0SAKURA-mruby-CAR 14
スマホ操作
? BluetoothSPP 無料版を使います。
? キーボードモードでキーをボタンに割り当て
可能です。 シリアル接続と同じです。
GR0SAKURA-mruby-CAR 15
スマホ画面例
GR0SAKURA-mruby-CAR 16
コピペ 参考にさせていただいた方々
ありがとうございます
? GR-SAKURAでmrubyを動かす
? http://d.hatena.ne.jp/tarosay/20131006/1381042546 山本 三七男様
? GR-SAKURAのHEWプロジェクト
? http://d.hatena.ne.jp/licheng/20131001/p1 西村備山様
? RXマイコンのMTU
? http://d.hatena.ne.jp/licheng/20130926/p1 西村備山様
? RX63N/GR-SAKURA で TOPPERS/ASP を使う
? http://matuura.cocolog-nifty.com/blog/grsakura-toppersasp-.html 松浦光洋様
? SCIsample.zip
? …シリアル通信サンプル?プログラム
? (SCIチャネル0/1/2、通信速度57600bpsまたは115200bps、エコーバック)
? http://www.kumikomi.net/interface/editors/2011/04/6cd-romrx62n.php
Interface2011年6月号CD-ROM
GR0SAKURA-mruby-CAR 17
ソース等のアップロード先
? 本ソース一式は以下にアップしています。
? https://osdn.jp/users/alvstakahashi/pf/GR_
SAKURA_mruby/files/
? facebook
? https://www.facebook.com/firstandlastand
allways

More Related Content

More from Kazuhiro Takahashi (11)

PPT
TOPPERS/SSPを用いた教育訓練カリキュラムカーネルの自作およびカスタマイズ @ソフトウェア講演会名古屋
Kazuhiro Takahashi
?
PPT
Gr sakuraでtinet
Kazuhiro Takahashi
?
PPT
Rx hew-シミュレータで動かすー説明書
Kazuhiro Takahashi
?
PPT
mruby os(案)の開発
Kazuhiro Takahashi
?
PPT
リアルタイム翱蝉のカスタマイズ
Kazuhiro Takahashi
?
PPT
Toppers sspを用いた教育訓練カリキュラムカーネルの自作およびカスタマイズ
Kazuhiro Takahashi
?
PDF
リアルタイム翱蝉のカスタマイズチラシ023
Kazuhiro Takahashi
?
PPT
Raspberry pi 用 toppers ssp シュリンク版(海賊版)の紹介
Kazuhiro Takahashi
?
PPT
骋7プレゼン谤迟辞蝉自作
Kazuhiro Takahashi
?
PPT
骋7プレゼン谤迟辞蝉自作
Kazuhiro Takahashi
?
PPT
骋7プレゼン谤迟辞蝉自作
Kazuhiro Takahashi
?
TOPPERS/SSPを用いた教育訓練カリキュラムカーネルの自作およびカスタマイズ @ソフトウェア講演会名古屋
Kazuhiro Takahashi
?
Gr sakuraでtinet
Kazuhiro Takahashi
?
Rx hew-シミュレータで動かすー説明書
Kazuhiro Takahashi
?
mruby os(案)の開発
Kazuhiro Takahashi
?
リアルタイム翱蝉のカスタマイズ
Kazuhiro Takahashi
?
Toppers sspを用いた教育訓練カリキュラムカーネルの自作およびカスタマイズ
Kazuhiro Takahashi
?
リアルタイム翱蝉のカスタマイズチラシ023
Kazuhiro Takahashi
?
Raspberry pi 用 toppers ssp シュリンク版(海賊版)の紹介
Kazuhiro Takahashi
?
骋7プレゼン谤迟辞蝉自作
Kazuhiro Takahashi
?
骋7プレゼン谤迟辞蝉自作
Kazuhiro Takahashi
?
骋7プレゼン谤迟辞蝉自作
Kazuhiro Takahashi
?

Gr sakuraで動く mrubyスマホリモコンカー(タミヤ製ラジコン改造)