I started writing this, as a solution, but I didn't end up on a neat solution (although I am certain it exists). In any case you can find a solution with numerical methods at end. If I find the neater way I will update.
Assuming that :
- the end of bar s is point S
- the end of bar p is point P
- the length of bar p,q,s are respectively $L_p, L_q, L_s$
- the angles of bars p,s are respectively $\theta_p, \theta_s$
- the beginning of the coordinate system is at the bottom left end of bar s.
Then the coordinates for :
$$\vec S = \begin{bmatrix}L_s \cos \theta_s \\L_s \sin \theta_s \\0\end{bmatrix}$$
$$\vec P = \begin{bmatrix}L_q + L_p \cos \theta_p \\L_s \sin \theta_p \\0\end{bmatrix}$$
Then the distance between S and P as a vector is
$$ \vec P -\vec S = \begin{bmatrix}L_q + L_p \cos \theta_p \\L_s \sin \theta_p \\0\end{bmatrix} - \begin{bmatrix}L_s \cos \theta_s \\L_s \sin \theta_s \\0\end{bmatrix} =
\begin{bmatrix}L_q + L_p \cos \theta_p - L_s \cos \theta_s \\L_s \sin \theta_p -L_s \sin \theta_s \\0\end{bmatrix}$$
Therefore the distance between points P and S should be equal to the length of rod l:
$$(L_q + L_p \cos \theta_p - L_s \cos \theta_s)^2 + (L_s \sin \theta_p -L_s \sin \theta_s)^2 = L_l^2$$
if we expand and we collect all $L_p$ and $L_s$:
$$L_p^2 \left(\sin ^2(\theta_p)+\cos ^2(\theta_p)\right)+L_p (2 L_q
\cos (\theta_p)+L_s (-2 \sin (\theta_p) \sin (\theta_s)-2 \cos (\theta_p) \cos
(\theta_s)))+L_q^2-2 L_q L_s \cos (\theta_s)+L_s^2 \left(\sin
^2(\theta_s)+\cos ^2(\theta_s)\right) = L_l^2$$
Substituting $\left(\sin ^2(\theta_p)+\cos ^2(\theta_p)\right) = 1 =\left(\sin
^2(\theta_s)+\cos ^2(\theta_s)\right) $, simplifies the above to
$$L_p^2 +L_p (2 L_q
\cos (\theta_p)+L_s (-2 \sin (\theta_p) \sin (\theta_s)-2 \cos (\theta_p) \cos
(\theta_s)))+L_q^2-2 L_q L_s \cos (\theta_s)+L_s^2 = L_l^2$$
$$L_p (2 L_q
\cos (\theta_p)-2 L_s ( \sin (\theta_p) \sin (\theta_s)+ \cos (\theta_p) \cos
(\theta_s)))= L_l^2 - (L_p^2 - L_q^2-2 L_q L_s \cos (\theta_s)+L_s^2) $$
Also because $ \sin (\theta_p) \sin (\theta_s)+ \cos (\theta_p) \cos
(\theta_s)) = \cos(\theta_p+\theta_s)$
$$L_p (2 L_q
\cos (\theta_p)-2 L_s ( \cos(\theta_p+\theta_s)))= L_l^2 - (L_p^2 - L_q^2-2 L_q L_s \cos (\theta_s)+L_s^2) $$
$$L_q
\cos (\theta_p)-L_s ( \cos(\theta_p+\theta_s))=\frac{1}{2 L_p }\left( L_l^2 - (L_p^2 - L_q^2-2 L_q L_s \cos (\theta_s)+L_s^2) \right) $$
At this point you can probably find a clevel trigonometrical way to solve this (I am not that good), but in this form it would be easy enough to find a numerical solution to the equation by assuming a value for $\theta_s$.