Finding a path solution in a dynamic environment represents a challenge for the robotics researchers, furthermore, it is the main issue for autonomous robots and manipulators since nowadays the world is looking forward to this challenge. The collision free path for robot in an environment with moving obstacles such as different objects, humans, animals or other robots is considered as an actual problem that needs to be solved. In addition, the local minima and sharp edges are the most common problems in all path planning algorithms. The main objective of this work is to overcome these problems by demonstrating the robot path planning and obstacle avoidance using D star (D*) algorithm based on Particle Swarm Optimization (PSO) technique. Moreover, this work focuses on computational part of motion planning in completely changing dynamic environment at every motion sample domains. Since the environment type that discussed here is a known dynamic environment, the solution approach can be off-line. The main advantage of the off-line planning is that a global optimal path solution is always obtained, which is able to overcome all the difficulties caused by the dynamic behavior of the obstacles. A mixing approach of robot path planning using the heuristic method D* algorithm based on optimization technique is used. The heuristic D* method is chosen for finding the shortest path. Furthermore, to insure the path length optimality and for enhancing the final path, PSO technique has been utilized. The robot type has been used here is the two-link robot arm which represents a more difficult case than the mobile robot. Simulation results are given to show the effectiveness of the proposed method which clearly shows a completely safe and short path.