Leveraging Least Squares for a Unified Methodology in Mobile Robotics and SLAM problems