Skip to content

Commit a1a1dc1

Browse files
committed
Improve hydraulic cylinder and animation logic
Refactored hydraulic_cylinder module to support total mount-to-mount length and improved extension clamping for realistic visuals. Updated animation logic for arms and bucket to use a looping phase for smoother motion. Fixed orientation and placement of cylinder pins and wheel rotation axes. Adjusted bucket cylinder lug positions for better alignment with cylinder mounts.
1 parent 76be8b6 commit a1a1dc1

File tree

2 files changed

+36
-19
lines changed

2 files changed

+36
-19
lines changed

LifeTrac-v25/mechanical_design/modules/hydraulics.scad

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,24 @@ $fn = 32;
1616
*/
1717
module hydraulic_cylinder(bore_diameter=63.5, rod_diameter=31.75,
1818
stroke=300, retracted=true, extension=0,
19-
mounting_type="clevis") {
20-
21-
body_length = stroke + 100; // Body is longer than stroke
22-
actual_extension = retracted ? 0 : (extension > 0 ? extension : stroke);
19+
mounting_type="clevis", total_length=0) {
20+
// Clamp requested extension to realistic range to avoid flipped visuals
21+
desired_extension = retracted ? 0 : max(0, min(extension, stroke));
22+
// If a total mount-to-mount length is provided, keep extension within it
23+
actual_extension = (total_length > 0) ? min(desired_extension, total_length) : desired_extension;
24+
// Pick body length so body + rod extension spans the requested total length when given
25+
body_length = (total_length > 0)
26+
? max(total_length - actual_extension, rod_diameter * 2 + 20)
27+
: stroke + 100; // Legacy fallback sizing
2328

2429
// Cylinder body
2530
color("Orange")
2631
cylinder(d=bore_diameter, h=body_length);
2732

28-
// Rod
33+
// Rod (extends with increasing extension value)
2934
color("Silver")
3035
translate([0, 0, body_length])
31-
cylinder(d=rod_diameter, h=stroke - actual_extension);
36+
cylinder(d=rod_diameter, h=actual_extension);
3237

3338
// Base mounting
3439
color("DimGray")
@@ -53,9 +58,9 @@ module hydraulic_cylinder(bore_diameter=63.5, rod_diameter=31.75,
5358
cylinder(d=bore_diameter*1.3, h=20);
5459
}
5560

56-
// Rod end mounting
61+
// Rod end mounting follows the rod tip
5762
color("DimGray")
58-
translate([0, 0, body_length + stroke - actual_extension])
63+
translate([0, 0, body_length + actual_extension])
5964
if (mounting_type == "clevis") {
6065
// Clevis at rod end
6166
cylinder(d=rod_diameter*2, h=30);

LifeTrac-v25/mechanical_design/openscad/lifetrac_v25.scad

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,13 @@ echo("CLEARANCE_FROM_FRONT_WHEELS =", ARM_PIVOT_Y + ARM_HORIZONTAL_REACH - WHEEL
138138
ARM_TUBE_SIZE = TUBE_3X3_1_4; // 3"x3" arm tubing
139139
ARM_SPACING = TRACK_WIDTH; // Distance between arm centerlines
140140

141-
// Default arm position: lowered to ground (animation_time=0)
141+
// Looping animation: 0->0.5 = arms go up, 0.5->1 = arms come back down
142+
// This creates a smooth loop where the animation returns to start position
143+
animation_phase = animation_time < 0.5 ? (animation_time * 2) : (2 - animation_time * 2);
144+
145+
// Default arm position: lowered to ground (animation_phase=0)
142146
// ARM_GROUND_ANGLE is the angle below horizontal needed to reach ground
143-
ARM_LIFT_ANGLE = -ARM_GROUND_ANGLE + (animation_time * (60 + ARM_GROUND_ANGLE)); // Animate from ground to raised
147+
ARM_LIFT_ANGLE = -ARM_GROUND_ANGLE + (animation_phase * (60 + ARM_GROUND_ANGLE)); // Animate from ground to raised and back
144148

145149
// Cross beam positions along arm length (from pivot)
146150
// First cross beam positioned for bucket cylinder attachment
@@ -217,7 +221,11 @@ BUCKET_HEIGHT = 450;
217221
// At ground position (ARM_LIFT_ANGLE = -ARM_GROUND_ANGLE), bucket tilts forward to lay flat
218222
// The bucket bottom is horizontal when bucket tilt = ARM_GROUND_ANGLE (compensates for arm angle)
219223
BUCKET_GROUND_TILT = ARM_GROUND_ANGLE; // Tilt needed to make bottom flat when arm at ground
220-
BUCKET_TILT_ANGLE = BUCKET_GROUND_TILT + (animation_time * (45 - BUCKET_GROUND_TILT)); // From flat to curled
224+
BUCKET_MAX_CURL = 60; // Maximum curl angle when fully raised
225+
226+
// Bucket actuates with the arm using the same animation_phase for looping
227+
// Starts flat on ground, curls up as arm rises, then uncurls as arm lowers
228+
BUCKET_TILT_ANGLE = BUCKET_GROUND_TILT + (animation_phase * (BUCKET_MAX_CURL - BUCKET_GROUND_TILT)); // From flat to curled and back
221229

222230
// =============================================================================
223231
// HYDRAULIC CYLINDER MOUNTING POINTS
@@ -882,11 +890,12 @@ module oriented_cylinder(base_pt, target_pt, bore, rod, stroke, extension) {
882890

883891
translate(base_pt)
884892
rotate(a = angle, v = axis) {
885-
hydraulic_cylinder(bore, rod, stroke, false, extension, "clevis");
893+
// Scale cylinder to exactly span between mounts using total_length
894+
hydraulic_cylinder(bore, rod, stroke, false, extension, "clevis", len);
886895

887-
// Base clevis pin with nuts
896+
// Base clevis pin with nuts (pin axis along X to match lug holes)
888897
translate([0, 0, -10])
889-
rotate([90, 0, 0]) {
898+
rotate([0, 90, 0]) {
890899
// Pin
891900
color("Silver")
892901
cylinder(d=clevis_pin_dia, h=clevis_pin_length, center=true, $fn=24);
@@ -906,7 +915,7 @@ module oriented_cylinder(base_pt, target_pt, bore, rod, stroke, extension) {
906915

907916
translate(target_pt)
908917
rotate(a = angle, v = axis)
909-
rotate([90, 0, 0]) {
918+
rotate([0, 90, 0]) { // Pin axis along X to match lug holes
910919
// Pin
911920
color("Silver")
912921
cylinder(d=rod_pin_dia, h=rod_pin_length, center=true, $fn=24);
@@ -1376,7 +1385,7 @@ module wheel_assemblies() {
13761385
for (i = [0:3]) {
13771386
translate(positions[i])
13781387
rotate([0, 0, 90])
1379-
rotate([animation_time * 360, 0, 0]) // Spin animation
1388+
rotate([0, animation_time * 360, 0]) // Spin around axle (wheel axis is Y)
13801389
{
13811390
wheel(WHEEL_DIAMETER, WHEEL_WIDTH, 150, true);
13821391

@@ -1535,9 +1544,12 @@ module bobcat_quick_attach_plate() {
15351544
}
15361545

15371546
// Bucket cylinder attachment points - TYPE A: U-Channel from 3"x3" tube with pins
1538-
for (x = [-flange_spacing/2, flange_spacing/2]) {
1539-
translate([x, plate_thick + 40, -60]) // Near top of plate
1540-
rotate([0, 0, 90])
1547+
// Bucket cylinder lugs: align with cylinder line and bring inward toward machine center
1548+
for (side = [-1, 1]) {
1549+
x = side * BUCKET_CYL_X_SPACING; // Match arm-side cylinder X offset
1550+
y = plate_thick + 20; // Tuck closer to the plate (inboard)
1551+
z = -60; // Height on plate
1552+
translate([x, y, z])
15411553
u_channel_lug_with_pin(TUBE_3X3_1_4, 80, BOLT_DIA_3_4 + 2);
15421554
}
15431555
}

0 commit comments

Comments
 (0)