-
Notifications
You must be signed in to change notification settings - Fork 0
/
vector_02_robot_kinematics.scad
69 lines (54 loc) · 1.78 KB
/
vector_02_robot_kinematics.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
//---------------------------------------------------------------------
//-- Example of use of the vector library
//-- It is just an example of what can be done with the vector library
//-- A simple robot kinematics is show. For making the example easier
//-- no homogeneous transformation are used. There are no direct
//-- kinematic calculations. It will be done in future examples
//--
//-- A robot consisting of 4-DOF is drawn (with 2 spherical 2-DOF joints)
//-- The link projections on the z=0 are drawn as gray vectors to
//-- see the robot better
//---------------------------------------------------------------------
use <obiscad/vector.scad>
//-- Robot parameters
show_robot = false; //-- Show the whole robot or just the kinematics
ls = 3; //-- link section side
r = 3; //-- link sphere radius
robot_color="Yellow"; //--- Color
//-- Define the 2 link vectors and calculate their lengths
v1 = [20,20,20]; l1 = mod(v1);
v2 = [30,0,10]; l2 = mod(v2);
//-- Projections of the link vector on the z=0 plane
v1p = [v1[0], v1[1], 0];
v2p = [v2[0], v2[1], 0];
//-- Robot origin
frame(l=20);
//-- Draw link vector 1
vector(v1);
if (show_robot) {
//-- Origin robot sphere
color(robot_color) sphere(r=r, $fn=20);
//-- Link 1
orientate(v=v1, roll=0)
translate([0,0,l1/2])
color(robot_color) cube([ls,ls,l1],center=true);
}
//-- Draw link2
translate(v1) {
frame(l=20);
vector(v2);
if (show_robot) {
color(robot_color) sphere(r=r, $fn=20);
orientate(v=v2, roll=0)
translate([0,0,l2/2])
color(robot_color) cube([ls,ls,l2],center=true);
}
}
//-- Frame in the robot end
translate(v1+v2) {
frame(l=20);
}
//-- Draw the proyections (to see the robot better)
color("Gray") vector(v1p);
translate(v1p)
color("Gray") vector(v2p);