To show degrees of ability, we can use modal verbs. These show:
1. ability or opportunity in the present
2. ability or opportunity in the past
3. ability in the future:
To show ability in the present we use can or be able to often with verbs of perception. N.B. In most cases be able to is more formal than can.
When we talk about ability in the past the choice between could or was/were able to takes on an extra meaning.
Both examples say that I had the opportunity or ability to leave, but could implies I did not leave while was able to implies I did leave.
When we talk about a real past action we use was/were able to and when we talk about a hypothetical course of action we us could.
When we talk about a skill, could and was/were able to are interchangeable.
Note that in conditional sentences could and be able to are also interchangeable.
In questions, can and could are requests, wiht could being slightly more formal, while be able to asks about actual ability.