// ============================================
// SaltyLab — Full Assembly Visualization
// Shows all parts in position on 2020 spine
// ============================================
include <dimensions.scad>

// Spine height
spine_h = 500;

// Component heights (center of each mount on spine)
h_motor = 0;
h_battery = 50;
h_esc = 100;
h_fc = 170;
h_jetson = 250;
h_realsense = 350;
h_lidar = 430;

// Colors for visualization
module spine() {
    color("silver")
        translate([-extrusion_w/2, -extrusion_w/2, 0])
            cube([extrusion_w, extrusion_w, spine_h]);
}

module wheel(side) {
    color("DimGray")
        translate([side * 140, 0, 0])
            rotate([0, 90, 0])
                cylinder(d=200, h=50, center=true, $fn=60);
}

// --- Assembly ---

// Spine
spine();

// Wheels
wheel(-1);
wheel(1);

// Motor mount plate (at base)
color("DodgerBlue", 0.7)
    translate([0, 0, h_motor])
        import("motor_mount_plate.stl");

// Battery shelf
color("OrangeRed", 0.7)
    translate([0, 0, h_battery])
        rotate([0, 0, 0])
            cube([180, 80, 40], center=true);

// ESC
color("Green", 0.7)
    translate([0, 0, h_esc])
        cube([80, 50, 15], center=true);

// FC (tiny!)
color("Purple", 0.9)
    translate([0, 0, h_fc])
        cube([36, 36, 5], center=true);

// Jetson Orin Nano Super
color("LimeGreen", 0.7)
    translate([0, 0, h_jetson])
        cube([100, 80, 29], center=true);

// RealSense D435i
color("Gray", 0.8)
    translate([0, -40, h_realsense])
        cube([90, 25, 25], center=true);

// RPLIDAR A1
color("Cyan", 0.7)
    translate([0, 0, h_lidar])
        cylinder(d=70, h=41, center=true, $fn=40);

// Kill switch (accessible on front)
color("Red")
    translate([0, -60, h_esc + 30])
        cylinder(d=22, h=10, $fn=30);

// LED ring
color("White", 0.3)
    translate([0, 0, h_jetson - 20])
        difference() {
            cylinder(d=120, h=15, $fn=60);
            translate([0, 0, -1])
                cylinder(d=110, h=17, $fn=60);
        }

// Bumpers
color("Orange", 0.5) {
    translate([0, -75, 25])
        cube([350, 30, 50], center=true);
    translate([0, 75, 25])
        cube([350, 30, 50], center=true);
}

// Handle (top)
color("Yellow", 0.7)
    translate([0, 0, spine_h + 10])
        cube([100, 20, 25], center=true);

// Tether point
color("Red", 0.8)
    translate([0, 0, spine_h - 20]) {
        difference() {
            cylinder(d=30, h=8, $fn=30);
            translate([0, 0, -1])
                cylinder(d=15, h=10, $fn=30);
        }
    }

echo("=== SaltyLab Assembly ===");
echo(str("Total height: ", spine_h + 30, "mm"));
echo(str("Width (axle-axle): ", 280 + 50*2, "mm"));
echo(str("Depth: ~", 150, "mm"));
