Lockpicking is an ability based on Perception. By default, you can open the simplest locks. This ability is useful when trying to get to unavailable parts of locations, where interesting items are frequently hidden. You can also open cases, chests and safes. You can also open the trailers of some trucks. When opening a lock, the time is stopped and you see a lock and a bobby pin. If you don't have high perception or you don't like to collect everything and you will decide that you don't need this ability very much, you can invest in hacking. Key points: safes, closed warehouse rooms etc. very often offer access through both methods.
In order to open locks, you need to have bobby pins. Each of them is wearing off and after some time, it breaks (very often during a single opening of a lock). Stopping the lockpicking in order to regenerate the pin will not help, its state is remembered by the game. The bobby pins are quite common in the game world, very frequently you will find them in boxes in large numbers. You can also cheaply buy them from merchants.
In order to successfully open the lock, first you must try to open the lock in "0" position by using the left or right direction button. If the pin starts vibrating, it means it is in bad position. You change the position of the bobby pin with the mouse or analog stick. You must find the perfect point in which the lock opens. You will find that point thanks to the fact that, when you're close, the lock is partially rotating - the closer you are, the more rotation. Easy and medium locks are quite easy to open with just a single bobby pin.