Commit 4a262042 authored by William Wadsworth's avatar William Wadsworth
Browse files

Camera rotation refactor

A lot of changes to clean up how camera rotations are defined and used.
Camera mounts and rendered camera boards are now are defined square to the axes.
Rotations for different optics modules are defined in dictionaries in optics_configurations.scad
parent a7db096c
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line

use <./libs/cameras/logitech_c270.scad>

rotate([180,0,0]){
translate([0,0,c270_backshell_height()]){
    c270_backshell();
}
 No newline at end of file
+0 −4
Original line number Diff line number Diff line
@@ -162,7 +162,6 @@ module arducam_b0196_camera_mount(screwhole=true){
    mounting_hole_xy = arducam_b0196_corner_hole_spacing();

    mount_height = key_lookup("mount_height", arducam_b0196_camera_dict());
    rotate(-45){
    difference(){
        translate([0*-w/2, 0*-b/2 -arducam_offset_y(), -mount_height]){
            arducam_rounded_block(w=w, b=b, h=mount_height, roc=3.5);
@@ -188,7 +187,6 @@ module arducam_b0196_camera_mount(screwhole=true){
        }
    }
}
}

// Counterbore mounting holes for the lens spacer to screw on from above
module b0196_counterbore(){
@@ -249,7 +247,6 @@ module at_b0196_hole_pattern(){
                    [-screw_xy,-screw_xy,0],
                    [close_screw_xy,0,0],
                    [-close_screw_xy,0,0]];
    rotate(-45){
    translate_y(-arducam_offset_y()){
        for(pos=mount_holes){
            translate(pos){
@@ -258,4 +255,3 @@ module at_b0196_hole_pattern(){
        }
    }
}
}
+10 −8
Original line number Diff line number Diff line
@@ -112,7 +112,6 @@ module c270_camera_mount(screwhole=true){
    y_excess = (screwhole)? 0 : c270_mount_y_excess();

    mount_height = key_lookup("mount_height", c270_camera_dict());
    rotate(-45){
    difference(){
        union(){
            // Cube over sensor for hulling to the lens mount, slightly raised
@@ -134,7 +133,6 @@ module c270_camera_mount(screwhole=true){
        c270_backshell_self_tap_screwholes();
    }
}
}

module c270_self_tap_screwholes(screwhole){
    mount_height = key_lookup("mount_height", c270_camera_dict());
@@ -172,12 +170,11 @@ module c270_backshell_self_tap_screwholes(){
    }
}

function c270_backshell_height() = 6;

module c270_backshell(){
    // This whole element is rotated 180 degrees about x when in place
    // y here becomes -y
    // z here becomes -z 
    
    height = 6;
    height = c270_backshell_height();
    h = c270_dims().y;
    w = c270_dims().x;

@@ -186,6 +183,12 @@ module c270_backshell(){
    //extra room for cable
    y_excess = c270_mount_y_excess();

    rotate_y(180){
        // This whole element is built upside down along the y-axis and needs to
        // be rotated 180 degrees about y to be in place
        // y here remains y
        // z here becomes -z
        // x here becomes -x
        difference(){
            //The main block
            end_from_centre = 3; // distance from axis of end of the cover
@@ -233,6 +236,7 @@ module c270_backshell(){
            cube([5, 50, h], center=true);
        }
    }
}

/* A module currently not used. If split in half it can clamp
around the block at the end of C270 cable & e-clip
@@ -300,7 +304,6 @@ module at_c270_hole_pattern(){
    // Third hole position at the far end of the board [-6,42.3,0] is too far away and makes 
    // the camera platform too big for mounting from above.
    //c270_third_hole_pos = [5,-9.5,0];
    rotate_z(-45){
    reflect_x(){
        translate([screw_x, 0, 0]){
            children();
@@ -310,4 +313,3 @@ module at_c270_hole_pattern(){
        children();
    }
}
}
+0 −8
Original line number Diff line number Diff line
@@ -146,7 +146,6 @@ module picamera_2_camera_mount(screwhole=true, counterbore=false){
    b = 24;
    w = 25;
    difference(){
        rotate(45){
        translate_y(2.4){
            sequential_hull(){
                translate_z(picamera_2_bottom_z()){
@@ -158,12 +157,9 @@ module picamera_2_camera_mount(screwhole=true, counterbore=false){
                cube([w-(-1.5-picamera_2_bottom_z())*2,b,tiny()],center=true);
            }
        }
        }
        rotate(45){
        translate_z(picamera_2_bottom_z()){
            picam2_cutout();
        }
        }
        if(counterbore){
            picamera_2_counterbore();
        }
@@ -176,7 +172,6 @@ module picamera_2_camera_mount(screwhole=true, counterbore=false){
module picamera_2_screwholes(){
    //chamfered screw holes for mounting
    screw_x = picamera_2_hole_spacing()/2;
    rotate_z(45){
    translate_z(picamera_2_bottom_z()){
        reflect_x(){
            translate_x(screw_x){
@@ -189,7 +184,6 @@ module picamera_2_screwholes(){
        }
    }
}
}

module picamera_2_counterbore(){
    translate_z(picamera_2_bottom_z()-1){
@@ -237,7 +231,6 @@ module picamera_2_bottom_mounting_posts(optics_config, outers=true, cutouts=true
module at_picamera_2_hole_pattern(){
    // posts to mount to pi camera from below
    screw_x = picamera_2_hole_spacing()/2;
    rotate(45){
    reflect_x(){
        for(y=[0,12.5]){
            translate([screw_x, y, 0]){
@@ -246,7 +239,6 @@ module at_picamera_2_hole_pattern(){
        }
    }
}
}

/////////// Cover for camera board //////////////
module picamera_2_cover(){
+10 −11
Original line number Diff line number Diff line
@@ -23,8 +23,8 @@ function optics_wedge_bottom() = -2; //bottom of dovetail (<0 to allow some play
// This is used for both the lens spacer and the tube lens gripper
function lens_aperture(lens_r) = lens_r - 1.5;

// This function is used because the C270 camera needs to be rotated when used with a lens spacer
// in order to fit in between the xy stage legs
// This function is used for conditional modification of optics modules  and platforms
// to fit the Logitech C270 webcam
function is_c270_spacer(optics_config) = (key_lookup("optics_type", optics_config) == "spacer")
                                            && (key_lookup("camera_type", optics_config) == "logitech_c270");

@@ -373,7 +373,7 @@ module lens_spacer(params, optics_config){

    // This is the height of the block the camera mounts into.
    camera_mount_height = camera_mount_height(optics_config);
    lens_spacer_rotate = is_c270_spacer(optics_config)? -135: 0;
    lens_spacer_rotate = key_lookup("rotation", optics_config);

    rotate_z(lens_spacer_rotate){
        translate_z(lens_spacer_z(params, optics_config)){
@@ -428,14 +428,14 @@ function camera_board_thickness(optics_config) = key_lookup("board_thickness", o
* * base_r - radius of mount body
* * camera_rotation - orientation of the camera compared the the OFM std
*/
module camera_platform(params, optics_config, base_r, _camera_rotation=0, text_=""){ //TODO remove _camera rotation when eliminated
module camera_platform(params, optics_config, base_r, text_=""){
    assert(key_lookup("optics_type", optics_config)=="spacer", "Use spacer optics configuration to create a camera_platform.");

    // platform height is 5mm below the lens spacer (board is 1mm thick mounting posts are 4mm tall)
    platform_h = lens_spacer_z(params, optics_config) - camera_mounting_post_height(optics_config) - camera_board_thickness(optics_config);
    assert(platform_h > upper_z_flex_z(params), "Platform height too low for z-axis mounting");

    camera_rotation = key_lookup("rotation", optics_config); // TODO deal with undefined, or put zero in all dictionaries (better)
    camera_rotation = key_lookup("rotation", optics_config);

    // Make a camera platform with a fitting wedge on the side and a platform on the top
    difference(){
@@ -496,24 +496,23 @@ module camera_platform(params, optics_config, base_r, _camera_rotation=0, text_=
        }
        // cut-out for Arducam b0196 cable
        if(is_b0196_spacer(optics_config)){
            rotate_z(45 + camera_rotation){
                translate([9,-11.5,10]){
                    cube([7,12,99]);
            echo("b0196",camera_rotation);
            rotate_z(camera_rotation){
                translate([-0.5,9,10]){
                    cube([12,99,99]);
                }
            }
        }
        // cut ledge for the backshell, with a little clearance
        if(is_c270_spacer(optics_config)){
            rotate_z(camera_rotation + 135){
            rotate_z(camera_rotation){
                translate_z(lens_spacer_z(params, optics_config)-0.1){
                    rotate([180,0,0]){
                    c270_backshell();
                }
            }
        }
    }
}
}


// A module to difference() from an objective fitting wedge
Loading