2011年1月18日火曜日

Sensor Simulatorを利用してセンサの動作を確認する<設定編> - Confirming the behavior of sensor using Sensor Simulator (Settings) -

このエントリーをはてなブックマークに追加
Sensor SimulatorとはAndroidアプリへ仮想的に傾きや加速度を与えるためのツールです.Sensor SimulatorとAndroidエミュレータを接続し,Sensor Simulatorに表示された携帯電話の画像をマウスで動かしたり,各種パラメータ値を変更したりすることで,仮想的に傾きや加速度を与えることができます.

ここでは,Sensor Simulatorが使えるようになるまでの設定を記述しています.


Sensor Simulator is a tool to give virtually a inclination and an acceleration to Android application. The inclination and the acceleration can be given virtually by connecting Sensor Simulator with Android emulator and moving the image of mobile phone displayed in Sensor Simulator with mouse or changing various argument values.

In this articles, we describe about the settings of the Sensor Simulator.


事前準備(ダウンロード)
1.openintentsのダウンロードページへアクセス.
http://code.google.com/p/openintents/downloads/list

2.sensorsimulator-1.1.0-rc1.zipをダウンロード.

3.適当なフォルダへ解凍.
(ここでは,解凍したフォルダ名はsensorsimulator-1.1.0-rc1として話を進めます)


シミュレータ起動
1.sensorsimulator-1.1.0-rc1/bin/sensorsimulator-1.1.0-rc1.jarを起動.



2.左側に表示されたSocket(8010)とIP Adressっぽい値(114.48.3.10)をメモ.


SensorSimutatorSettings.apkのインストール
1.「sensorsimulator-1.1.0-rc1/bin/SensorSimulatorSettings-1.1.0-rc1.apk」を「android-sdk-windows/tools」へコピー.

2.コマンドプロンプトを起動し,「android-sdk-windows/tools」へ移動.

3.次のコマンドをタイプしエンターキーを押下.
adb install SensorSimulatorSettings-1.1.0-rc1.apk

成功するとSuccsessの文字が表示される.



AndroidエミュレータとSensor Simulator
1.EclipseからAndroidエミュレータを起動し,「Sensor Simulator settings」というアイコンが追加されていることを確認.
2.「Sensor Simulator settings」を起動.
→IP addressとSocketを入力するテキストフィールドが表示される

3.IP addressとSocketにSensorSimulatorから読み取ったそれらの値を入力.


4.Testingを選択し,[Connect]ボタンをクリック.

5.傾きを計測したい場合はorientationにチェック.


6.Sensor SimulatorのYaw,Pitch,Rollを適当に変更し,それに追従してorientationの下の数値が変化することを確認.


これで,Sensor Simulatorの設定と動作確認は完了です.


参考URL
Android Sensor Simulator設定メモ

2 件のコメント:

  1. 参考にさせていただきました。
    しかし、SensorSimulator上のTestingでは上手く反応してくれますが、
    実際のアプリでは反応しませんね。
    Connectボタンを押した後でアプリを選択するのでいいのですよね?
    http://www.impressjapan.jp/support/aftercare/2940
    これの7-3のサンプルなどを実行しても反応しません。

    返信削除
  2. 実際のアプリ用に作られたセンサ機能はSensorSimulatorでは機能しないはずです。

    例えばSensorEventListenerを用いる場合、実際のアプリでは次をインポートします。
    import android.hardware.SensorEventListener;

    しかし、SensorSimulatorでセンサの動作を確認しようとする場合、
    openintents.sensorsimulator.hardware.SensorEventListener
    をインポートする必要があります。

    なので、実際のアプリをSensorSimulatorで確認する場合には、コードもSensorSimulator用に書き換える必要があります。

    返信削除