How can I do the calculation to know if the line is passing through the rectangle (obstacle), since I only know the position of sta1 and sta2 and I also know the x_min, x_max and y_min, y_max of the rectangle?
Can you construct the input needed by Findinstance from the information you have about the points and test whether the result returned from FindInstance is an empty list or not?