So it converged on practically the same parameters, except chain sag is substantially different, but that’s not surprising. The end error value was 0.93 just like the current method.
This is the routine I’m using:
leftForce = chainSagCorrection/((targetX-leftMotorX)/(leftMotorY-targetY)+(rightMotorX-targetX)/(rightMotorY-targetY))*math.sqrt(math.pow(((rightMotorX-targetX)/(rightMotorY-targetY)),2)*math.pow(((targetX-leftMotorX)/(leftMotorY-targetY)),2)+math.pow(((rightMotorX-targetX)/(rightMotorY-targetY)),2)) rightForce =chainSagCorrection/((targetX-leftMotorX)/(leftMotorY-targetY)+(rightMotorX-targetX)/(rightMotorY-targetY))*math.sqrt(math.pow(((rightMotorX-targetX)/(rightMotorY-targetY)),2)*math.pow(((targetX-leftMotorX)/(leftMotorY-targetY)),2)+math.pow(((targetX-leftMotorX)/(leftMotorY-targetY)),2))
hl = math.cos(leftChainAngleTarget)*leftChainStraightTarget*0.00328084
hr = math.cos(rightChainAngleTarget)*rightChainStraightTarget*0.00328084
vl = math.sin(leftChainAngleTarget)*leftChainStraightTarget*0.00328084
vr = math.sin(rightChainAngleTarget)*rightChainStraightTarget*0.00328084
al = math.cos(leftChainAngleTarget)*leftForce/0.09
ar = math.cos(rightChainAngleTarget)*rightForce/0.09
leftChainSag = math.sqrt( math.pow((2*al*math.sinh(hl/(2*al))),2)+vl*vl)/0.00328084
rightChainSag = math.sqrt( math.pow((2*ar*math.sinh(hr/(2*ar))),2)+vr*vr)/0.00328084
LChainLengthTarget = (leftChainAroundSprocketTarget + leftChainSag*leftChainTolerance)-rotationRadius
RChainLengthTarget = (rightChainAroundSprocketTarget + rightChainSag*rightChainTolerance)-rotationRadius
The force calculation appears dimensionless (the part that divides into chainSagCorrection) so I don’t think I have to worry about units being in mm.
The only thing concerning is that chainSagCorrection, which is basically the sled weight here, is too low if it truly represents the sled weight.
Here’s a sample of the calculations:
chainSag: 30.0
targetX,Y: 0, 0
chainStraightL,R: 2095.25386998, 2095.25386998
ForcesL,R: 28.8908257068, 28.8908257068
anglesL,R: 31.554701169, 31.554701169
hl, hr: 5.85778143585, 5.85778143585
vl, vr: 3.59734930469, 3.59734930469
al, ar: 273.545078447, 273.545078447
Lchains (straight, sag, delta): 2095.25386998, 2095.28294102, 0.0290710335626
Rchains (straight, sag, delta): 2095.25386998, 2095.28294102, 0.0290710335626
finals: 1968.09884324, 1968.09884324
(finals are modified by chain wrap and rotational radius)