2. For any real number $x$, the value of the function $f(x)=x^{2}-2 x-|x-1-a|-|x-2|+4$ is a non-negative real number, then the range of the real number $a$ is $\qquad$.
2. Solution: From the conditions, we have $\left\{\begin{array}{l}f(0)=-|1+a|+2 \geqslant 0 \\ f(1)=-|a|+2 \geqslant 0\end{array}\right.$, solving this gives $-2 \leqslant a \leqslant 1$.

Next, we prove: When $-2 \leqslant a \leqslant 1$, for any $x \in \mathbf{R}$, we have $f(x) \geqslant 0$,

In fact, let $t=x-1$, then $f(x)=t^{2}-|t-a|-|t-1|+3$,
Let $g(t)=t^{2}+3-|t-a|-|t-1|$,
When $t \leqslant a$, $g(t)=t^{2}+3-(a-t)-(1-t)=(t+1)^{2}+(1-a) \geqslant 0$

When $a < t \leqslant 1$, $g(t)=t^{2}+3-(t-a)-(t-1)=t^{2}-2t+4+a=(t-1)^{2}+3+a \geqslant 3+a \geqslant 1$,

Therefore, when $-2 \leqslant a \leqslant 1$, we always have $f(x) \geqslant 0$, so the set of $a$ that satisfies the condition is $\{a \mid -2 \leqslant a \leqslant 1\}$.