Let $M$ be a smooth manifold and $G$ a Lie group acting properly on $M$. Let $k$ be the codimension of a maximal dimensional $G$-orbit in $M$.

Is it always possible to construct $k$ functions $f_1, \dots, f_k \colon M \to \mathbb{R}$, such that $f_1, \dots , f_k$ are $G$-invariant and functionally independent on an open and dense subset of $M$?

If it is not possible, under which further assumptions could it be true?