|
SensorSimulator
Sensor Simulator for simulating sensor data in real time.
Sensor Simulator(scroll down for detailed description)
About the SensorSimulatorThe OpenIntents SensorSimulator lets you simulate sensor data with the mouse in real time. It currently supports accelerometer, compass, orientation, and temperature sensors, where the behavior can be customized through various settings. TRY IT OUT NOW
Connecting the SensorSimulator with the Android emulator
Additional settingsScroll down the settings pane to access the following settings:
How to use the SensorSimulator in your application
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); // Before calling any of the Simulator data,
// the Content resolver has to be set !!
Hardware.mContentResolver = getContentResolver();
// Link sensor manager to OpenIntents Sensor simulator
mSensorManager = (SensorManager) new SensorManagerSimulator((SensorManager)
getSystemService(SENSOR_SERVICE)); Intent intent = new Intent(Intent.ACTION_VIEW, Hardware.Preferences.CONTENT_URI); startActivity(intent); // first disable the current sensor
mSensorManager.unregisterListener(mGraphView);
// now connect to simulator
SensorManagerSimulator.connectSimulator();
// now enable the new sensors
mSensorManager.registerListener(this,
SensorManager.SENSOR_ACCELEROMETER |
SensorManager.SENSOR_MAGNETIC_FIELD |
SensorManager.SENSOR_ORIENTATION,
SensorManager.SENSOR_DELAY_FASTEST);
@Override
protected void onResume() {
super.onResume();
mSensorManager.registerListener(this,
SensorManager.SENSOR_ACCELEROMETER |
SensorManager.SENSOR_MAGNETIC_FIELD |
SensorManager.SENSOR_ORIENTATION,
SensorManager.SENSOR_DELAY_FASTEST);
}
@Override
protected void onStop() {
mSensorManager.unregisterListener(mGraphView);
super.onStop();
}class MySensorActivity extends Activity implements SensorListener {
public void onSensorChanged(int sensor, float[] values) {
// do something with the sensor values.
}
}
Sensor data definitionThe coordinate system with XYZ directions is defined as described in the Android SensorManager reference AccelerometerThe accelerometer values are defined in the accelerometer reference "Sensor values are acceleration in the X, Y and Z axis, where the X axis has positive direction toward the right side of the device, the Y axis has positive direction toward the top of the device and the Z axis has positive direction toward the front of the device. The direction of the force of gravity is indicated by acceleration values in the X, Y and Z axes. The typical case where the device is flat relative to the surface of the Earth appears as -STANDARD_GRAVITY in the Z axis and X and Z values close to zero. Acceleration values are given in SI units (m/s^2)." Magnetic field (compass)The magnetic field sensor values are defined in the magnetic field sensor reference "Sensor values are the magnetic vector in the X, Y and Z axis, where the X axis has positive direction toward the right side of the device, the Y axis has positive direction toward the top of the device and the Z axis has positive direction toward the front of the device. Magnetic values are given in micro-Tesla (uT)".
OrientationThe magnetic field sensor values are defined in the orientation sensor reference "Sensor values are yaw, pitch and roll Yaw is the compass heading in degrees, range [0, 360[ 0 = North, 90 = East, 180 = South, 270 = West Pitch indicates the tilt of the top of the device, with range -90 to 90. Positive values indicate that the bottom of the device is tilted up and negative values indicate the top of the device is tilted up. Roll indicates the side to side tilt of the device, with range -180 to 180. Positive values indicate that the left side of the device is tilted up and negative values indicate the right side of the device is tilted up." |
Sign in to add a comment
First, this is an excellent simulator. My only comment (and admittedly it is a weak complaint) is that it assumes that the accelerometer is dead center in the device (variations of Yaw have no affect on the accelerometer where pitch and roll remain constant). Of course, it may (albeit I would think somewhat unlikely) be that the device manufacturer will place the sensor dead center in the device. However, I would think it would be more useful to simulate it as if the sensor were placed in the front of the device. This way we could simulate a swinging motion common in alot of games. However, I realize this might be far more difficult to simulate:)
Thanks again for the sensor simulator. Great Job!
Excellent indeed. Proved very useful to check if my talking compass code worked as intended in the Android SDK 0.9 beta emulator. Thanks Peli!
I cannot get past the Connection Intent for the Emulator. Once finished and connected, I try to go back to my main activity, but it always takes me back to the Menu, can anyone help?
I am having the same problem. I added the following code and now instead of going to my app, it takes me to the Sesnsor Simlulator configuration screen. when I hit back, it takes me back to the menu. can anyone help?
nm, i looked at the source code and figured it out. you may want to note that Intent intent = new Intent(Intent.ACTION_VIEW, Hardware.Preferences.CONTENT_URI); startActivity(intent);
# and then
// first disable the current sensor mSensorManager.unregisterListener(mGraphView); // now connect to simulator SensorManagerSimulator?.connectSimulator(); // now enable the new sensors mSensorManager.registerListener(this,
gets called not on create but when a button gets clicked.
As some users described above i have the same problem when starting my own app. It just takes me back to the simulator screen. It happens at connectSimulator() Anybody know what im doing wrong or what causes this?
regards, Martijn
The problem can be that you are putting in the wrong IP address in the emulator. turn on sensorsimulator.jar & take your IP address from there. It might work. But I`m facing a different problem. When I click on connect, after a couple of minutes it gives an error message "activity sensor simulator (in application open intents ) not responding", anyone knows how to overcome this problem??
Cheers, Avinash Parnandi
I solved it by not starting the intent in my application. Just connect to the simulator using the OpenIntent? application via the Testing tab. Click the Connect button and data from the simulator should be coming in. Then close the application and start your own application.
My problem is solved and my app is working with the sensor simulator now and works great. The problem is that i didnt had the permission INTERNET in the configuration XML. The rest of the example given above works but just loose the Intent.
we are doing a project on all the sensors in android operating system.so we need some help from you about designing(usecase diagrams,sequence diagram..........) and the documentation of it.
If your program is closing without an error try placing
<uses-permission android:name="android.permission.INTERNET"/>
in your AndroidManifest?.xml directly after the <manifest> tag
:)
I was the preference/config screen then when I hit the back button it would close without a warning. When I finish a little app I will post.
I tried running the java application. I get the following error
Exception in thread "AWT-EventQueue?-0" java.lang.ClassCastException?: org.openintents.tools.sensorsimulator.MobilePanel?$2
Check your java version. Make sure it's 1.6
I am not getting a possible IP address from the Java app
hi, i have the same problem, it is going to directly my ip address again i click the back menu, it is going to main menu, can anyone help?
Hi,
- when I enter the IP and click on connect in Emulator, the Simulator on my computer can change the values of sensors; - when I hit "back" on Emulator, the Simulator shows that all sensors are disconnected.
Best regards
huckey
oh man yes... because i also look for two days how to solve.. i will AGAIN tell the solution of many probs here
add this in the androidmanifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
we are doing a project work on sensors in android operating system.so i have a problem with my Accelerometer that is ,it is not displaying the speed just it is displaying the values in the co-ordinate position.By using the Cordinate values we have to calculate the speed. so,it is making a disadvantage in my project, so suggest me to overcome this problem.
Hi,
I tried to port the openintents.apk on the Texas Instrument "Zoom" board. The board was uploaded with Kernel 2.6.27.10 & Android file system version 1.5.
Due to some reasons the openintents apk is not appearing on the device. However, the same apk is working fine on the emulator (with SDK 1.1 r1). Using ls command (to view the apks installed on the device) on PC connected to device, I do see the openintents apk, yet, its not visible on Zoom.
CAn you please help me with this??
Thanks.
Best Regards, Zhubham.
Hi,
I cannot access the Sensor Simulator settings in the Open Intents app on the emulator. When I select it, I get only a black screen. This is the logcat output:
I/ActivityManager?( 567): Starting activity: Intent { action=android.intent.action.MAIN comp={org.openintents/org.openintents.hardware.SensorSimulatorSettingsActivity?} } D/qemud ( 546): fdhandler_accept_event: accepting on fd 10 D/qemud ( 546): created client 0xc088 listening on fd 14 D/qemud ( 546): client_fd_receive: attempting registration for service 'sensors' D/qemud ( 546): client_fd_receive: -> received channel id 7 D/qemud ( 546): multiplexer_handle_control: unknown control message (26 bytes): 'ko:connect:07:service busy' W/ActivityManager?( 567): Launch timeout has expired, giving up wake lock! W/ActivityManager?( 567): Activity idle timeout for HistoryRecord?{436b1840 {org.openintents/org.openintents.hardware.SensorSimulatorSettingsActivity?}}
The versions I use: Android emulator version 1.9 (build_id CUPCAKE-147336) AVD Target: Google APIs (Google Inc.) Based on Android 1.5 (API level 3) OpenIntents 0.9.0
Any help would be greatly appreciated.
Thomas
When I use Android 1.1 (API level 2) as the target of my avd it works.
I get the following error on SDK 1.5 emulator (and OMAP 3430 as well). Can anyone tell how to come out of this??
D:\android-sdk-windows-1.5_r1\tools>adb install D:\openintents-binary-01?.9.0\openintents-binary-0.9.0\OpenIntents.apk 549 KB/s (1196340 bytes in 2.124s) DDM dispatch reg wait timeout Can't dispatch DDM chunk 52454151: no handler defined Can't dispatch DDM chunk 48454c4f: no handler defined
Failure INSTALL_FAILED_MISSING_SHARED_LIBRARY?D:\android-sdk-windows-1.5_r1\tools>
I get teh same error on the emulator: adb install OpenIntents.apk 295 KB/s (1196340 bytes in 3.954s)
Failure INSTALL_FAILED_MISSING_SHARED_LIBRARY?I use the SDK 1.5 r1 as well
Are there any solution?
If you're getting the MISSING_SHARED_LIBRARY problems, you need to use the 'Google APIs' target for your avd - this includes the Location libraries that are no longer built into the default.
What is the problem when I run SensorSimulator into my Android simulator? When I pulse on OpenIntents --> Settings --> Sensor Simulator, It doesn't work and screen changes a black color (as like as the application doesn't run well).
And the screen of your example (IP & port configuration), I haven't found.
Thanks a lot.
Hi again,
I forgot the next:
I'm using GoogleMaps? + Android Simulator 1.5.
Thanks!
Wonderful work!
Please someone can update this document with this two instructions:
First, the Target MUST be the Google APIs (Using 1.5 standard will cause instalation of OpenIntents.apk to fail).
Second, add this in the androidmanifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
To add use tag "Permissions" -> Add -> android.permission.INTERNET o just copy paste it before closing the manifest tag:
<manifest> .... <uses-permission android:name="android.permission.INTERNET"></uses-permission> </manifest>
Cheers.
I'm having the same problem as Paco. Where can I enter the IP and port???
When I pulse on OpenIntents --> Settings --> Sensor Simulator, the screen changes to black color and the emulator freezes.
(i) Can anyone please let me know the remedy of this??
(ii) Has it got something to do with the fact that Sensor and Compass APIDemo are failing on SDK 1.5 r1 emulator : refer http://groups.google.com/group/android-developers/browse_thread/thread/9f6c794b17eea701#
Thanks in advance.
Hi all, I have the same problem as sahilz750, Paco and finlaysoni, Is there any solution for that problem. For those that SensorSimulator works, which version of sdk and openintents do you use
I use Android SDK 1.5r2 with google apis and openintents 0.9.0 thank you for your Help
Hi guys, I'm using the latest version of the sensor somulator, and Android SDK 1.5r2. When I try to put in the IP address all I get is a blank screen. What can I do to fix this? Do I need a different version of teh SDK?
Hi all, I have executed on Android SDK 1.1. If you use Android SDK 1.5, Use Emulator on AVD for Android SDK 1.1 refer : http://developer.android.com/guide/developing/tools/avd.html
Works like charm, thanks for that great piece of software!will mention OpenIntents in my Software.
I have successfully used it for the android sample Compass.java ! But now I am using it with "SensorEventListener?" and i guess its not supported in "SensorManagerSimulator?"!
Will this simulator work with Android 1.5 (Cupcake) release. If not where can get some gaming application to test my accelerometer on cupcake.
Could you tell me how to save the data that I collected into a file? Thanks. ---- A new Androider
while i'm installing OpenIntent?.apk..its not getting loaded into emulator.. error message is shown in command prompt pkg: /data/local/tmp/OpenIntents.apk Failure INSTALL_FAILED_MANIFEST_MALFORMED D:\android-sdk-windows-1.5_r3\tool plz help.... thanks in advance
First of all, thank you for this simulator! But I have to ask you a question. I've upgraded my Android SDK to 1.6 version, and I've realized that the Sensor constant changed if I use the new Interface SensorEventListener? ('cause the old one says it's deprecated!). So, anyone knows if I could use the sensorsimulator with the new Interface or I have to use the deprecated one?? Thank you guys!!
I'd like to second the request to update the sensor simulator to new Android SDK 1.6/2.0 APIs. Thanks!
if I want to use my HTC magic to control the SensorSimulator on computer,can i?
+1 for updating the sensor simulator to the new Android platform and SensorEventListener?. (I just updated some other code for this change, so maybe I could do the same for SensorSimulator and submit a patch.)
Question: The instructions above say "download the latest openintents-binary-x.x.x.zip". I don't see any such thing on the openintents download list. Does sensorsimulator-1.0.0-beta1.zip replace that file?
Thanks, Lars
P.S. Thanks HastCibernio? for the tip about requiring the Google APIs as a target!
As Nicholaus said it would be great to have version for 1.6/2.0/2.1. Thanks
Is there any version to test applications with android 2.0 and SensorEventListener? ?