using the Verlet method for indoor geolocation in Android:
hi I wonder why this application does not work even if it contains no error, I want to integrate the acceleration to find position using Verlet method here is my code `package com.test.accelo; import android.app.Activity; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.view.Display; import android.view.Surface; import android.widget.TextView; public class AccelerometreActivity extends Activity implements SensorEventListener { /** Called when the activity is first created. */ private Display mDisplay; SensorManager sm; boolean acceltest; TextView t1,t2,t3; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); sm=(SensorManager) getSystemService(SEARCH_SERVICE); }@Override protected void onResume() { super.onResume(); acceltest=sm.registerListener(this,sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),SensorManager.SENSOR_DELAY_UI); if(! acceltest){ sm.unregisterListener(this,sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)); }} protected void onStop() { super.onStop(); sm.unregisterListener(this,sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)); } public void onAccuracyChanged(Sensor sensor, int accuracy) { // TODO Auto-generated method stub } @SuppressWarnings("null") public void onSensorChanged(SensorEvent event) { // TODO Auto-generated method stub float x = 50,y=50,z = 50; final long mSensorTimeStamp = 0; final long mCpuTimeStamp = 0; if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER){ switch (mDisplay.getRotation()) { case Surface.ROTATION_0: x = event.values[0]; y = event.values[1]; break; case Surface.ROTATION_90: x = -event.values[1]; y = event.values[0]; break; case Surface.ROTATION_180: x = -event.values[0]; y = -event.values[1]; break; case Surface.ROTATION_270: x = event.values[1]; y = -event.values[0]; break; } z = event.values[2]; } final float alpha = (float) 0.8; float[] gravity = null; gravity[0] = alpha * gravity[0] + (1 - alpha) * event.values[0]; gravity[1] = alpha * gravity[1] + (1 - alpha) * event.values[1]; gravity[2] = alpha * gravity[2] + (1 - alpha) * event.values[2]; float[] linear_acceleration = null; linear_acceleration[0] = event.values[0] - gravity[0]; linear_acceleration[1] = event.values[1] - gravity[1]; linear_acceleration[2] = event.values[2] - gravity[2]; final float sx = linear_acceleration[1]; final float sy = linear_acceleration[2]; float mPosX=0; float mPosY=0; float mAccelX = 0; float mAccelY=0; float mLastPosX=0; float mLastPosY=0; final long dT = mSensorTimeStamp + (System.nanoTime() - mCpuTimeStamp); final float dTdT = dT * dT; final float x1 = 2*(mPosX )- mLastPosX + mAccelX* dTdT; final float y1 = 2*(mPosY) - mLastPosY + (mAccelY)*dTdT; mLastPosX = mPosX; mLastPosY = mPosY; mPosX = x1; mPosY = y1; mAccelX = sx; mAccelY = sy; t1=((TextView) findViewById(R.id.textView1)); t1.setText("Axe x"+x+"ms^2"+"\n"+" Axe y"+y+"\n"+"Axez"+z); t2=(TextView) findViewById(R.id.textView2); t1.setText("AcclinX"+ linear_acceleration[1]+"ms^2"+"AcclinY"+ linear_acceleration[2]+"ms^2"); t3=(TextView) findViewById(R.id.textView3); t3.setText("POSX"+ x1+"m"+"POSY"+ y1+"m"); }} `I do not know what's the probleme.Mon stumbles is to find a position from the accelerometer, if it please you help me 2012/5/13, Marcin Orlowski <webnet.andr...@gmail.com>: > Just a note, that to make this thread useful for others, searching for help > in future, it's a good habbit to tell where the problem was and how you > fixed it (if it was not trivial) > > Regards, > Marcin Orlowski > > *Tray Agenda <http://bit.ly/trayagenda>* - keep you daily schedule handy... > *Date In Tray* <http://bit.ly/dateintraypro> - current date at glance... > WebnetMobile on *Facebook <http://webnetmobile.com/fb/>*, > *Google+*<http://bit.ly/webnetmobile-gp>and > *Twitter <http://webnetmobile.com/twitter/>* > > > > On 13 May 2012 18:20, Jeresam515 <jeremyschiff...@gmail.com> wrote: > >> Thanks all, I have gotten it to work. >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to android-developers@googlegroups.com >> To unsubscribe from this group, send email to >> android-developers+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- sne.bh -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en