4. Given that $f(x)$ is an odd function defined on $\mathbf{R}$, when $x \leqslant 0$,
$$
f(x)=\left|x+\frac{1}{2} \sin \alpha\right|+\left|x+\frac{3}{2} \sin \alpha\right|-2 \sin \alpha,
$$

where $\alpha \in(-\pi, \pi)$. If for any real number $x$, we have $f(x) \geqslant f(x+2)$, then the range of $\alpha$ is $\qquad$
4. $\left[0, \frac{\pi}{6}\right] \cup\left[\frac{5 \pi}{6}, \pi\right)$.

Since $f(x)$ is an odd function on $\mathbf{R}$, we know $f(0)=0$, i.e.,
$2|\sin \alpha|-2 \sin \alpha=0$
$\Rightarrow \sin \alpha \geqslant 0$.
When $x \leqslant 0$,
$f(x)$
$$
=\left\{\begin{array}{ll}
-2 x-4 \sin \alpha, & x \leqslant-\frac{3}{2} \sin \alpha ; \\
-\sin \alpha, & -\frac{3}{2} \sin \alpha<x<-\frac{1}{2} \sin \alpha ; \\
2 x, & -\frac{1}{2} \sin \alpha \leqslant x \leqslant 0 .
\end{array}\right.
$$

By symmetry, the graph of the function can be drawn, as shown in Figure 2.
To ensure that for any $x \in \mathbf{R}$,
$$
f(x) \geqslant f(x+2) \text {, }
$$

i.e., shifting $f(x)$ two units to the left does not place it above $f(x)$.
Then $2 \sin \alpha-(-2 \sin \alpha) \leqslant 2$
$\Rightarrow \sin \alpha \leqslant \frac{1}{2}$.
In summary, $\alpha \in\left[0, \frac{\pi}{6}\right] \cup\left[\frac{5 \pi}{6}, \pi\right)$.