F#で動かすraspberry pi+lego mindstorms

17
F# でででで Raspberry PI+LEGO Mindstorms でで でで@moonmile .NET でで Micorosft MVP C# Moonmile Solutions

description

2014/08/03 F# Meetup in Tokyo の発表資料

Transcript of F#で動かすraspberry pi+lego mindstorms

Page 1: F#で動かすraspberry pi+lego mindstorms

F# で動かす Raspberry PI+LEGO Mindstorms

増田 智明( @moonmile ).NET ラボ Micorosft MVP C#

Moonmile Solutions

Page 2: F#で動かすraspberry pi+lego mindstorms

自己紹介

増田 智明 [email protected]

執筆業&プログラマ C# による iOS, Android, Windows アプリケーション開発入門 逆引き大全 Visual C# 2013, Visual Basic 2013

逆引き大全 iPhone/iPad アプリ開発 作って覚える iPhone/iPad アプリ入門

Page 3: F#で動かすraspberry pi+lego mindstorms

「ハルロック」西餅 著http://www.moae.jp/comic/harurock/1/1

つい最近知った。 電子工作の基礎な話が出てきます。

PIC

Raspberry Pi

Arduino

.NET Micro は、まだ出てきてない

モーニング連載

Page 4: F#で動かすraspberry pi+lego mindstorms

プレゼンの目的F# は何処で使えるのか?

Page 5: F#で動かすraspberry pi+lego mindstorms

いきなり、結論 .NET Framework があれば何処でも使えま

Page 6: F#で動かすraspberry pi+lego mindstorms

ロボット制御に使おうRaspberry PiLinux/Mono

CameraOpenCV

DualSock3Bluetooth

GPIO/I2C

RobotProtocol

WiFiHTTPXAML

Xamarin.Forms

Page 7: F#で動かすraspberry pi+lego mindstorms

Rasbpery Pi に F# を入れる

Raspberry PiLinux/Mono

Linux なので Monoが入る。

F# をビルド→ 10 時間かかる

インタプリタが動く→ 遅いが

Page 8: F#で動かすraspberry pi+lego mindstorms

Rasbpery Pi に F# を入れる

簡易 C/S を作るHttpListenerHttpClient

適当な RESTfulWiFiHTTP

Page 9: F#で動かすraspberry pi+lego mindstorms

Rasbpery Pi に F# を入れる

スマートフォンのクライアントXamarin.iOS/AndroidXamarin.FormsWindows Store 8.1 作成中Windows Phone 8.1 作成中Windows 8.1 WPF

XAMLXamarin.Form

s

Page 10: F#で動かすraspberry pi+lego mindstorms

Rasbpery Pi に F# を入れる

画像解析OpenCV の C# 版

(opencvsharp) で実験する予定

CameraOpenCV

Page 11: F#で動かすraspberry pi+lego mindstorms

Rasbpery Pi に F# を入れる

Bluetooth コントローラ/dev/input/js0 を

BinaryReader で扱えば OKDualSock3Bluetooth

Page 12: F#で動かすraspberry pi+lego mindstorms

Rasbpery Pi に F# を入れる

シリアルポートを叩く実験中。現在は C からインポートする方式

GPIO/I2C

Page 13: F#で動かすraspberry pi+lego mindstorms

Rasbpery Pi に F# を入れる

ロボット制御ロジックパターンマッチとか諸々は F# の得

意なところセンサーが受信したデータを解析

RobotProtocol

Page 14: F#で動かすraspberry pi+lego mindstorms

ロボットのアームを制御する

RasPi からアームを動かす BrickPi -> LEGO でもアームが動くが、ここでは RasPi から直接行う。 RasPi -> I2C モジュール → サーボモータ で動作させるのだが、 I2C モジュールを買い忘れてた orz

購入済み。プログラミング途中

Page 15: F#で動かすraspberry pi+lego mindstorms

ロボットからセンサーのフィードバックを受ける

BrickPi 経由で超音波センサーを使う 変換器が必要なのが分かって、現在購入中。

Page 17: F#で動かすraspberry pi+lego mindstorms

自前のライブラリ

BrickPiNet BrickPi を扱う C#/F# ライブラリhttps://github.com/moonmile/BrickPiNet

XFormsPreviewer Xamarin.Forms Previewer (パース部分が F# )https://github.com/moonmile/XFormsPreviewerXamarin.Forms Xaml を動的にロードするライブラリhttps://www.nuget.org/packages/Xamarin.Forms.XamlProvider/

WinXamlProiver Windows Store 8.1 Xaml 用の TypeProvider もどきhttps://github.com/moonmile/WinXamlProvider

D4Reflection リフレクションを使って Xamarin.Forms, Windows.UI.Xaml 等を一括に扱う試作ライブラリhttps://github.com/moonmile/D4Reflection