Bellow is the complete function3 referred from earlier. Toward the very end of the function, I’ve added comments with numbers (1) and (2), for the two rows of interest. MainProgram calls a function1, which calls function2, which on its side calls function3. IsJoint is False and none of all the present ‘return None’ is executed due to errors. Function executes and when it exits, the program does not continue from function2 which called it, with the remaining code, instead it goes all the way back to the beginning of MainProgram. If I comment # (1) which is the last ‘return None’, or instead add a random line of code like uncommenting # (2) , program follows expected program flow and after exiting function3, program continues with the rest in function2 and then, the rest in function1, as expected.
def CalcExternalPoints():
#set tarPosition and tarJoint
if IsJoint:
tarPosition = get_forward_kin([tarPositionX, tarPositionY, tarPositionZ, tarPositionRX, tarPositionRY, tarPositionRZ])
tarJoint = [tarPositionX, tarPositionY, tarPositionZ, tarPositionRX, tarPositionRY, tarPositionRZ]
else:
tarPosition = p[tarPositionX, tarPositionY, tarPositionZ, tarPositionRX, tarPositionRY, tarPositionRZ]
if get_inverse_kin_has_solution(tarPosition):
tarJoint = get_inverse_kin(tarPosition)
else:
SetGeneralStatus(Busy = False, Error = True)
LogMessage("CalcExternalPoints: Error, no valid joint position for tarPosition", popup = True, pTitle = "Error!", pError = True)
return None
end
end
#set prePosition and preJoint - offset is treated only position wise
if IsJoint:
prePosition = get_forward_kin(tarJoint, p[offPositionX, offPositionY, offPositionZ, offPositionRX, offPositionRY, offPositionRZ])
if get_inverse_kin_has_solution(prePosition, tarJoint):
preJoint = get_inverse_kin(prePosition, tarJoint)
else:
SetGeneralStatus(Busy = False, Error = True)
LogMessage("CalcExternalPoints: Error, no valid joint position for prePosition", popup = True, pTitle = "Error!", pError = True)
return None
end
else:
prePosition = pose_trans(tarPosition, p[offPositionX, offPositionY, offPositionZ, offPositionRX, offPositionRY, offPositionRZ])
if get_inverse_kin_has_solution(prePosition):
preJoint = get_inverse_kin(prePosition)
else:
SetGeneralStatus(Busy = False, Error = True)
LogMessage("CalcExternalPoints: Error, no valid joint position for prePosition", popup = True, pTitle = "Error!", pError = True)
return None #(1) last return None with no code following it until the end of the function
end
end
#a = 0 #(2) random local variable assignment
end