In recent years, the mobile robot has been considerable attention to researchers for its application in various environments. For a mobile robot navigating its way from starting point to a goal point while traversing through deterrents, needs to recognize the obstacles and generate new trajectories to reach the destination. This paper presents an obstacle avoidance method for mobile robots using an open-source in robot operation system (ROS) combining with the dynamic window approach (DWA) algorithm. The experiment is carried out using a mobile robot in which the navigation data is based on data collecting by a laser scanner. The experimental results show that the robot could work well in environments containing static and dynamic obstacles.