Autonomous mobile robots developed using metaheuristic algorithms are increasingly becoming a hot topic in control and computer sciences. Specifically, finding the shortest route to the goal and avoiding hurdles are current subjects of autonomous mobile robots. The Modified Grey Wolf Optimization (MGWO) is demonstrated in this work using two approaches: first, the Adaptive Adjustment Approach of the Control Parameters, and second, the Adaptive Variable Weights method. Those two methods are utilized for updating the wolf position, accelerate convergence, and cut down on time. The proposed online optimization approach is used in three different environments including an environment with unknown static obstacles, dynamic obstacles, and an environment with a dynamic target. The online optimization method is performed using two phases which are the sensors reading phase and the path calculation phase. The proposed approach can solve a local minima problem in the static obstacles. A comparison study result between the proposed method and two other algorithms revealed that the proposed algorithm performed better in avoiding obstacles, which include the situation with the local minima. Finally, when put to comparison with Hybrid Fuzzy-Wind Driven Optimization and Adaptive Particle Swarm Optimization the average improvement rates in route length are 2.86% and 4.70391%, respectively.