Classiclll's Blog

an old boy

バランスボード対応完了 テスト出来てないけど

イメージ 1

バランスボード対応完了 テスト出来てないけど


WiiRemoteJ 1.5 Releaseで私のリクエストに応じてくれたCha0sのため、ってわけじゃあないけど、バランスボード対応のWrj4P5 alpha-006が一応の完成をみた(はず)。
バランスボードを持っていないので、テストはおあずけ。
とりあえずWiiRemoteJ 1.5で(バランスボードとリモコンの共存を目的に)変更されてしまったAPIに対応した改造版をこしらえて、リモコンとの連携がうまく行く事までは確認出来た。

このあと、SourceForge.jpで公開予定だけど、若干の使用上の注意が・・・
WiiRemoteJ 1.4までとWiiRemoteJ 1.5のAPIが異なるため、次のような組み合わせしかうまく行かない。
 (スケッチの変更は不要)
 1.Wrj4P5の001~005 + WiiremoteJの0.9~1.4
 2.Wrj4P5のalpha-006 + WiiremoteJの1.5

承前 バランスボード

ご存知、Wiiのバランスボードを使うと、
 体重を量れる。
 重心バランスを測れる。
 体を使って・・・が出来る。
Wiiリモコンに並ぶゲームアイテムの優れもの。

工学的には
 4点の圧力(重量)センサー(ボードの4隅に配置されている)
 1個のLEDランプ
 1個のボタン
 1個のパワースイッチ(Power)
 Bluethoothデバイス
を単三アルカリ二本で駆動する独立装置

バランスボードのクラス WRJ4P5(005との差分だけ)


まずは、あなたのスケッチ(PApplet)
class PApplet 必要なら下記メソッドは各自用意すべし
【event handling methods】
 void boardPressed(int bid) bid番目のボードのボタンが押されたときに呼ばれる。
 void boardreleased(int bid) bid番目のボードのボタンが離されたときに呼ばれる。

次はWii本体、リモコンあるいはボードを最大7台まで繋げられ、各リモコンにはヌンチャクかクラコンかギターを繋げられる。
class WRJ4P5
 int dCount 繋がっている装置(リモコン、ボード)の数
 int rCount 繋がっているWiiリモコンの数
 int bCount 繋がっているバランスボードの数

 WiiBoard board 最初に繋がったバランスボード
 WiiBoard bood(int bid) (最大7台の)繋がっているバランスボード
興味の対象、バランスボード
class WiiBoard

[members]
  float sensed[2][2];	: latest sensed by pressure sensors at each corner.(mesured by Kg)
  float psensed[2][2];	// previous sensed value.
  float weight;		// = average of 4 sensor.(mesured by Kg)
  float pweight;	// = previous average of 4 sensor   
  float topRight;	// = sensed[0][0], Top-Right
  float bottomLeft;	// = sensed[1][1], Bottom-Left
  float topLeft;	// = sensed[0][1], Top-Left
  float bottomRight;	// = sensed[1][0], Bottom-Right
  boolean isIlluminated; //status of the LED on the board

[connection/communication]
:<status>
  void requestStatus()	 : command to start getting the newest status report
  boolean isReadingData()	: check if getting status
  boolean isConnected() 	: has 'me' connected ?
:<Battery>
  float getBatteryLevel()	: get the latest battery level, 0(empty) to 1(full)
:<LED Lights>
  boolean isLED()			: check the LED illumination.
  void setLED(boolean illumination)	: set the LED illumination.

ついでにRodとl4p5の完成 テストアプレットで妄想したRodに続くモデルもいくらか。

クラス Tag ー 3次元空間の平面のモデル

API
* Class Tag, the model of (partial) plane on the 3D space,
 * 			spanned from it's stern and star to it's bow and port
 *					created by Classiclll, 7/28/2008
 *  	Tag(Loc s, Loc b, Loc r)	// only constructor you can use, and
 *  	Tag(Tag frm)			// constructor you can use
 *  	Loc at(float s, float b)	// location at (s,b),
					// at(0,0):stern, at(0,me.length):bow, at(me.width,0):star
	Tag move(Loc to)		// move stern to "to"
	Tag shift(Loc diff)		// shift stern by "diff"
	Tag shiftI(Loc diff)		// inverse shift
	Tag scale(float factor)		// scale the size of me by factor
	Tag scaleI(float factor)	// inverse scaling
	Rod intersect(Tag to) 		// intersect line with me and to
	Loc intersect(Rod ln) 		// intersect point with me and ln
	float angle(Tag to)		// angle between each normal vector, me and to
	float dist(Loc pt)		// distance between "me" and "pt", = length of ortho(pt)
	Rod ortho(Loc pt)		// the orthogonal rod connecting from "pt" to "me"
	boolean having(Loc pt)		// is "me" having "pt" on myself ?
	float length()			// length of me
	float width()			// width of me
	Loc stern()			// location of the stern of me, the base position
	Loc bow()			// location of the bow of me
	Loc starBoard()		// location of the star of me
	Loc fore()			// foward direction of me, the unit vector
	Loc star()			// right direction of me, the unit vector
	Loc normal()			// upword direction of me, the unit vector
	Rod keel()			// line model of me's front/end, the Rod
	Boolean equals(Tag to)
	String toString()
さらに、

クラス Ship ー 3次元空間の(部分)空間のモデル

APIは...公開情報で



Processing については、
日本語サポートサイトからたどれるP5インフォメーション→言語が参考になる。
(解説してあるのは一昔前の版だから注意が必要だけど、loop()→draw()の読み替えだけで大抵OK)
・山本徹(thoru)さんがFunProce55ingで解説してくれている。(【簡潔】で【わかり易く】、【楽しい】解説)
例題集は習作集と区別するためにこちらに置いている。
・P5のスケッチからアプレットを作り、【ジオシティーズ】にアップする手順をまとめたので、参考に。
WiiRemoteアクセスライブラリWrj4P5はここ