Pick-and-Place (robots) rotation angles

I have a question , how to calculate the angle block of pickandplace.for example, as attachment, the black is wall, I dont want the robot void to crash it. so how much block angle I should set? thank you. and another question , the process is G1->G2->G3,after the robot put the MU from G1 to G2, the robot will turn to a place, when G2 finish,then turn back to G2, rather than always stay G2. why?