I wrote a simple script that takes 2 polylines, explodes them into segments, then compares each segment’s length against the length of the other polyline’s segments. From the comparison, the smaller number is divided by the larger to get the ratio of their difference in length. This ratio is then used to modify a variable that represents the speed of a robot arm, so that both robots could theoretically move to each of their control points at the same time.
Here is that script:
#Calculate both Robots' Feed Rates to Match while <= MaxFeed import rhinoscriptsyntax as rs #Main Variables SlaveFeed =  MasterFeed =  Master = MasterTCP Slave = SlaveTCP #Break ToolPath into individual Moves Msegs = rs.ExplodeCurves(Master) Ssegs = rs.ExplodeCurves(Slave) #Make Sure there are the same number of moves for each robot if len(Msegs) != len(Ssegs): print "Unequal Line Segments!" MasterFeed = "Learn to count...." SlaveFeed = "Nope" #If there are = Moves, Find difference in length else: print "Same number of Moves for both Robots" for i in range(len(Msegs)): Mseglen = rs.CurveLength(Msegs[i]) Sseglen = rs.CurveLength(Ssegs[i]) #If Master Moves Farther than Slave, Slow Slave by length difference Ratio if Mseglen > Sseglen: Rlen = Sseglen/Mseglen SFeed = Rlen*MaxFeed MasterFeed.append(MaxFeed) SlaveFeed.append(SFeed) #If Slave Moves Farther than Master, Slow Master by length difference Ratio else: Rlen = Mseglen/Sseglen MFeed = Rlen*MaxFeed MasterFeed.append(MFeed) SlaveFeed.append(MaxFeed)
This script seems to be working fine, but I am now trying to coordinate more that 2 robots. For this I will need to find a way of checking which segment from each robot’s path is the longest, so that it can receive the fastest speed. Once I find the longest, I will need to calculate a ratio for each of the other lengths and append them to a list of Feed Rates. I am not sure how to set up this relationship of comparing more than 2 lengths. Anyone have an idea?
Sorry if the post is long/hard to follow. It is my first question on here.