We can treat human responses to cognitions as involving law-like connections grounded on free choices which show themselves in our character.
Kant does not think that along with choice of an action we also choose in each case the motive from which we do it. He thinks all is well if I act beneficently, realizing that it is my duty but also having sympathetic feelings for the person I help. But I ought to strive to be the sort of person who would still help even if these feelings were absent. And it is such a case that he presents when the sympathetic friend of humanity finds his sympathetic feelings overclouded by his own sorrows, and still acts beneficently from duty.