How to expand the Fourier series for $f(x)=\max \{0, \frac{\pi}{2}-\lvert x\rvert \} $?
Hint: Consider the $2\pi$ continuation of $$f(x)=\begin{cases} 0 & x\in\left[-\pi, -\frac{\pi}{2}\right] \\ \frac{\pi}{2}+x & x\in \left[-\frac{\pi}{2}, 0\right] \\ \frac{\pi}{2}-x & x\in\left[0,\frac{\pi}{2}\right] \\ 0 & x\in\left[\frac{\pi}{2}, \pi\right]\end{cases}$$
Edit: As your function is even, each $b_n=0$. Also, the integral can be computed by integrating from $0$ to $\pi$ and multiplying the result by 2.
Since the function is even, the coefficients of $\sin nx$ are all zero. The constant term is the average value of the function on $[-\pi,\pi]$: $$ \frac{1}{2\pi}\int_{-\pi}^\pi f(x)\,dx\;=\; \frac{1}{2\pi}\left(\frac{\pi^2}{4}\right) \;=\; \frac{\pi}{8} $$ (The integral here was evaluated using the formula for the area of a triangle.)
The coefficient of $\cos nx$ is given by the formula $$ a_n \;=\; \frac{1}{\pi}\int_{-\pi}^\pi f(x)\,\cos nx\;dx $$ Since $f(x)$ is nonzero only on $[-\pi/2,\pi/2]$, this is the same as $$ a_n \;=\; \frac{1}{\pi}\int_{-\pi/2}^{\pi/2} f(x)\,\cos nx\;dx $$ Moreover, since $f(x) \cos nx$ is an even function, we can restrict to $[0,\pi/2]$ and double the integral: $$ a_n \;=\; \frac{2}{\pi}\int_0^{\pi/2} f(x)\,\cos nx\;dx \;=\; \frac{2}{\pi}\int_0^{\pi/2} \left(\frac{\pi}{2} - x\right)\,\cos nx\;dx $$ The integral on the right can be evaluated using integration by parts. The result is: $$ a_n \;=\; \begin{cases}\dfrac{2}{\pi n^2} & \text{if }n\equiv 1,3\pmod{4}, \\[6pt] \dfrac{4}{\pi n^2} & \text{if }n\equiv 2\pmod 4, \\[6pt] 0 & \text{if }n\equiv 0 \pmod{4}.\end{cases} $$ Thus $$ f(x) \;=\; \frac{\pi}{8} + \frac{2}{\pi}\cos x + \frac{1}{\pi}\cos 2x + \frac{2}{9\pi}\cos 3x + \frac{2}{25\pi}\cos 5x + \frac{1}{9\pi}\cos 6x + \cdots. $$ In summation form, $$ f(x) \;=\; \frac{\pi}{8} \,+\, \sum_{k=0}^\infty \frac{2}{\pi(2k+1)^2} \cos\bigl((2k+1)x\bigr) \,+\, \sum_{k=0}^\infty \frac{1}{\pi(2k+1)^2} \cos\bigl((4k+2)x\bigr). $$ By the way, the following animation shows thee convergence of this Fourier series for the first twelve terms: