I'm build an app for mountain biking, and I would like to estimate the ground slope using the phone'

Rebecca Villa 2022-07-12 Answered
I'm build an app for mountain biking, and I would like to estimate the ground slope using the phone's integrated accelerometer so that I can adapt my pedaling effort based on the current slope.
I took the Y-axis value of the accelerometer and converted it to degrees, using a notion abs(y-axis) * 90 with a offset. So, for example, if the accelerometer reads 0.5 or -0.5 on the Y-axis, that's converted to 45°. If I zero out the accelerometer, that 45° is now considered as 0°, and any frontal movement is negative and back movement is positive. I use that value for slope calculation.
Now, that works perfectly fine when standing still. When I angle the phone at 45° the slope is 100%.
But, problems arise in the real world. Since I'm using a accelerometer for my angle detection, readings when hitting potholes and bumps in the road go all over the place. One second I read 80%, the next -300%, and so on.
What can I do to smooth out the readings and make them semi-accurate?
I could try to discard any invalid value, such as anything +-20% of slope and average that over 10 seconds, but I feel that would be inaccurate.
I was looking into the Kalman filter, based on a thesis on slope detection using an accelerometer for Scania trucks, but the jerking of a truck is much less violent than that of a mountain bike.
What can I do to predict and smooth out sensor values over time?
You can still ask an expert for help

Expert Community at Your Service

  • Live experts 24/7
  • Questions are typically answered in as fast as 30 minutes
  • Personalized clear answers
Learn more

Solve your problem for the price of one coffee

  • Available 24/7
  • Math expert for every subject
  • Pay only if we can solve it
Ask Question

Answers (1)

isscacabby17
Answered 2022-07-13 Author has 13 answers
The easiest way is to simply low pass filter it to get rid of frequencies that you are not interested in. For example, let's say that on most roads and trails, the inclination can only change at α Hertz. Think of riding a bicycle on a sinusoid with a certain frequency. How high of a frequency sinusoid do you think you will be navigating? Even if you don't know the value, you can start with a ballpark, say 5 Hertz (that sounds like a lot) and roll back.
θ ^ ( k ) be an estimate of your inclination at time k,
and θ a c c e l ( k ) be the measurement. Then from your estimate, chop off everything above a frequency of w c :
θ ^ ( k + 1 ) = ( 1 w c T s ) θ ^ ( k ) + w c T s θ a c c e l ( k ) ,,where wc is the cutoff frequency in Hz and Ts is the sample rate. I think you can get about 50Hz sample rate from Android phones. That depends on your device.
The Kalman filter route is more complicated and its performance comes when you know more about the problem. You need a model for your movement (can you tell me what your inclination will be for the next ten seconds if I gave you your correct inclination now and removed the accelerometer?), and noise modeling (can you tell me how much noise on the accelerometer is because of the fact that any movement means the accelerometer is no longer measuring gravity?).
Did you like this example?
Subscribe for all access

Expert Community at Your Service

  • Live experts 24/7
  • Questions are typically answered in as fast as 30 minutes
  • Personalized clear answers
Learn more

You might be interested in

asked 2021-02-23
Interpreting z-scores: Complete the following statements using your knowledge about z-scores.
a. If the data is weight, the z-score for someone who is overweight would be
-positive
-negative
-zero
b. If the data is IQ test scores, an individual with a negative z-score would have a
-high IQ
-low IQ
-average IQ
c. If the data is time spent watching TV, an individual with a z-score of zero would
-watch very little TV
-watch a lot of TV
-watch the average amount of TV
d. If the data is annual salary in the U.S and the population is all legally employed people in the U.S., the z-scores of people who make minimum wage would be
-positive
-negative
-zero
asked 2022-05-23
Bookkeeping is mainly concerned with
a. All options are correct.
b. Interpreting the data.
c. Recording the economic activities.
d. Designing the systems for recording, classifying and summarizing.
asked 2020-10-28
Given any two numbers, which is greater, the LCM of the numbers or the GCF of the numbers? Why?
asked 2022-06-26
Survivor function of a variable that has discrete and continuous components
I'm currently reading The Statistical Analysis of Failure Time Data by Kalbfleisch and Prentice and had trouble at arriving at the expression for the survivor function of a random variable T having both discrete and continuous components. The setup is the following:
Let T be a random variable on [ 0 , ) with survivor function F(t)=P(T>t). Then
if T is absolutely continuous with density f, then the hazard function λ can be defined as
λ ( t ) := lim h 0 + P ( t T < t + h T t ) h = f ( t ) F ( t )
for t 0, and hence we have
F ( t ) = exp ( 0 t λ ( s ) d s ) , t 0.
if T is discrete taking on the values 0 a 1 < a 2 < , then we define the hazard at a i as
λ i = P ( T = a i T a i ) , i = 1 , 2 , .
Then we can show that
F ( t ) = j a j t ( 1 λ j ) , t 0.
These expressions for the survivor functions I am ok with. Now they write the following:
More generally, the distribution of T may have both discrete and continuous components. In this case, the hazard function can be defined to have the continuous component λ c ( t ) and discrete components λ 1 , λ 2 , at the discrete times a 1 < a 2 <
The overall survivor function can then be written
(1) F ( t ) = exp ( 0 t λ c ( s ) d s ) j a j t ( 1 λ j ) .
That T has both discrete and continuous components means that the distribution of T is of the form
P T ( d x ) = f c ( x ) λ ( d x ) + j = 1 b j δ a j ( d x )
or equivalently
P ( T A ) = A f c ( x ) d x + j a j A b j
for some sequence a 1 < a 2 < and b i ( 0 , 1 ) and some non-negative measurable function f c with 0 f c d λ + i = 1 b j = 1. If we define
λ c ( t ) = f c ( t ) P ( T t ) = f c ( t ) F ( t ) , t a i ,
and
λ i = P ( T = a i T a i ) ,
then how do I show (and is it even true) that the survivor function of T is given by (1)?
asked 2022-07-07
Shouldn't the probability of sampling a point from a continuous distribution be 0?
Hey I was reading about Gaussian EM algorithm in which you first calculate the likelihood of data points being sampled from a Gaussian and then adjust your mean and variance to maximize it. To calculate the probability of a point being sampled from a distribution we do
P ( x i θ ) = 1 2 π σ 2 exp ( ( x i μ ) 2 2 σ 2 )
But how can you sample a point from a continuous distribution? Shouldn't this be zero? Moreover I read many times about sampling a point/data from some continuous distribution but I can't understand how could you do that as for continuous random variable X the P ( X = x 1 ) = 0, so how could yo sample data point(s) from a continuous distribution?
Or does this sampling have some other meaning. I've seen many questions on this platform but I couldn't get my answer.
asked 2022-07-09
Better understanding of the pre sheaf kernel of φ
I'm currently reading chapter II of Hartshorne's algebraic geometry and am comfortable with the definition of a sheaf. I am new to the idea of the presheaf kernel of φ however.
Let φ : F G be a morphism of pre sheaves of abelian groups on a topological space X.
Am I correct in defining the kernel pre sheaf on φ to be the contra variant functor that consists of the data
For every open set U X, we have an abelian group Γ ( ker φ ( U ) , F )
For every inclusion V U open sets in X, we have a morphism ρ U V : Γ ( ker φ ( U ) , F ) Γ ( ker φ ( V ) , F ) that satisfies the usual three conditions (empty set, identity map and composition condition)?
Moreover,
Hartshorne remarks that while the pre sheaf kernel is a sheaf, in general, the pre sheaf cockernel and image are not sheaves. Is there any intuition for why this would be so?
asked 2022-02-12
Represent the following sentence as an algebraic expression, where "a number" is the letter x. A number is subtracted from 2.