accelerometer

Accelerometer stops delivering samples when the screen is off on Droid/Nexus One even with a WakeLock

丶灬走出姿态 提交于 2019-12-17 17:44:31
问题 I have some code that extends a service and records onSensorChanged(SensorEvent event) accelerometer sensor readings on Android. I would like to be able to record these sensor readings even when the device is off (I'm careful with battery life and it's made obvious when it's running). While the screen is on the logging works fine on a 2.0.1 Motorola Droid and a 2.1 Nexus One. However, when the phone goes to sleep (by pushing the power button) the screen turns off and the onSensorChanged

Is there a way to retrieve multiple sensor data in Android

若如初见. 提交于 2019-12-17 10:32:47
问题 I'm trying to get both accelerometer and orientation data. Currently, I created an AccelerometerManager and OrientationManager. They both do the same thing; implement SensorEventListener and retrieve data from values[] in onSensorChanged() listeners. Is there an easier way to do this? It seems like having 2 handlers with duplicate code is uneccessary. Is there a way to access a values[] array with the combined accelerometer and orientation data together? Because of the 2 handlers, I'm also

How do I use the Android Accelerometer?

社会主义新天地 提交于 2019-12-17 08:25:10
问题 I'm trying to build an app for reading the values from the accelerometer on my phone, which supports Android 2.1 only. How do I read from the accelerometer using 2.1-compatible code? 回答1: Start with this: public class yourActivity extends Activity implements SensorEventListener{ private SensorManager sensorManager; double ax,ay,az; // these are the acceleration in x,y and z axis @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R

Filtering accelerometer data noise

放肆的年华 提交于 2019-12-17 06:27:11
问题 How do I filter noise of the accelerometer data in Android? I would like to create a high-pass filter for my sample data so that I could eliminate low frequency components and focus on the high frequency components. I have read that Kalman filter might be the best candidate for this, but how do I integrate or use this method in my application which will mostly written in Android Java? or can it be done in the first place? or through Android NDK? Is there by any chance that this can be done in

Android TYPE_LINEAR_ACCELERATION sensor - what does it show?

回眸只為那壹抹淺笑 提交于 2019-12-17 03:55:16
问题 I am developing application for car acceleration tracking. I used standard accelerometer, calibrating it in specific position beforehand. Then, assuming phone's orientation is not changing, I logged the accelerometer data for a specified time and calculated move parameters, one of which is the car's speed at the end of the test. It works rather well, on a straight, horizontal road: error of a few percent. But then I found out, that in API-level 10 there is a virtual sensor called TYPE_LINEAR

Combine Gyroscope and Accelerometer Data

跟風遠走 提交于 2019-12-17 02:02:13
问题 I am building a balancing robot using the Lego Mindstorm's NXT system. I am using two sensors from HiTechnic, the first being an Accelerometer and the second being a Gyroscope. I've successfully filtered out noise from both sensors and derived angles for both in a range between -90 and 90 degrees, with 0 degrees being perfectly balanced. My next challenge is to combine both of the sensor values to correct for the Gyroscope's drift over time. Below is an example graph I created from actual

How to use Android sensors to detect how fast the device is moving

萝らか妹 提交于 2019-12-14 03:44:47
问题 I am a beginner at android programming and I have come up with some progress on getting the sensor data (Source code below). Can someone help me with detecting how fast my Android device is moving using these information? For example if I am moving the device fast, it will give me like 10, and if I am moving it slowly, I will get like 1. Aside from accelerometer, all other sensors are also OK for me. package course.examples.Sensors.ShowValues; import android.app.Activity; import android

Detect acceleration in absolute vertical axis

时光总嘲笑我的痴心妄想 提交于 2019-12-13 20:28:50
问题 I'm writing an app in which I want to access the acceleration data in an absolute vertical axis (i.e., from the ground to the floor), but with CoreMotion I'm only able to retrieve acceleration from the device's relative axis. For example if the device is laying flat on the table, it's vertical axis is actually at 90º from the absolute vertical axis. I've been playing with the gyro data to try to fix this, but data don't make sense. // Make sure the accelerometer hardware is available. if self

Stop recording accelerometer data with button click

◇◆丶佛笑我妖孽 提交于 2019-12-13 18:05:03
问题 I have written the following lines to record accelerometer data in a file with a button click startButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { final SensorEventListener mySensorEventListener = new SensorEventListener() { public void onSensorChanged(SensorEvent sensorEvent) { if (sensorEvent.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { xAxis_lateralA = sensorEvent.values[0]; yAxis_longitudinalA = sensorEvent.values[1]; zAxis_verticalA = sensorEvent

Get orientation device in the iPhone for Opengl Es

≯℡__Kan透↙ 提交于 2019-12-13 12:20:36
问题 I'm trying to convert the geomagnetic and accelerometer to rotate the camera in opengl ES1, I found some code from android and changed this code for iPhone, actually it is working more or less, but there are some mistakes, I´m not able to find this mistake, I put the code, also the call to Opengl Es1: glLoadMatrixf((GLfloat*)matrix); - (void) GetAccelerometerMatrix:(GLfloat *) matrix headingX: (float)hx headingY:(float)hy headingZ:(float)hz; { _geomagnetic[0] = hx * (FILTERINGFACTOR-0.05) +