Raw dead reckoning data is obtained from an inertial measurement unit (IMU) worn by a user. Drift in the raw data is compensated for by detecting a gait of the user and phase of that gait, and constraining the position of the IMU to lie within corresponding bounds as the IMU moves. The bounds depend on the bodily geometry of the user and the detected gait phase. The raw orientation data of the IMU may be also corrected for drift in a similar way. Gait and gait phase may be detected by sensors in an energy harvester worn around the knee, for example. Drift in the IMU measurements can be compensated for without depending on a GPS signal or on the earth's magnetic field.