// ============================================
// SaltyLab — LIDAR Standoff
// Ø80×80mm ASA
// Raises RPLIDAR above all other components
// for unobstructed 360° scan
// Connects sensor_tower_top to 2020 extrusion
// ============================================
include <dimensions.scad>

standoff_od = 80;
standoff_h = 80;
wall_t = 3;

module lidar_standoff() {
    difference() {
        union() {
            // Main cylinder
            cylinder(d=standoff_od, h=standoff_h, $fn=60);
            
            // Bottom flange (bolts to extrusion bracket below)
            cylinder(d=standoff_od + 10, h=4, $fn=60);
        }
        
        // Hollow interior
        translate([0, 0, wall_t])
            cylinder(d=standoff_od - wall_t*2, h=standoff_h, $fn=60);
        
        // Cable routing hole (bottom)
        translate([0, 0, -1])
            cylinder(d=20, h=wall_t + 2, $fn=30);
        
        // Ventilation / weight reduction slots (4x around circumference)
        for (angle = [0, 90, 180, 270]) {
            rotate([0, 0, angle])
                translate([0, standoff_od/2, standoff_h/2])
                    rotate([90, 0, 0])
                        hull() {
                            translate([0, -15, 0])
                                cylinder(d=10, h=wall_t + 2, center=true, $fn=25);
                            translate([0, 15, 0])
                                cylinder(d=10, h=wall_t + 2, center=true, $fn=25);
                        }
        }
        
        // Bottom flange bolt holes (M5, 4x for mounting)
        for (angle = [45, 135, 225, 315]) {
            rotate([0, 0, angle])
                translate([standoff_od/2, 0, -1])
                    cylinder(d=m5_clear, h=6, $fn=25);
        }
        
        // Top mating holes (M3, align with sensor_tower_top)
        for (angle = [0, 90, 180, 270]) {
            rotate([0, 0, angle])
                translate([standoff_od/2 - wall_t - 3, 0, standoff_h - 8])
                    cylinder(d=m3_clear, h=10, $fn=25);
        }
    }
}

lidar_standoff();
