I have an accelerometer mounted to an inverted pendulum (i.e. a cart-pole robot) which I'm using to measure the tilt angle from the vertical upright position (+y direction). If the inverted pendulum is held motionless at a fixed angle, the accelerometer essentially detects the gravity direction as a vector $(g_x,g_y)$ and the tilt angle $\theta$ can be determined by


However, if the inverted pendulum is in motion (e.g. if I'm dynamically trying to balance it like a cart-pole system), the pendulum itself is accelerating the accelerometer in a direction which is not necessarily the gravity direction. Acceleration from the cart may also distort the measurement of the gravity direction by the accelerometer as well. In such a case, I don't think the formula above is necessarily appropriate.

Of course, I'm not 100% sure that the swinging motion of the pendulum and the forward-backward motion of the cart are significant enough to distort the angle measurement on the accelerometer. I presume that if I start with initial conditions close to $\theta=0$ on the pendulum, it shouldn't be that significant. Nonetheless, if the pendulum is significantly perturbed by a disturbance force, I think the accelerometer's measurements must be compensated in some way.

How can I compensate for pendulum and cart accelerations when using an accelerometer to detect the tilt angle?

  • $\begingroup$ A sketch of your system with the axis as you use them would be helpful $\endgroup$
    – N. Staub
    Oct 2, 2017 at 10:29

1 Answer 1


If an accelerometer is mounted along the pole axis of a pole-cart system with its axes oriented tangential and normal to the pole rotation, the components of acceleration can be found using rigid body kinematics to yield the following:

Tangential: $S_x = \ddot{X} cos(\theta)-\alpha d-g sin(\theta)$,

Normal: $S_y = -\ddot{X} sin(\theta)-\omega^2 d-g cos(\theta)$,


  • $d$ is the distance from the sensor to the axis of rotation
  • $\ddot{X}$ is the horizontal acceleration of the cart
  • $\omega$ is the angular velocity of the pole, and
  • $\alpha$ is the angular acceleration of the pole

Cart-Pole System with accelerometer

This assumes the pole can be treated as a rigid body and that the cart is limited to motion in the horizontal plane.

Estimating the pole angle, $\theta$, using the measured acceleration components will produce an error if any of $\ddot{X},\omega,\alpha$ are non-zero.

$\theta \approx tan^{-1}\left ( \frac{S_x}{S_y} \right ) = sin^{-1}\left ( \frac{S_x}{\sqrt{S_x^2+S_y^2}} \right ) = cos^{-1}\left ( \frac{S_y}{\sqrt{S_x^2+S_y^2}} \right )$

(Note that the equation in the OP is incorrect.)

Whether this approximation will work with your system really depends on the parameters and the expected magnitudes of the angular velocity, angular acceleration, and horizontal acceleration. Compensating would likely require some additional sensors - e.g., a second accelerometer on the cart and a gyrometer on the pole.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.