@@ -94,7 +94,7 @@ def spool_lengths(self, helper, pos):
9494 def expected_motor_to_line_pos (self , motor_pos , rotation_distance ,
9595 steps_per_rotation , buildup_factor ,
9696 mechanical_advantage = 1 ):
97- radius = rotation_distance / (2.0 * math .pi )
97+ radius = rotation_distance * float ( mechanical_advantage ) / (2.0 * math .pi )
9898 steps_per_mm = steps_per_rotation / rotation_distance
9999 k2 = - float (buildup_factor ) * float (mechanical_advantage )
100100 if abs (k2 ) <= 1.0e-12 or steps_per_mm <= 0.0 :
@@ -159,6 +159,23 @@ def test_buildup_model_matches_closed_form_with_gearing(self):
159159 motor_pos , rotation_distance , steps_per_rotation , buildup , 1 )
160160 self .assertAlmostEqual (actual , expected , places = 12 )
161161
162+ def test_buildup_model_scales_with_mechanical_advantage (self ):
163+ buildup = 0.6366197723675814
164+ rotation_distance = 123.10
165+ steps_per_rotation = 3200.0 * 12.75
166+ helper = self .build_helper (((0.0 , 0.0 , 0.0 ),),
167+ mover_weight = 0.0 ,
168+ spring = 0.0 ,
169+ target = 0.0 ,
170+ buildup_factor = buildup ,
171+ mechanical_advantage = [2 ])
172+ helper .set_spool_params (0 , rotation_distance , steps_per_rotation )
173+ motor_pos = 18.5
174+ actual = helper .motor_to_line_pos (0 , motor_pos )
175+ expected = self .expected_motor_to_line_pos (
176+ motor_pos , rotation_distance , steps_per_rotation , buildup , 2 )
177+ self .assertAlmostEqual (actual , expected , places = 12 )
178+
162179 def test_four_anchor_near_singularity (self ):
163180 helper = self .build_helper (FOUR_ANCHORS_PROBLEM )
164181 origin_lengths , _ , _ = self .spool_lengths (helper , (0.0 , 0.0 , 0.0 ))
0 commit comments