The method involves illuminating environment with a radiation of a sensor (1.2), and forming a three-dimensional image of the environment using the radiation reflected by the environment. The properties of the environment and its objects are deduced from the image of the environment. Work machines such as agricultural robots, are controlled based on reflected/ exploited sensor signals or properties of the environment and/or objects. An independent claim is also included for a system for capturing the environment.