When NASA was trying to figure out how to keep track of where they were, the helped develop the new technology of a IMU or Inertial Measurement Unit. It saved Apollo 13 from a death in space.
https://airandspace.si.edu/stories/editorial/restarting-apollo-13-command-module-imu
Also, for the moon buggy, they knew it would be easy to drive out of view of the lunar lander. If batteries were low, they wanted a direct path back to the lander, and not have to back track. A small IMU was used. It could calculate just where they were, and the fastest route back to the lander.
All cell phones now have a IMU and that is how it knows you just raised it up to your face to read or use it. The IMUs are super tiny now, and the ones NASA developed when from refrigerator size to something to fit on a space craft.