How to measure acceleration and orientation