Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6621277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:14:31+00:00 2026-05-25T21:14:31+00:00

Recently I have made some research to use both the accelerometer + Gyroscope to

  • 0

Recently I have made some research to use both the accelerometer + Gyroscope to use those senser to track a smartphone without the help of the GPS (see this post)
Indoor Positioning System based on Gyroscope and Accelerometer

For that purpose I will need my orientation (angle (pitch, roll etc..)) so here what i have done so far:

public void onSensorChanged(SensorEvent arg0) {
    if (arg0.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
    {
        accel[0] = arg0.values[0];
         accel[1] = arg0.values[1];
   accel[2] = arg0.values[2];
   pitch = Math.toDegrees(Math.atan2(accel[1], Math.sqrt(Math.pow(accel[2], 2) + Math.pow(accel[0], 2))));

  tv2.setText("Pitch: " + pitch + "\n" + "Roll: " + roll);

   } else if (arg0.sensor.getType() == Sensor.TYPE_GYROSCOPE )
{
  if (timestamp != 0) {
  final float dT = (arg0.timestamp - timestamp) * NS2S;         
  angle[0] += arg0.values[0] * dT;
  filtered_angle[0] = (0.98f) * (filtered_angle[0] + arg0.values[0] * dT) + (0.02f)* (pitch);
   }        
   timestamp = arg0.timestamp;
 }
}

Here I’m trying to angle (just for testing) from my accelerometer (pitch), from integration the gyroscope_X trough time filtering it with a complementary filter

filtered_angle[0] = (0.98f) * (filtered_angle[0] + gyro_x * dT) + (0.02f)* (pitch)

with dT begin more or less 0.009 secondes

But I don’t know why but my angle are not really accurate…when the device is position flat on the table (Screen facing up)

Pitch (angle fromm accel) = 1.5 (average) 
Integrate gyro = 0 to growing (normal it's drifting) 
filtered gyro angle = 1.2

and when I lift the phone of 90° (see the screen is facing the wall in front of me)

Pitch (angle fromm accel) = 86 (MAXIMUM) 
Integrate gyro = he is out ok its normal 
filtered gyro angle = 83 (MAXIMUM)

So the angles never reach 90 ??? Even if I try to lift the phone a bit more…
Why doesn’t it going until 90° ? Are my calculation wrong? or is the quality of the sensor crap?

AN other thing that I’m wondering it is that: with Android I don’t “read out” the value of the sensor but I’m notified when they change. The problem is that as you see in the code the Accel and Gyro share the same method…. so when I compute the filtered angle I will take the pitch of the accel measure 0.009 seconds before, no ? Is that maybe the source of my problem?

Thank you !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:14:32+00:00Added an answer on May 25, 2026 at 9:14 pm

    I can only repeat myself.

    You get position by integrating the linear acceleration twice but the error is horrible. It is useless in practice. In other words, you are trying to solve the impossible.

    What you actually can do is to track just the orientation.

    Roll, pitch and yaw are evil, do not use them. Check in the video I already recommended, at 38:25.

    Here is an excellent tutorial on how to track orientation with gyros and accelerometers.

    Similar questions that you might find helpful:

    track small movements of iphone with no GPS
    What is the real world accuracy of phone accelerometers when used for positioning?
    how to calculate phone's movement in the vertical direction from rest?
    iOS: Movement Precision in 3D Space
    How to use Accelerometer to measure distance for Android Application Development
    Distance moved by Accelerometer
    How can I find distance traveled with a gyroscope and accelerometer?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently reinstalled MacOSX, and at some point (without realizing it) I made
I have recently made some changes to my hosting account and a script I
I have recently started learning Java EE 6 and I could need some help.
I have an iPhone app that is using CoreData. I recently made some minor
Recently I have discovered that my release executable (made with msvc++ express 2008) becomes
I released an update to one of my apps recently. This update made some
We have recently migrated some 30 DTS packages in SQL Server 2000 to SSIS
I'm working with some SQL 2005 CLR code written in C#. We have recently
I recently made some changes to my development environment and came across a problem.
I've recently started using Cucumber & Subdomain-fu together, and it's made me do some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.