-
Notifications
You must be signed in to change notification settings - Fork 0
/
chorder.scad
2210 lines (1928 loc) · 68.1 KB
/
chorder.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// TODO: Whole thing should be much more comprehensively commented
// TODO: test object should have contacts at weird angles
// TODO: test object should include connector_positive/connector_negative
// TODO: model should echo() absolute positions of buttons, relative to some
// known point (connection point?)
partname = "composition";
// The Makefile scrapes the below, but you can specify partname to be any of
// the below values:
//
// _partname_values composition finger_end finger_l body wrist_handle test_object
/*****************************************************************************/
/* Likely calibration properties */
/*****************************************************************************/
// finger_measurements
//
// For the below, the "first joint" (joint 0) is the one at the base of the
// finger. Most people thus have joints 0, 1 and 2 on their four fingers, and
// joints 0 and 1 on their thumb (I'm not exception).
//
// The "first segment" (segment 0) thus is between joint 0 and joint 1, etc,
// until segment 2, which ends at the tip of the finger (segment 1 in the case
// of a thumb).
//
// Generally, these are measured when joints are bent 90 degrees.
//
// E.g. to measure segment 0 on pinky, you'd clench your fist and look at it
// from below. That way, joint0 and joint1 on pinky will be at an angle of at
// least 90 degrees. Then you put a caliper on those two pinky joints.
//
// (It gets more finger-yoga-like to do this with other joints. You'll probably
// have to use another hand to hold the joint in a slightly overstretched
// position. Or take a guess.)
pinky_segment_lengths = [ 53, 32, 38 ];
ring_segment_lengths = [ 65, 40, 41 ];
middle_segment_lengths = [ 69, 44, 41 ];
index_segment_lengths = [ 65, 39, 41 ];
thumb_segment_lengths = [ 54, 40 ];
// Radii of each finger:
pinky_radius = 7.5;
ring_radius = 9.0;
middle_radius = 10.0;
index_radius = 10.0;
thumb_radius = 11.0;
// Angles at joint 0, joint 1 and joint 2, for a "comfortably glove-shaped" hand:
pinky_angles = [20,37,33];
ring_angles = [20,60,20];
middle_angles = [15,60,10];
index_angles = [20,30,10];
thumb_angles = [0,0];
// Almost-guesstimate: for a fingers-stretched hand, where are the joint 0's?
//
pinky_joint0_offset = [ 110, -25,-15];
ring_joint0_offset = [ 89, -10,-10];
middle_joint0_offset = [ 64, 0, 0];
index_joint0_offset = [ 32, -2, 0];
thumb_joint0_offset = [ 5, -50,-40];
wristaxis_thumbside_upper_offset = [ 37, -80,-15];
wristaxis_pinkyside_upper_offset = [ 97, -80,-15];
wristaxis_radius = 20;
// four fingers: rotation around y axis:
pinky_joint0_rotation = [ 14, -30];
ring_joint0_rotation = [ 9, -10];
middle_joint0_rotation = [ -3, 0];
index_joint0_rotation = [ -10, 0];
// thumb: rotation around x axis:
thumb_joint0_rotation = [-110, -90];
// LiPo battery measurements:
lipo_compartment_wdh = [34+1,53+3.5,4.9+1];
// the girth of the riggers that make up the most of the finger mounts
frame_radius = 5;
button_l_thickness = 0.5;
button_l_thin_part_thickness = 0.5;
button_l_offset = 4;
button_l_cutout_thickness = button_l_thickness + 1;
// MCU related measurements:
// (Clearance in the height dimension has to be fairly generous if you're using
// Dupont cables.)
mcu_in_use = "TTGO T-Display";
mcu_wall_w = 1.5;
// Use to press MCU deeper (negative values) into its cutout:
mcu_vertical_indentation = -2;
// Elastic band width:
elastic_band_w = 20;
// measured as compressed, if relevant:
elastic_band_thickness = 1;
elastic_band_clearing_w = 22;
elastic_band_wall_w = 3;
button_hole_overdimension_factor = 1.15;
// how much to depress (in the z direction) contact_{positive,negative} given
// that the contact point is at z=0.
contact_z_depress = 15;
// how much depression of spring before electrical contact is made:
contact_clearance = 4;
// 0.3mm wire diameter 10 mm high 6mm outer diameter springs:
// https://www.aliexpress.com/item/33050149067.html
spring_radius = 3;
spring_height = 10;
// Do we want a GND connector on the body()?
include_gnd_connector = false;
/*****************************************************************************/
/* Less-likely calibration properties */
/*****************************************************************************/
// real m3 radius:
m3_radius = 1.5;
// so that an m3 bolt can be passed through without too much effort:
m3_clear_radius = 1.7;
m3_bolt_visualisation_height = 26;
m3_head_radius = 3; // from memory
m3_head_clear_radius = 3.2; // from memory
m3_nut_clear_radius = 3.4; // When creating $fn=6 cutouts for these
m3_nut_height = 2; // actual height (for visualisation)
m3_nut_clear_height = 4; // When creating $fn=6 cutouts for these
m3_head_height = 2; // from memory
m3_nut_holder_wall_w = 1;
connector_depth = 2;
aux_connector_dimension = frame_radius;
aux_connector_growth_factor = 1.3;
aux_connector_growth_height = 10;
aux_connector_standoff = 7;
// https://www.aliexpress.com/item/32960278288.html
// measured: microswitch_box_wdh = [5.79,12.86,6.16];
microswitch_box_wdh = [5.80+0.4,12.80+0.4,/*choosing measured*/6.16];
// Visually only:
microswitch_box_black_until_h = 3.17;
// Switch expands a bit around the mounting through holes:
microswitch_box_h_at_throughhole = 6.52;
microswitch_pin_wdh = [0.5,0.8,3.18];
microswitch_pin_depths = [
(12.80-2*5.15)/2,
(12.80-2*5.15)/2+1*5.15,
(12.80-2*5.15)/2+2*5.15
];
microswitch_lever_d = 1.42;
// only until the point under the radius; larger for cosmetic purposes
microswitch_lever_l = 14.50-5.00/2;
microswitch_lever_width = 3.6;
// estimate:
microswitch_lever_rest_angle = 20;
microswitch_lever_wheel_wr = [3,5.00/2];
// off the lever clearance:
microswitch_lever_wheel_raise = 1.00; // measured
microswitch_throughhole_r = 0.9; // crummy measurement; not precise
microswitch_throughholes_yzs = [
[(microswitch_box_wdh[1]-6.50)/2,5.80-5.10],
[(microswitch_box_wdh[1]-6.50)/2+6.50,5.80-5.10],
];
// the width of the pieces "holding up" the switch in its mount:
microswitch_support_bridge_width = 2;
microswitch_case_wall_w = 2;
// how far down (perspective of joint1 on the thumb) the connection point is placed:
thumb_connection_point_translation_distance = 2*thumb_radius;
// Derive coordinates and rotation vectors:
// Helper functions {{{
// These helper functions calculate the coordinate following a segment, as if
// *_joint0_rotation didn't exist (it can be compensated for, later on).
function x_coord_for(startvec,angle,segment,radius) =
startvec[0] ; // always same, given no _joint0 rotation.
function y_coord_for(startvec,angle,segment,radius) =
startvec[1] + cos(angle)*(segment-2*radius);
function z_coord_for(startvec,angle,segment,radius) =
startvec[2] + sin(-angle)*(segment-2*radius);
function sum(list,i=0) = i<len(list)-1 ? list[i] + sum(list,i+1) : list[i];
assert(sum([ 4, 5, 3]) == 12);
assert(sum([ 4, 1, -1]) == 4);
function rotate_coord(coord,joint0_rotation,relative_to_joint0_offset) =
[
// have hypotenuse and angle, want opposite:
relative_to_joint0_offset[0]-sin(joint0_rotation[0])*(relative_to_joint0_offset[2]-coord[2]),
coord[1], // remains the same when rotating around y axis
// have hypotenuse and angle, want adjacent:
relative_to_joint0_offset[2]-cos(joint0_rotation[0])*(relative_to_joint0_offset[2]-coord[2])
];
function coord_for(startvec,angle,segment,radius) =
[
x_coord_for(startvec,angle,segment,radius),
y_coord_for(startvec,angle,segment,radius),
z_coord_for(startvec,angle,segment,radius)
];
// Returns a euler rotation 3-tuple that can be used to rotate something in the
// direction of the vector given:
function rotation_of_vector(v) =
// {{{
// Due to OpenSCAD function syntax, the below cannot have interim variables.
// This was a previous calculation, for reference:
//
// rotation_upwards = atan(v[2])/sqrt(pow(v[0],2)+pow(v[1],2)));
// tangent = (v[1])/(v[0]);
// rotation_in_plane = atan(tangent) + (0 > (v[0]) ? 180 : 0);
[
0,
90-atan((v[2])/sqrt(pow(v[0],2)+pow(v[1],2))),
// possible corner case: what about _minus_ infinity?
(is_num(atan(v[1]/v[0])) ? atan(v[1]/v[0]) + (0 > (v[0]) ? 180 : 0) : 90)
];
// }}}
// Applies euler rotation 3-tuple rotations by way of matrix multiplication.
// This function's output is multiplied onto a vector of [0,0,length].
function rotation_for_euler_rotations(a) =
[[cos(a[2]),-sin(a[2]),0],[sin(a[2]),cos(a[2]),0],[0,0,1]]
* [[cos(a[1]),0,sin(a[1])],[0,1,0],[-sin(a[1]),0,cos(a[1])]]
* [[1,0,0],[0,cos(a[0]),-sin(a[0])],[0,sin(a[0]),cos(a[0])]];
// }}}
// Assign {pinky,ring,middle,index,thumb}_{coords,rotation} {{{
// For pinky {{{
_pinky_coord_1 = coord_for(pinky_joint0_offset,sum([for (i=[0:0]) pinky_angles[i]]),pinky_segment_lengths[0],pinky_radius);
_pinky_coord_2 = coord_for(_pinky_coord_1, sum([for (i=[0:1]) pinky_angles[i]]),pinky_segment_lengths[1],pinky_radius);
_pinky_coord_3 = coord_for(_pinky_coord_2, sum([for (i=[0:2]) pinky_angles[i]]),pinky_segment_lengths[2],pinky_radius);
pinky_coords = [
rotate_coord(pinky_joint0_offset,pinky_joint0_rotation,pinky_joint0_offset),
rotate_coord(_pinky_coord_1, pinky_joint0_rotation,pinky_joint0_offset),
rotate_coord(_pinky_coord_2, pinky_joint0_rotation,pinky_joint0_offset),
rotate_coord(_pinky_coord_3, pinky_joint0_rotation,pinky_joint0_offset)
];
pinky_rotation = [ for (i=[0:3])
[
sum([for (j=[0:i]) pinky_angles[j] ? -pinky_angles[j] : 0]),
pinky_joint0_rotation[0],
pinky_joint0_rotation[1],
],
];
// }}}
// For ring {{{
_ring_coord_1 = coord_for(ring_joint0_offset,sum([for (i=[0:0]) ring_angles[i]]),ring_segment_lengths[0],ring_radius);
_ring_coord_2 = coord_for(_ring_coord_1, sum([for (i=[0:1]) ring_angles[i]]),ring_segment_lengths[1],ring_radius);
_ring_coord_3 = coord_for(_ring_coord_2, sum([for (i=[0:2]) ring_angles[i]]),ring_segment_lengths[2],ring_radius);
ring_coords = [
rotate_coord(ring_joint0_offset,ring_joint0_rotation,ring_joint0_offset),
rotate_coord(_ring_coord_1, ring_joint0_rotation,ring_joint0_offset),
rotate_coord(_ring_coord_2, ring_joint0_rotation,ring_joint0_offset),
rotate_coord(_ring_coord_3, ring_joint0_rotation,ring_joint0_offset)
];
ring_rotation = [ for (i=[0:3])
[
sum([for (j=[0:i]) ring_angles[j] ? -ring_angles[j] : 0]),
ring_joint0_rotation[0],
ring_joint0_rotation[1],
],
];
// }}}
// For middle {{{
_middle_coord_1 = coord_for(middle_joint0_offset,sum([for (i=[0:0]) middle_angles[i]]),middle_segment_lengths[0],middle_radius);
_middle_coord_2 = coord_for(_middle_coord_1, sum([for (i=[0:1]) middle_angles[i]]),middle_segment_lengths[1],middle_radius);
_middle_coord_3 = coord_for(_middle_coord_2, sum([for (i=[0:2]) middle_angles[i]]),middle_segment_lengths[2],middle_radius);
middle_coords = [
rotate_coord(middle_joint0_offset,middle_joint0_rotation,middle_joint0_offset),
rotate_coord(_middle_coord_1, middle_joint0_rotation,middle_joint0_offset),
rotate_coord(_middle_coord_2, middle_joint0_rotation,middle_joint0_offset),
rotate_coord(_middle_coord_3, middle_joint0_rotation,middle_joint0_offset)
];
middle_rotation = [ for (i=[0:3])
[
sum([for (j=[0:i]) middle_angles[j] ? -middle_angles[j] : 0]),
middle_joint0_rotation[0],
middle_joint0_rotation[1],
],
];
// }}}
// For index {{{
_index_coord_1 = coord_for(index_joint0_offset,sum([for (i=[0:0]) index_angles[i]]),index_segment_lengths[0],index_radius);
_index_coord_2 = coord_for(_index_coord_1, sum([for (i=[0:1]) index_angles[i]]),index_segment_lengths[1],index_radius);
_index_coord_3 = coord_for(_index_coord_2, sum([for (i=[0:2]) index_angles[i]]),index_segment_lengths[2],index_radius);
index_coords = [
rotate_coord(index_joint0_offset,index_joint0_rotation,index_joint0_offset),
rotate_coord(_index_coord_1, index_joint0_rotation,index_joint0_offset),
rotate_coord(_index_coord_2, index_joint0_rotation,index_joint0_offset),
rotate_coord(_index_coord_3, index_joint0_rotation,index_joint0_offset)
];
index_rotation = [ for (i=[0:3])
[
sum([for (j=[0:i]) index_angles[j] ? -index_angles[j] : 0]),
index_joint0_rotation[0],
index_joint0_rotation[1],
],
];
// }}}
// For thumb {{{
// FIXME/HACK: Using 0.5 thumb_radius to compensate for the geometry of the
// ball of the thumb.
_thumb_coord_1 = coord_for(thumb_joint0_offset,sum([for (i=[0:0]) thumb_angles[i]]),thumb_segment_lengths[0],0.5*thumb_radius);
_thumb_coord_2 = coord_for(_thumb_coord_1, sum([for (i=[0:1]) thumb_angles[i]]),thumb_segment_lengths[1],thumb_radius);
thumb_coords = [
rotate_coord(thumb_joint0_offset,thumb_joint0_rotation,thumb_joint0_offset),
rotate_coord(_thumb_coord_1, thumb_joint0_rotation,thumb_joint0_offset),
rotate_coord(_thumb_coord_2, thumb_joint0_rotation,thumb_joint0_offset),
];
thumb_rotation = [ for (i=[0:2])
[
// Ternary expression necessary to handle that there is no angle available
// at joint2 for a thumb:
90+sum([for (j=[0:i]) thumb_angles[j] ? -thumb_angles[j] : 0]), // always 0 when rotating in y and x axes
thumb_joint0_rotation[0],
thumb_joint0_rotation[1],
],
];
// }}}
// }}}
// Calculating where the thumb connection point is {{{
thumb_connection_point =
thumb_coords[1]+
-thumb_connection_point_translation_distance*rotation_for_euler_rotations(thumb_rotation[1])*[0,0,1];
// }}}
// Calculating where the parts attaches to each other {{{
// Warning: inexact science at play. Technically, these points could be derived
// from observed angles between e.g. index and middle joint0's.
finger_end_connection_point_thumb =
0.2*index_joint0_offset+
0.8*thumb_connection_point+
[0,-frame_radius,0];
finger_end_connection_point_index =
0.6*index_joint0_offset +
0.4*middle_joint0_offset+
[0,-3*connector_depth,-10-frame_radius];
finger_end_connection_point_pinky =
0.3*ring_joint0_offset +
0.7*pinky_joint0_offset+
[0,-4*connector_depth,-8-frame_radius];
finger_end_connection_point_radius = frame_radius;
wrist_handle_connection_frame_height = 30;
wrist_handle_connection_stand_base_height = 20;
body_wristaxis_thumbside_upper_offset = wristaxis_thumbside_upper_offset+[0,0,-wristaxis_radius-frame_radius];
body_wristaxis_pinkyside_upper_offset = wristaxis_pinkyside_upper_offset+[0,0,-wristaxis_radius-frame_radius];
body_wristaxis_thumbside_lower_offset = wristaxis_thumbside_upper_offset+[0,0,-wristaxis_radius-frame_radius-wrist_handle_connection_frame_height];
body_wristaxis_pinkyside_lower_offset = wristaxis_pinkyside_upper_offset+[0,0,-wristaxis_radius-frame_radius-wrist_handle_connection_frame_height];
wrist_handle_connection_point_thumb_upper =
body_wristaxis_thumbside_upper_offset+[0,-frame_radius,0];
wrist_handle_connection_point_thumb_lower =
body_wristaxis_thumbside_lower_offset+[0,-frame_radius,0];
wrist_handle_connection_point_pinky_upper =
body_wristaxis_pinkyside_upper_offset+[0,-frame_radius,0];
wrist_handle_connection_point_pinky_lower =
body_wristaxis_pinkyside_lower_offset+[0,-frame_radius,0];
// }}}
// Assign other variables {{{
mcu_clearance_wdh =
("TTGO T-Display" == mcu_in_use) ? [52.5, 25.5,30] :
("Adafruit 32u4 BLE" == mcu_in_use) ? [51.5,23.5,30] :
// If mcu_in_use is not a valid choice:
[undef, undef, undef];
// }}}
// Helper modules:
module mcu_clearance_box()
{ // {{{
if ("TTGO T-Display" == mcu_in_use) {
mcu_clearance_box_ttgo_t_display_esp32();
} else if ("Adafruit 32u4 BLE" == mcu_in_use) {
mcu_clearance_box_adafruit_32u4_ble();
} else {
assert(false);
}
} // }}}
module mcu_clearance_box_ttgo_t_display_esp32()
{ // {{{
// This is for a TTGO T-Display
//
// https://github.com/Xinyuan-LilyGO/TTGO-T-Display
usb_clear_wh = [13,10];
usb_offset = [6,-3];
reset_button_interval=[36,43];
window_cutout_wd = [34+2*0.5,18+2*0.5];
cube(mcu_clearance_wdh);
// Window for viewing display:
// actual offset until display, from edge x=6 y=4
translate([5,3,0.01])
mirror([0,0,1])
cube([34+2*1,18+2*1,15]);
translate([reset_button_interval[0],-2,-1])
cube([reset_button_interval[1]-reset_button_interval[0],3,2*frame_radius]);
for (yoff = [2, mcu_clearance_wdh[1]-2])
translate([0,yoff,1])
rotate([0,90,0])
cylinder(r=2,h=mcu_clearance_wdh[0],$fn=20);
// TODO: cutout for user programmable buttons
for (yoff = [4.5, mcu_clearance_wdh[1]-4.5])
translate([49,yoff,-frame_radius])
cylinder(r=2.5,h=frame_radius+0.01,$fn=20);
// USB charging cable entry:
translate([
mcu_clearance_wdh[0]-0.01-usb_offset[0],
mcu_clearance_wdh[1]/2-usb_clear_wh[0]/2,
usb_offset[1]])
cube([frame_radius+usb_offset[0]+0.02,usb_clear_wh[0],usb_clear_wh[1]+0.01]);
} // }}}
module mcu_clearance_box_adafruit_32u4_ble()
{ // {{{
// This is for an Adafruit Feather 32u4 BLE
//
// https://learn.adafruit.com/adafruit-feather-32u4-bluefruit-le/overview
usb_clear_wh = [10.5,10];
usb_vertical_offset = -1.5;
cube(mcu_clearance_wdh);
// USB charging cable entry:
translate([
mcu_clearance_wdh[0]-0.01,
mcu_clearance_wdh[1]/2-usb_clear_wh[0]/2,
usb_vertical_offset])
cube([frame_radius+0.02,usb_clear_wh[0],usb_clear_wh[1]+0.01]);
// Battery connector (in reality from 8 to 14 mm from the end of board):
translate([
mcu_clearance_wdh[0]-5-10,
-frame_radius,
1])
cube([10,2*frame_radius,5+0.01]);
} // }}}
module cylinder_from_to (origin,dest,radius1,radius2)
{ // {{{
length = sqrt(
pow(origin[0]-dest[0],2)+
pow(origin[1]-dest[1],2)+
pow(origin[2]-dest[2],2)
);
rot = rotation_of_vector(dest-origin);
translate(origin)
rotate(rot)
cylinder(r1=radius1,r2=radius2,h=length);
} // }}}
module elastic_clasp_positive()
{ // {{{
rounding_r = 2;
clasp_length = elastic_band_clearing_w+2*elastic_band_wall_w+2*m3_head_clear_radius+2*m3_clear_radius-2*rounding_r;
minkowski()
{
cylinder(r=rounding_r,h=0.01,$fn=20);
translate([rounding_r,rounding_r,0])
cube([2*frame_radius-2*rounding_r,
clasp_length-2*rounding_r,
frame_radius]);
}
translate([0,0,-elastic_band_wall_w-elastic_band_thickness])
intersection()
{
cube([2*frame_radius,
clasp_length,
elastic_band_wall_w]);
minkowski()
{
sphere(rounding_r,$fn=20);
translate([rounding_r,rounding_r,rounding_r])
cube([2*frame_radius-2*rounding_r,
clasp_length-2*rounding_r,
elastic_band_wall_w-rounding_r]);
}
}
} // }}}
module elastic_clasp_negative()
{ // {{{
for (offs = [0,elastic_band_clearing_w+2*m3_clear_radius])
{
translate([
frame_radius,
elastic_band_wall_w+1*m3_clear_radius+offs,
-elastic_band_wall_w-elastic_band_thickness-0.01])
{
cylinder(r=m3_clear_radius,h=3*frame_radius,$fn=20);
}
translate([
frame_radius,
elastic_band_wall_w+1*m3_clear_radius+offs,
2*frame_radius-1.3*m3_head_height])
{
cylinder(r=m3_head_clear_radius,h=3*frame_radius,$fn=20);
}
}
} // }}}
rounding_r = 2;
clasp_length = elastic_band_clearing_w+2*elastic_band_wall_w+2*m3_head_clear_radius+2*m3_clear_radius-2*rounding_r;
loose_clasp_length = clasp_length;
module elastic_clip_positive(print_clip=true)
{ // {{{
rotate([0,90,0])
translate([-frame_radius,0,-3*frame_radius])
minkowski()
{
cylinder(r=rounding_r,h=0.01,$fn=20);
translate([rounding_r,rounding_r,0])
cube([2*frame_radius-2*rounding_r,
clasp_length-2*rounding_r,
3*frame_radius]);
}
module clasp_together()
{
difference()
{
translate([0,0,0])
hull()
{
rotate([-90,0,0])
for (o=[0,1*frame_radius])
translate([o,0,0])
cylinder(r=rounding_r,h=loose_clasp_length,$fn=20);
}
translate([0.5*frame_radius,0,0])
{
for (offs = [
/* 1*m3_head_clear_radius+1, */
/* loose_clasp_length/2, */
/* loose_clasp_length-(1*m3_head_clear_radius+1) */
/* 1*m3_head_clear_radius+1, */
loose_clasp_length/2-1*(1*m3_head_clear_radius+1),
loose_clasp_length/2+1*(1*m3_head_clear_radius+1),
/* loose_clasp_length-(1*m3_head_clear_radius+1) */
])
{
translate([0,0,-frame_radius])
{
translate([
0,
offs,
-elastic_band_wall_w-elastic_band_thickness-0.01])
{
cylinder(r=m3_clear_radius,h=3*frame_radius,$fn=20);
}
}
translate([
0,
offs,
rounding_r-0.5*m3_head_height])
{
cylinder(r=m3_head_clear_radius,h=3*frame_radius,$fn=20);
}
}
}
}
}
module clasp_one_side()
{
intersection()
{
translate([-frame_radius,0,0])
cube([3*frame_radius,loose_clasp_length,rounding_r]);
clasp_together();
}
}
if (print_clip)
{
rotate([0,90,0])
translate([0,-(loose_clasp_length-clasp_length)/2,-4*frame_radius])
{
clasp_one_side();
translate([0,0,-elastic_band_thickness])
mirror([0,0,1])
clasp_one_side();
}
}
} // }}}
module elastic_clip_negative()
{ // {{{
rotate([0,90,0])
translate([-frame_radius,0,-3*frame_radius])
translate([1.2*frame_radius,-0.01,frame_radius])
rotate([-90,0,0])
{
hull()
{
for (o=[0,frame_radius])
translate([o,0,0])
cylinder(r=rounding_r+1.5*elastic_band_thickness,h=0.02+clasp_length,$fn=20);
}
}
rotate([0,90,0])
translate([-frame_radius,0,-3*frame_radius])
translate([-0.01,(clasp_length-elastic_band_clearing_w)/2,-0.01])
cube([0.02+2*frame_radius,elastic_band_clearing_w,2*frame_radius]);
} // }}}
module connector_positive()
{ // {{{
rotate([-90,0,0])
{
cylinder(r=finger_end_connection_point_radius,h=connector_depth+frame_radius,$fn=20);
}
} // }}}
module connector_negative(extra_cutout=false,clear_for_insertion=true,hex=false)
{ // {{{
rotate([90,0,0])
{
translate([0,0,0])
cylinder(r=finger_end_connection_point_radius,h=connector_depth+frame_radius,$fn=20);
}
rotate([-90,0,0])
{
translate([0,0,-10])
cylinder(r=m3_clear_radius,h=20,$fn=20);
if (hex)
{
translate([0,0,m3_head_height])
rotate([0,0,0.5*360/6])
cylinder(r=m3_nut_clear_radius,h=m3_head_height+(extra_cutout?20:5),$fn=6);
}
else
{
translate([0,0,2*frame_radius-m3_head_height])
cylinder(r=m3_head_clear_radius,h=m3_head_height+5,$fn=30);
}
if(clear_for_insertion)
translate([0,0,2*frame_radius+5-0.01])
cylinder(r=m3_head_clear_radius,h=m3_head_height+20,$fn=20);
if(extra_cutout)
translate([0,0,2*frame_radius+5-0.01])
cylinder(r=m3_head_clear_radius,h=10,$fn=20);
}
} // }}}
module connector_access_negative(hex=false)
{ // {{{
rotate([-90,0,0])
{
hull ()
{
for (t=[0,frame_radius])
{
translate([0,t,m3_head_height])
if (hex)
rotate([0,0,0.5*360/6])
cylinder(r=m3_nut_clear_radius,h=m3_nut_clear_height,$fn=6);
else
cylinder(r=m3_head_clear_radius,h=m3_nut_clear_height,$fn=20);
}
}
}
} // }}}
module showcase_rotation_for_euler_rotations()
{ // {{{
angles = [[119,-133,-94], [-129,112,-142], [104,-44,-139], [70,99,-85],
[-146,171,64], [113,55,-26], [-39,-169,-58], [-8,82,39], [86,-110,-33],
[168,119,67], [-9,58,114], [69,110,39], [99,26,175], [140,-84,95],
[-132,-58,78], [112,-125,-47], [-94,8,-35], [20,173,-141], [-121,79,-71],
[19,59,-131]];
for(angle=angles)
{
amplitude = 10;
dest = amplitude*rotation_for_euler_rotations(angle)*[0,0,1];
translate(dest)
color("green")
{
translate([0,0,0.2*amplitude])
cylinder(r=0.1,h=0.8*amplitude,$fn=10);
cylinder(r1=0.01,r2=0.4,h=0.2*amplitude,$fn=10);
}
rotate(angle)
color("blue")
{
cylinder(r=0.1,h=0.8*amplitude,$fn=10);
translate([0,0,0.8*amplitude])
cylinder(r1=0.4,r2=0.01,h=0.2*amplitude,$fn=10);
}
}
} // }}}
module segment (length,radius)
{ // {{{
sphere(radius);
cylinder(r=radius,h=length);
} // }}}
module final_segment (length,radius)
{ // {{{
sphere(radius);
intersection()
{
rotate([10,0,0])
cylinder(r=radius,h=length);
cylinder(r=radius,h=length);
}
} // }}}
module compass (length=20)
{ // {{{
$fn=20;
% union ()
{
color("red")
{
cylinder_from_to([0,0,0],[length-2,0,0],0.2,0.2);
cylinder_from_to([length-2,0,0],[length,0,0],0.6,0.01);
}
color("green")
{
cylinder_from_to([0,0,0],[0,length-2,0],0.2,0.2);
cylinder_from_to([0,length-2,0],[0,length,0],0.6,0.01);
}
color("blue")
{
cylinder_from_to([0,0,0],[0,0,length-2],0.2,0.2);
cylinder_from_to([0,0,length-2],[0,0,length],0.6,0.01);
}
}
} // }}}
module contact_negative ()
{ // {{{
contact_negative_microswitchbased();
} // }}}
module contact_positive ()
{ // {{{
contact_positive_microswitchbased();
} // }}}
module microswitch ()
{ // {{{
difference()
{
union()
{
// white part of body
color("white")
{
cube([microswitch_box_wdh[0],microswitch_box_wdh[1],microswitch_box_wdh[2]-microswitch_box_black_until_h]);
// boxy shape around throughholes:
for(yz = microswitch_throughholes_yzs)
translate([0,yz[0]-microswitch_throughhole_r,microswitch_box_wdh[2]-microswitch_box_h_at_throughhole])
cube([microswitch_box_wdh[0],2*microswitch_throughhole_r,2*microswitch_throughhole_r]);
}
// black part of body
color("black")
translate([0,0,microswitch_box_wdh[2]-microswitch_box_black_until_h])
cube([microswitch_box_wdh[0],microswitch_box_wdh[1],microswitch_box_black_until_h]);
// pins
color("silver")
for (d = microswitch_pin_depths)
translate([microswitch_box_wdh[0]/2,d,-microswitch_pin_wdh[2]])
translate([-microswitch_pin_wdh[0]/2,-microswitch_pin_wdh[1]/2,0])
cube(microswitch_pin_wdh);
// lever and wheel:
translate([(microswitch_box_wdh[0]-microswitch_lever_width)/2,microswitch_lever_d,microswitch_box_wdh[2]])
{
rotate([microswitch_lever_rest_angle,0,0])
{
// the lever itself:
color("silver")
cube([microswitch_lever_width,microswitch_lever_l+microswitch_lever_wheel_wr[1],0.2]);
// the wheel on the lever:
color("black")
translate([
(microswitch_lever_width-microswitch_lever_wheel_wr[0])/2,
microswitch_lever_l,
microswitch_lever_wheel_raise+microswitch_lever_wheel_wr[1]
]) {
rotate([0,90,0])
cylinder(r=microswitch_lever_wheel_wr[1],h=microswitch_lever_wheel_wr[0],$fn=12);
}
}
}
}
// cut out through-holes:
union()
{
color("white")
for(yz = microswitch_throughholes_yzs)
translate([-microswitch_box_wdh[0],yz[0],yz[1]])
rotate([0,90,0])
cylinder(r=microswitch_throughhole_r,h=3*microswitch_box_wdh[0],$fn=12);
}
}
} // }}}
microswitch_translation = [
-(
microswitch_lever_l
+sin(microswitch_lever_rest_angle)*microswitch_box_wdh[2]
+cos(microswitch_lever_rest_angle)*microswitch_lever_d
),
microswitch_box_wdh[0]/2,
-(
cos(microswitch_lever_rest_angle)*microswitch_box_wdh[2]
-sin(microswitch_lever_rest_angle)*microswitch_lever_d
+microswitch_lever_wheel_raise
+ 2*microswitch_lever_wheel_wr[1]
)
+ contact_clearance
];
microswitch_rotation = [-microswitch_lever_rest_angle,0,-90];
module contact_positive_microswitchbased ()
{ // {{{
// visualisation:
/* % */
/* translate(microswitch_translation) */
/* { */
/* rotate(microswitch_rotation) */
/* /1* translate([0,0,contact_clearance]) *1/ */
/* microswitch(); */
/* } */
// positive parts of holder for microswitch:
translate(microswitch_translation)
{
rotate(microswitch_rotation)
{
difference()
{
minkowski()
{
sphere(r=microswitch_case_wall_w,$fn=20);
cube(microswitch_box_wdh+[0,microswitch_lever_wheel_wr[1],3]);
}
// cut off near-finger minkowski box:
translate([
0,
0,
cos(microswitch_lever_rest_angle)*(microswitch_lever_wheel_raise+microswitch_lever_wheel_wr[1]+microswitch_box_wdh[2])
]) {
rotate([microswitch_lever_rest_angle,0,0])
translate([-microswitch_box_wdh[0],-microswitch_box_wdh[1],0])
cube([3*microswitch_box_wdh[0],3*microswitch_box_wdh[1],10]);
}
}
}
}
} // }}}
module contact_negative_microswitchbased ()
{ // {{{
translate(microswitch_translation)
{
rotate(microswitch_rotation)
{
// cutout for mounting of box itself:
//
// (countersunk a bit to handle indentations around throughholes of switch)
translate([0,0,-(microswitch_box_h_at_throughhole-microswitch_box_wdh[2])])
cube([
microswitch_box_wdh[0],
microswitch_box_wdh[1],
microswitch_box_h_at_throughhole,
]);
// cutout for free movement of lever arm
hull()
{
translate([0,0,microswitch_box_wdh[2]])
{
cube([
microswitch_box_wdh[0],
max(microswitch_box_wdh[1],microswitch_lever_d+microswitch_lever_l+microswitch_lever_wheel_wr[1]),
microswitch_box_wdh[2]+microswitch_lever_wheel_raise+2*microswitch_lever_wheel_wr[1],
]);
}
translate([
0,
microswitch_lever_d+microswitch_lever_l,
microswitch_box_wdh[2]
+sin(microswitch_lever_rest_angle)*microswitch_lever_l
+cos(microswitch_lever_rest_angle)*microswitch_lever_wheel_raise
+microswitch_lever_wheel_wr[1]
])
rotate([0,90,0])
cylinder(r=microswitch_lever_wheel_wr[1],h=microswitch_box_wdh[0],$fn=20);
}
microswitch_with_lever_length = max(microswitch_box_wdh[1],microswitch_lever_d+microswitch_lever_l+microswitch_lever_wheel_wr[1]);
// cut out for the easy movement of the finger:
// TODO: should probably be a cylinder of sorts:
translate([
0,
microswitch_case_wall_w,
cos(microswitch_lever_rest_angle)*(microswitch_lever_wheel_raise+microswitch_lever_wheel_wr[1]+microswitch_box_wdh[2])
]) {
rotate([0,0,0])
translate([-microswitch_box_wdh[0],0,0])
cube([
3*microswitch_box_wdh[0],
2*microswitch_case_wall_w+microswitch_with_lever_length,
2*(2*microswitch_lever_wheel_wr[1]+microswitch_lever_wheel_raise)]);
}
// cutout for cable through's
// cutting everything out except the bars that the microswitch rests
// on, thus, difference():
microswitch_support_bridge_width = 2;
difference()
{
translate([0,0,-2*microswitch_box_h_at_throughhole])
{
cube([