def FeedLimitation(commands): feedrate=[] displacement=[] feedrate.append(0) displacement.append(0) velocity=0 first=commands[0] second=commands[1] third=commands[2] times=[] for i in range(3,len(commands)): if second.motion_type in motions and third.motion_type in motions: if second.feedrate==0 and (second.motion_type=="G00" or second.motion_type=="G0"): second.feedrate=MaxFeed if second.motion_type in straight: if third.motion_type in straight: cos=Methods.IncludedAngle(first.position, second.position, third.position, second.plane) if cos==2: velocity=0 elif cos==1: velocity=min(second.feedrate/60,third.feedrate/60) else: velocity=min(second.feedrate/60,third.feedrate/60,Acc*Period/(1-cos)) elif third.motion_type in circular: center=cl.position(second.position.x+third.position.i, second.position.y+third.position.j, second.position.z+third.position.k,0,0,0,third.position.r) endpoint = Methods.TangentPoint(second.position,center,5,third.motion_type,second.plane) cos=Methods.IncludedAngle(first.position,second.position,endpoint,second.plane) if cos == 2: velocity=0 elif cos==1: velocity=min(second.feedrate/60,third.feedrate/60,2*np.sqrt(ChordError*(2*center.r-ChordError))/Period) else: velocity=min(second.feedrate/60,third.feedrate/60,Acc*Period/(1-cos),2*np.sqrt(ChordError*(2*center.r-ChordError))/Period) length=Methods.LinearLength(first.position,second.position) velocity=CheckFeedrate(feedrate[-1],np.round(velocity,6),length) elif second.motion_type in circular: center=cl.position(first.position.x+second.position.i,first.position.y+second.position.j, first.position.z+second.position.k,0,0,0,second.position.r) chord_temp=2*np.sqrt(ChordError*(2*center.r-ChordError))/Period endpoint=Methods.TangentPoint(second.position,center,-5,second.motion_type,second.plane) if third.motion_type in straight: cos=Methods.IncludedAngle(endpoint,second.position,third.position,second.plane) if cos==2: velocity=0 elif cos==1: velocity=min(second.feedrate/60,third.feedrate/60) else: velocity=min(second.feedrate/60,third.feedrate/60,chord_temp,Acc*Period/(1-cos)) elif third.motion_type in circular: center1=cl.position(second.position.x+third.position.i,second.position.y+third.position.j,second.position.z+third.position.k, 0,0,0,third.position.r) endpoint1=Methods.TangentPoint(second.position,center1,5,third.motion_type,third.plane) cos=Methods.IncludedAngle(endpoint,second.position,endpoint1,third.plane) if cos==2: velocity=0 elif cos==1: velocity=min(second.feedrate/60,third.feedrate/60,chord_temp,2*np.sqrt(ChordError*(2*center1.r-ChordError))/Period) else: velocity=min(second.feedrate/60,third.feedrate/60,chord_temp,Acc*Period/(1-cos), 2*np.sqrt(ChordError*(2*center1.r-ChordError))/Period) length=Methods.CircularLength(first.position,second.position,center,second.motion_type,second.plane) velocity=CheckFeedrate(feedrate[-1],np.round(velocity,6),length) #time=ScheduleSingleBlock(feedrate[-1],velocity,length,second.feedrate/60) #times.append(time) feedrate.append(velocity) displacement.append(length) first=second second=third third=commands[i] return feedrate,displacement