Bonjour,
Je travaille sur une application faisant office de variomètre. Le but est de détecter une tendance à monter ou descendre selon l'axe Z géoterrestre. Je n'ai pas besoin d'une valeur précise de la vitesse.
Dans mon code je fais une intégration des accélérations linéaires filtrées et projetées sur l'axe Z. Cela me donne une vitesse. Les capteurs sont imparfaits. C'est pourquoi j’asservis cette valeur à la vitesse verticale déterminée par GPS
En gros je veux récupérer une vitesse accéléromètre hybridée GPS.
Mon premier problème réside dans la projection. Lorsque je projette les accélérations brutes sur l'axe Z géoterrestre, ma valeur d'accélération totale dépasse la gravité dans certaines positions du téléphone.
Mon second problème est peut-être une conséquence du premier. Lorsque j'effectue des mouvements, la vitesse verticale augmente même si je laisse tomber le téléphone dans le vide.
Pour tester ces comportements, j'ai désactivé l'asservissement au GPS dans le code ci-dessous.
Le code n'est pas propre, désolé.
Main activity
Service de récupération des sensors
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343 package com.vinu.androfpv; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.location.Location; import android.media.MediaPlayer; import android.os.Bundle; import android.os.SystemClock; import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech.OnInitListener; import android.util.FloatMath; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.ProgressBar; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; import android.widget.TextView; import android.widget.Toast; import java.io.FileWriter; import java.lang.String; public class MainActivity extends Activity implements OnInitListener, OnSeekBarChangeListener/*, SensorEventListener*/ { // DECLARATIONS public int MY_DATA_CHECK_CODE = 0; public TextToSpeech tts; public EditText inputText; public Button speakButton; public TextView TextViewAccelerometer; public TextView LaXView; public TextView LaYView; public TextView LaZView; public TextView VzCountView; public TextView VzAView; public TextView VzGView; public TextView VzView; public TextView LatView; public TextView LongView; public TextView AltView; public TextView AccView; public TextView SeekB1View; public ProgressBar mProgress1; public ProgressBar mProgress2; public ProgressBar mProgress3; public SeekBar bar; /*SensorManager sensorManager; Sensor accelerometer; Sensor magnetic; Sensor gravity; float[] accelerometerVector = new float[3]; float[] magneticVector = new float[3]; float[] resultMatrix = new float[9]; float[] values = new float[3]; float[] orientation = new float[3]; float[] gravityVector = new float[3];*/ float VitesseZ = 0; float VitesseZSound = 0; float Vz = 0; float VzG = 0; float VzDef = 0; float altTemp = 0; float[] moyenneVZ = new float[5]; private Intent intent; float AmortVZ = (float) 1; public static final String TAG = "VinuFpvMain"; int isound = 0; public long time; public Location locationAct, locationOrig; public FileWriter filewriter; public MediaPlayer mediaPlayer0, mediaPlayer1; int SounCount = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); inputText = (EditText) findViewById(R.id.EditText1); speakButton = (Button) findViewById(R.id.button1); TextViewAccelerometer = (TextView) findViewById(R.id.textViewAccelerometer); LaXView = (TextView) findViewById(R.id.textViewLaX); LaYView = (TextView) findViewById(R.id.textViewLaY); LaZView = (TextView) findViewById(R.id.textViewLaZ); VzCountView = (TextView) findViewById(R.id.textViewVzcount); VzAView = (TextView) findViewById(R.id.textViewVzA); VzGView = (TextView) findViewById(R.id.textViewVzG); VzView = (TextView) findViewById(R.id.textViewVz); LatView = (TextView) findViewById(R.id.textViewLat); LongView = (TextView) findViewById(R.id.textViewLong); AltView = (TextView) findViewById(R.id.textViewAlt); AccView = (TextView) findViewById(R.id.textViewAcc); SeekB1View = (TextView) findViewById(R.id.textViewSeekB1); SeekB1View.setText(String.valueOf(AmortVZ)); mProgress1 = (ProgressBar) findViewById(R.id.progressBar1); mProgress2 = (ProgressBar) findViewById(R.id.progressBar2); mProgress3 = (ProgressBar) findViewById(R.id.progressBar3); bar = (SeekBar)findViewById(R.id.seekBar1); bar.setOnSeekBarChangeListener(this); //VzDef = Vz; mediaPlayer0 = MediaPlayer.create(this, R.raw.snd440); mediaPlayer1 = MediaPlayer.create(this, R.raw.snd880); locationAct = new Location(LOCATION_SERVICE); locationOrig = new Location(LOCATION_SERVICE); speakButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { VitesseZ = 0; //VzDef = Vz; //locationOrig.set(locationAct); StringToSpeech(String.valueOf("distance " + (int) FloatMath.floor(locationAct.distanceTo(locationOrig))) + " mètres relèvement " + String.valueOf((int) FloatMath.floor(locationAct.bearingTo(locationOrig))) + " degrés"); locationOrig.set(locationAct); } }); Intent checkIntent = new Intent(); checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA); startActivityForResult(checkIntent, MY_DATA_CHECK_CODE); intent = new Intent(this,TimerService.class); //startService(intent); //Fin de MainActivity } @Override protected void onStart() { super.onStart(); startService(intent); } @Override protected void onStop() { super.onStop(); Log.d(TAG, "onStop()"); stopService(intent); } protected void StringToSpeech(String text) { Toast.makeText(this, text, Toast.LENGTH_SHORT).show(); //VZView.setText(String.valueOf(mService.getVz())); //int num = mService.getRandomNumber(); //Toast.makeText(this, "number: " + num, Toast.LENGTH_SHORT).show(); /*text = inputText.getText().toString();*/ if (text!=null && text.length()>0) { //Toast.makeText(MainActivity.this, "Saying: " + text, Toast.LENGTH_LONG).show(); tts.speak(text, TextToSpeech.QUEUE_ADD, null); } onActivityResult(MY_DATA_CHECK_CODE, MY_DATA_CHECK_CODE, null); } private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateUI(intent); } }; protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == MY_DATA_CHECK_CODE) { if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) { // success, create the TTS instance tts = new TextToSpeech(this, this); } else { // missing data, install it //Intent installIntent = new Intent(); //installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); //startActivity(installIntent); //Toast.makeText(MainActivity.this, "Pas de TTS install�", Toast.LENGTH_SHORT).show(); } } } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); menu.add(0, 0, 0, "Quit"); return true; } @Override public boolean onMenuItemSelected(int featureId, MenuItem item) { switch (item.getItemId()) { case 0: //finish(); //android.os.Process.killProcess(android.os.Process.myPid()); unregisterReceiver(broadcastReceiver); stopService(intent); System.exit(0); return true; } return super.onMenuItemSelected(featureId, item); } public void onInit(int status) { // TODO Auto-generated method stub } protected void onPause() { super.onPause(); Log.d(TAG, "onPause()"); unregisterReceiver(broadcastReceiver); //stopService(intent); } @Override protected void onResume() { super.onResume(); Log.d(TAG, "onResume()"); //startService(intent); registerReceiver(broadcastReceiver, new IntentFilter(TimerService.BROADCAST_ACTION)); } private void updateUI(Intent intent) { time = SystemClock.elapsedRealtime() - time; Vz = - intent.getFloatExtra("IntentVz", 0); String counter = intent.getStringExtra("counter"); VzG = intent.getFloatExtra("VzG", 0); VitesseZ = VitesseZ + (Vz / (float) time)/* - VzDef + ((VzG - VitesseZ)/AmortVZ)*/; if ( mediaPlayer0.isPlaying() == false && mediaPlayer1.isPlaying() == false) { if (VitesseZ > 0.2 && VitesseZ < 1) { mediaPlayer0.start(); } else if(VitesseZ >= 1) { mediaPlayer1.start(); } } if (intent.getBooleanExtra("locC", false)) { /*LaXView.setText(String.valueOf((int) locationAct.bearingTo(locationOrig))); LaYView.setText(String.valueOf((int) locationAct.distanceTo(locationOrig))); LaZView.setText(String.valueOf((int) (locationAct.getAltitude() - locationOrig.getAltitude())));*/ } /*switch (SounCount) { case 0: VitesseZSound = VitesseZ; if (VitesseZSound > -0.1) mediaPlayer0.start(); if (VitesseZSound < -0.3) mediaPlayer1.start(); case 1: //if (VitesseZSound > -0.1) mediaPlayer0.start(); //if (VitesseZSound < -0.3) mediaPlayer1.start(); case 2: if (VitesseZSound > -0.1) mediaPlayer0.start(); if (VitesseZSound < -0.3) mediaPlayer1.start(); case 3: //if (VitesseZSound > -0.1) mediaPlayer0.start(); //if (VitesseZSound > -0.3) mediaPlayer1.start(); case 4: if (VitesseZSound > -0.1) mediaPlayer0.start(); if (VitesseZSound < -0.3) mediaPlayer1.start(); case 5: //if (VitesseZSound > -0.1) mediaPlayer0.start(); //if (VitesseZSound < -0.3) mediaPlayer1.start(); case 6: if (VitesseZSound > -0.1) mediaPlayer0.start(); if (VitesseZSound < -0.3) mediaPlayer1.start(); case 7: //if (VitesseZSound > -0.1) mediaPlayer0.start(); //if (VitesseZSound < -0.3) mediaPlayer1.start(); case 8: if (VitesseZSound > -0.1) mediaPlayer0.start(); if (VitesseZSound < -0.3) mediaPlayer1.start(); case 9: //if (VitesseZSound > -0.1) mediaPlayer0.start(); //if (VitesseZSound < -0.3) mediaPlayer1.start(); }*/ /*LaXView.setText(String.valueOf(FloatMath.floor(intent.getFloatExtra("Ax", 0)*10)/10)); LaYView.setText(String.valueOf(FloatMath.floor(intent.getFloatExtra("Ay", 0)*10)/10)); LaZView.setText(String.valueOf(FloatMath.floor(intent.getFloatExtra("Az", 0)*10)/10));*/ LaXView.setText(String.valueOf(FloatMath.floor(intent.getFloatExtra("Ox", 0)))); LaYView.setText(String.valueOf(FloatMath.floor(intent.getFloatExtra("Oy", 0)))); LaZView.setText(String.valueOf(FloatMath.floor(intent.getFloatExtra("Oz", 0)))); VzCountView.setText(counter); VzAView.setText(String.valueOf(Vz)); VzGView.setText(String.valueOf(VzG)); VzView.setText(String.valueOf( FloatMath.floor(VitesseZ*100)/100 )); locationAct.setLatitude(intent.getDoubleExtra("Lat", 0)); LatView.setText(String.valueOf(intent.getDoubleExtra("Lat", 0))); locationAct.setLongitude(intent.getDoubleExtra("Long", 0)); LongView.setText(String.valueOf(intent.getDoubleExtra("Long", 0))); locationAct.setAltitude(intent.getDoubleExtra("Alt", 0)); AltView.setText(String.valueOf(intent.getDoubleExtra("Alt", 0))); AccView.setText(String.valueOf(intent.getFloatExtra("Acc", 0))); //VZView.setText(/*String.valueOf(intent.getDoubleExtra("Lat", 0)) + String.valueOf(intent.getDoubleExtra("Long", 0)) + */String.valueOf(intent.getDoubleExtra("Alt", 0))+ " " + String.valueOf(intent.getFloatExtra("Acc", 0)) + " " + String.valueOf(intent.getFloatExtra("VzG", 0))); mProgress1.setProgress((int) (10 * intent.getFloatExtra("Az", 0)) + 10); mProgress2.setProgress((int) (10 * Vz) + 10); mProgress3.setProgress((int) (50 * -VitesseZ) + 10); Log.d(TAG, "updateUI() " + time); time = SystemClock.elapsedRealtime(); if (SounCount == 9) { SounCount = 0; } else SounCount++; } public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { AmortVZ = ((float) progress / 100) * 10 + 1; SeekB1View.setText(String.valueOf(AmortVZ)); } }
Quelqu'un saurait-il me guider pour pallier ces problèmes ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275 package com.vinu.androfpv; import android.app.Service; import android.content.Intent; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.SystemClock; import android.util.FloatMath; import android.util.Log; public class TimerService extends Service implements SensorEventListener, LocationListener { private static final String TAG = "VinuFpv.TimerService"; public static final String BROADCAST_ACTION = "com.vinu.androfpv.displayevent"; private final Handler handler = new Handler(); Intent intent; int counter = 0; int altCount = 9; public int i = 1; SensorManager sensorManager; Sensor accelerometer; Sensor laccelerometer; Sensor magnetic; Sensor gravity; private LocationManager lm; float[] accelerometerVector = new float[3]; float[] laccelerometerVector = new float[3]; float[] magneticVector = new float[3]; float[] resultMatrix = new float[9]; float[] values = new float[3]; float[] orientation = new float[3]; float[] gravityVector = new float[3]; float lax = 0, lay = 0, laz = 0, ox, oy, oz, Vz = 0, vz = 0, vzGPS = 0; public double latitude; public double longitude; public double altitude; public double altitudePrev; public float accuracy; private static final boolean ADAPTIVE_ACCEL_FILTER = true; float lastAccel[] = new float[3]; float accelFilter[] = new float[3]; public long time; public boolean locChanged = false; @Override public void onCreate() { super.onCreate(); // Instancier le gestionnaire des capteurs, le SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); //if (sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER).size() > 0) TextViewAccelerometer.setText("Accelerometer OK"); // Instancier l'acc�l�rom�tre accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); laccelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION); magnetic = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); gravity = sensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY); sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_FASTEST); sensorManager.registerListener(this, laccelerometer, SensorManager.SENSOR_DELAY_FASTEST); sensorManager.registerListener(this, magnetic, SensorManager.SENSOR_DELAY_FASTEST); sensorManager.registerListener(this, gravity, SensorManager.SENSOR_DELAY_FASTEST); lm = (LocationManager) this.getSystemService(LOCATION_SERVICE); if (lm.isProviderEnabled(LocationManager.GPS_PROVIDER)) lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,100 , 0, this); intent = new Intent(BROADCAST_ACTION); } @Override public void onStart(Intent intent, int startId) { Log.d(TAG, "onStart()"); handler.removeCallbacks(sendUpdatesToUI); handler.postDelayed(sendUpdatesToUI, 500); } private Runnable sendUpdatesToUI = new Runnable() { public void run() { SendToMain(); handler.postDelayed(this, 30); } }; private void SendToMain() { time = SystemClock.elapsedRealtime() - time; Log.d(TAG, "SendToMain()" + i + " vz " + vz + " " + Vz /*+ " Lat " + latitude + " Long " + longitude + " Alt " + altitude + " Acc" + accuracy + vzGPS + ox+ " " + oy+ " " + oz+ " " */); vz = vz / i; intent.putExtra("locC", locChanged); if (locChanged) { vzGPS = (float) (altitude - altitudePrev) / time; locChanged = false; } altitudePrev = altitude; intent.putExtra("Ax", lax); intent.putExtra("Ay", lay); intent.putExtra("Az", laz); intent.putExtra("Ox", (float) Math.toDegrees((float) ox)); intent.putExtra("Oy", (float) Math.toDegrees((float) oy)); intent.putExtra("Oz", (float) Math.toDegrees((float) oz)); intent.putExtra("IntentVz", vz); intent.putExtra("counter", String.valueOf(i)); intent.putExtra("Lat", latitude); intent.putExtra("Long", longitude); intent.putExtra("Alt", altitude); intent.putExtra("Acc", accuracy); intent.putExtra("VzG", vzGPS); sendBroadcast(intent); vz = 0; i=0; altCount++; time = SystemClock.elapsedRealtime(); } public void onAccelerometerChanged(float accelX, float accelY, float accelZ) { // high pass filter float updateFreq = 30; // match this to your update speed float cutOffFreq = 2f; float RC = 1.0f / cutOffFreq; float dt = 1.0f / updateFreq; float filterConstant = RC / (dt + RC); float alpha = filterConstant; float kAccelerometerMinStep = 0.033f; float kAccelerometerNoiseAttenuation = 3.0f; if(ADAPTIVE_ACCEL_FILTER) { float d = (float) Clamp(Math.abs(Norm(accelFilter[0], accelFilter[1], accelFilter[2]) - Norm(accelX, accelY, accelZ)) / kAccelerometerMinStep - 1.0f, 0.0f, 1.0f); alpha = d * filterConstant / kAccelerometerNoiseAttenuation + (1.0f - d) * filterConstant; } lax = accelFilter[0] = (float) (alpha * (accelFilter[0] + accelX - lastAccel[0])); lay = accelFilter[1] = (float) (alpha * (accelFilter[1] + accelY - lastAccel[1])); laz = accelFilter[2] = (float) (alpha * (accelFilter[2] + accelZ - lastAccel[2])); lastAccel[0] = accelX; lastAccel[1] = accelY; lastAccel[2] = accelZ; //onFilteredAccelerometerChanged(accelFilter[0], accelFilter[1], accelFilter[2]); } double Clamp(double v, double min, double max) { if(v > max) return max; else if(v < min) return min; else return v; } double Norm(double x, double y, double z) { return Math.sqrt(x * x + y * y + z * z); } public void onAccuracyChanged(Sensor sensor, int accuracy) { // TODO Auto-generated method stub } public void onSensorChanged(SensorEvent event) { // TODO Auto-generated method stub if(event.sensor.getType() == Sensor.TYPE_LINEAR_ACCELERATION) { laccelerometerVector=event.values; onAccelerometerChanged(laccelerometerVector[0], laccelerometerVector[1], laccelerometerVector[2]); /*lax = laccelerometerVector[0]; lay = laccelerometerVector[1]; laz = laccelerometerVector[2];*/ } else if(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { accelerometerVector=event.values; /*ax = accelerometerVector[0]; ay = accelerometerVector[1]; az = accelerometerVector[2];*/ } /*else if(event.sensor.getType() == Sensor.TYPE_GRAVITY) { gravityVector=event.values; ax = gravityVector[0]; ay = gravityVector[1]; az = gravityVector[2]; }*/ else if(event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) { magneticVector=event.values; } SensorManager.getRotationMatrix(resultMatrix, null, accelerometerVector/*accelFilter*/, magneticVector); // Demander au SensorManager le vecteur d'orientation associ� (values) orientation = SensorManager.getOrientation(resultMatrix, values); // l'azimuth ox = orientation[0]; // le pitch oy = orientation[1]; // le roll oz = orientation[2]; //Vz = (float) (/*accelerometerVector[0] * Math.cos(orientation[1])*/+ accelerometerVector[0] * FloatMath.sin(orientation[2]) // + accelerometerVector[1] * FloatMath.sin(orientation[1]) //+ accelerometerVector[1] * Math.sin(orientation[2]) // /*- accelerometerVector[2] * Math.cos(orientation[1])*/ - accelerometerVector[2] * FloatMath.cos(orientation[2]) // + SensorManager.GRAVITY_EARTH); //Vz = (float) (/*accelerometerVector[0] * Math.cos(orientation[1])*/+ (accelFilter[0]) * FloatMath.sin(orientation[2]) // + (accelFilter[1]) * FloatMath.sin(orientation[1]) //+ accelerometerVector[1] * Math.sin(orientation[2]) // /*- accelerometerVector[2] * Math.cos(orientation[1])*/ - (accelFilter[2]) * FloatMath.cos(orientation[2]) // /*+ SensorManager.GRAVITY_EARTH*/); Vz = (float) (accelFilter[0] * FloatMath.sin(orientation[2]) - accelFilter[2] * FloatMath.cos(orientation[2])) * FloatMath.cos(orientation[1]) + accelFilter[1] * FloatMath.sin(orientation[1]) ; /*lax = accelerometerVector[0] * FloatMath.sin(orientation[2]); lay = accelerometerVector[1] * FloatMath.sin(orientation[1]); laz = - accelerometerVector[2] * FloatMath.cos(orientation[2]);*/ //vz = Vz; if (Vz < -0.1 || 0.1 < Vz) { vz += Vz; } i++; } @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } public void onLocationChanged(Location location) { latitude = location.getLatitude(); longitude = location.getLongitude(); altitude = location.getAltitude(); locChanged = true; accuracy = location.getAccuracy(); } public void onProviderDisabled(String provider) { // TODO Auto-generated method stub } public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } }
Merci d'avance pour votre aide.
Partager