The artificial potential field approach provides a simple and effective motion planner for robot navigation. However, the traditional artificial potential field approach in practice can have a local minimum problem, i.e., the attractive force from the target position is in the balance with the repulsive force from the obstacle, such that the robot cannot escape from this situation and reach the target. Moreover, the moving object detection and avoidance is still a challenging problem with the current artificial potential field method. In this paper, we present an improved version of the artificial potential field method, which uses a dynamic window approach to solve the local minimum problem and define a danger index in the speed field for moving object avoidance. The new danger index considers not only the relative distance between the robot and the obstacle, but also the relative velocity according to the motion of the moving objects. In this way, the robot can find an optimized path to avoid local minimum and moving obstacles, which is proved by our experimental results.