When we talk about ability, we mean two things. First, we mean general ability. This is something that once you have learned you can do any time you want, like being able to read or swim or speak a language, for example. The other kind of ability is specific ability. This mean something that you can or can't do in one particular situation. For example, being able to lift something heavy, or find somewhere you are looking for.
can / can't (for both general and specific ability)
I can play the piano.
He can't drive – he's too tired.
We can't come now.
Past : could / couldn't (for general ability)
I could read when I was four.
My grandfather couldn't swim.
was able to / couldn't (for specific ability)
She was able to pass the exam, even though she hadn't studied much.(not 'she could pass')
He called us because he couldn't find the house.
I couldn't open the window.
could + have + past participle (an ability someone had in the past, but didn't use)
I could have played the piano well but I didn't practise enough.