Skip to content

Commit b30dea6

Browse files
committed
Refactor bucket animation angle calculation
Reworked the bucket animation logic to interpolate the absolute bucket angle between horizontal at ground and -45 degrees at full lift. Added debug echo statements for animation variables and clarified comments for better maintainability.
1 parent 204e2eb commit b30dea6

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

LifeTrac-v25/mechanical_design/openscad/lifetrac_v25.scad

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,29 @@ BUCKET_HEIGHT = 450;
219219
// ANIMATION: Sweep from Max Curl (at bottom) to Max Dump (at top)
220220
// We calculate the Target ABSOLUTE angle based on animation phase
221221
// Then subtract the current Arm Angle to get the Relative Tilt Angle needed for the transform
222-
// MD: Default view ($t=0) overrides to 0 (flat) as per user request.
223-
// Fixed to force -45 degree dump at full lift
224-
_anim_abs_angle = ($t == 0) ? 0 : (BUCKET_ABS_CURL_ANGLE + (animation_phase * (-45 - BUCKET_ABS_CURL_ANGLE)));
222+
// At ground (phase=0): bucket horizontal (absolute = 0)
223+
// At full lift (phase=1): bucket dumps to -45 degrees below horizontal
224+
225+
// Target absolute bucket angles at each end of animation
226+
_bucket_abs_at_ground = 0; // Horizontal when on ground (flat for scooping)
227+
_bucket_abs_at_raised = -45; // 45 degrees below horizontal at full lift (dumping)
228+
229+
// Interpolate absolute bucket angle based on animation phase
230+
_anim_abs_angle = ($t == 0) ? _bucket_abs_at_ground :
231+
(_bucket_abs_at_ground + (animation_phase * (_bucket_abs_at_raised - _bucket_abs_at_ground)));
232+
233+
// Convert absolute angle to relative tilt (subtract arm rotation)
225234
BUCKET_TILT_ANGLE = _anim_abs_angle - ARM_LIFT_ANGLE;
226235

236+
// Debug output for animation
237+
echo("=== BUCKET ANIMATION DEBUG ===");
238+
echo("$t:", $t);
239+
echo("animation_phase:", animation_phase);
240+
echo("ARM_LIFT_ANGLE:", ARM_LIFT_ANGLE);
241+
echo("_anim_abs_angle (target absolute):", _anim_abs_angle);
242+
echo("BUCKET_TILT_ANGLE (relative):", BUCKET_TILT_ANGLE);
243+
echo("Actual absolute bucket angle:", ARM_LIFT_ANGLE + BUCKET_TILT_ANGLE);
244+
227245
// Legacy definitions for reference (unused in animation now)
228246
BUCKET_GROUND_TILT = -ARM_MIN_ANGLE;
229247
BUCKET_MAX_CURL = 60;

0 commit comments

Comments
 (0)