In this paper, we present a novel method for obstacle avoidance designed for a nonholonomic mobile robot. The method relies on light detection and ranging (LiDAR) readings, which are mapped into a polar coordinate system. Obstacles are taken into consideration when they are within a predefined radius from the robot. A central part of the approach is a new Heading Weight Function (HWF), in which the beams within the aperture angle of the LiDAR are virtually weighted in order to generate the best trajectory candidate for the robot. The HWF is designed to find a solution also in the case of a local-minima situation. The function is coupled with the robot’s controller in order to provide both linear and angular velocities. We tested the method both by simulations in a digital environment with a range of different static obstacles, and in a real, experimental environment including static and dynamic obstacles. The results showed that when utilizing the novel HWF, the robot was able to navigate safely toward the target while avoiding all obstacles included in the tests. Our findings thus show that it is possible for a robot to navigate safely in a populated environment using this method, and that sufficient efficiency in navigation may be obtained without basing the method on a global planner. This is particularly promising for navigation challenges occurring in unknown environments where models of the world cannot be obtained.