Yes, you are right. 'can you' is asking about ability, and 'do you' is asking about your habits. That's certainly the case with swimming.
In terms of language, 'can you' is more direct, if it is unclear (e.g when you go to a counter in a non-English-speaking country). I don't think it is normally rude, but could be in certain circumstances it could be. e.g. I might occasionally say that to telemarketers with really bad accents! It is possibly even more polite, as 'can you' can be interpreted as both 'do you have the ability' and 'can you please'.