# Anyone written a Python "translatePos(distance)" method?

Anyone written a Python “translatePosition(distance, technique)” method for moving a little left or right?

I’m thinking of three techniques:

• “Forward_S” turn plus back step
• “Backward_S” turn plus forward step
• “Right_angle” turn, fwd distance, opposite right angle turn

where the S turns use the orbit() function with an `s_angle=arc-cos(distance / wheel_base)` and the step `move = sin(s_angle)*wheel_base`. (Have to double check the calcs…)

Here is the first one - “Forward_S”

``````# TRANSLATE Sideways in millimeters
#     executes two forward S-turns and then drives back to starting line
#     1-3mm requires about an inch front clearance and 1.5 inches side clearance
#     1 inch requires about 3 inches front clearance and about 4 inches side clearance
#     3 inches requires about 4.5 inches front clearance and 6 inches side clearance
def translateMm(egpg=None,dist_mm=1.0,debug=False):
if (abs(dist_mm) > egpg.WHEEL_BASE_WIDTH):
translateMm(egpg, dist_mm / 2.0)
translateMm(egpg, dist_mm / 2.0)
ORBIT_SPEED = 120
egpg.set_speed(ORBIT_SPEED)
cosTheta = (egpg.WHEEL_BASE_WIDTH - abs(dist_mm)) / egpg.WHEEL_BASE_WIDTH
orbitAngle = math.degrees( math.acos(cosTheta) )