The very idea of "ought" itself implies the possibility of choice by a free will, as opposed to some other choice. Thus it stands apart from purely mechanical causality. Where no freedom of will exists the "ought" does not exist or cannot be properly applied.
We may say that the dog who eats the sandwich on the kitchen counter, ought not to have done that and is a "bad dog!" But we do not grant the dog moral choice and free will, at least not same degree as those of us with self-reflection and the moral example of the Son of God.
The dog is, as Pavlov would demonstrate, at least partly "mechanical," though not perhaps a Cartesian automaton. Our application of "ought" to the dog is merely anthropocentrism and whimsey. A behaviorally conditioned human is another matter, and I don't think Kant every contemplated or would ever accept humans "beyond freedom and dignity," except as the most horrible injustice.
So free will is required for any "ought." But free will requires worldly traction and can't simply skate around in our frictionless daydreams. Without the possibility of action, the moral exercise of free will cannot be exercised. Not to achieve goals per se, but to prove to itself its true intent.
Unlike existentialists, Kant may be willing for forego the imperative of actualized choice, I'm not sure about that. But where there is no possibility of a free action, the "ought" does not come into play. We are simply locked into the gears of the mechanical universe. The "can" is part of what is meant by "ought."
It is notable that the "ought" of Kant's CI is generally considered too empty of content for too many real-world cases. And it is illustrated by negation through actions, such as lying, that you "ought not" to do. The moral law applies in the realm of possibility, as presented to the life of the individual Protestant soul, the synthetic a priori realm where things can be done.
So, interestingly, Kant probably saw no moral duty to do all in his power to free the American slaves, though arguably within his maxim, whereas a utilitarian like Singer would, and in that sense seems more "universal." This may be a strike against against Kant's blend of Enlightenment liberalism and Christian universalism, a specter that still haunts liberalism.